complete rework of the user interface (using raygui)

This commit is contained in:
2026-02-27 02:58:35 +01:00
parent bd1bd79825
commit 2517a9d33b
20 changed files with 1781 additions and 586 deletions

View File

@ -1,6 +1,7 @@
#include "puzzle.hpp"
#include "config.hpp"
#include <print>
#include <unordered_set>
#ifdef TRACY
@ -8,7 +9,7 @@
#include <tracy/Tracy.hpp>
#endif
auto Block::Hash() const -> int {
auto Block::Hash() const -> std::size_t {
std::string s = std::format("{},{},{},{}", x, y, width, height);
return std::hash<std::string>{}(s);
}
@ -59,7 +60,9 @@ auto Block::Collides(const Block &other) const -> bool {
y < other.y + other.height && y + height > other.y;
}
auto State::Hash() const -> int { return std::hash<std::string>{}(state); }
auto State::Hash() const -> std::size_t {
return std::hash<std::string>{}(state);
}
auto State::HasWinCondition() const -> bool {
return target_x != 9 && target_y != 9;
@ -80,8 +83,9 @@ auto State::IsWon() const -> bool {
}
auto State::SetGoal(int x, int y) -> bool {
if (x < 0 || x >= width || y < 0 || y >= height ||
!GetTargetBlock().IsValid()) {
Block target_block = GetTargetBlock();
if (!target_block.IsValid() || x < 0 || x + target_block.width > width ||
y < 0 || y + target_block.height > height) {
return false;
}
@ -99,6 +103,12 @@ auto State::SetGoal(int x, int y) -> bool {
return true;
}
auto State::ClearGoal() -> void {
target_x = 9;
target_y = 9;
state.replace(3, 2, "99");
}
auto State::AddColumn() const -> State {
State newstate = State(width + 1, height, restricted);
@ -379,8 +389,8 @@ auto State::Closure() const
}
} while (remaining_states.size() > 0);
std::cout << "Closure contains " << states.size() << " states with "
<< links.size() << " links." << std::endl;
std::println("State space has size {} with {} transitions.", states.size(),
links.size());
return std::make_pair(states, links);
}