diff --git a/include/renderer.hpp b/include/renderer.hpp index 0e365b2..e444b73 100644 --- a/include/renderer.hpp +++ b/include/renderer.hpp @@ -51,11 +51,11 @@ public: instancing_shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(instancing_shader, "viewPos"); - infoln("LOC vertexPosition: {}", - rlGetLocationAttrib(instancing_shader.id, "vertexPosition")); - infoln("LOC instanceTransform: {}", - rlGetLocationAttrib(instancing_shader.id, "instanceTransform")); - infoln("LOC instanceColor: {}", rlGetLocationAttrib(instancing_shader.id, "instanceColor")); + // infoln("LOC vertexPosition: {}", + // rlGetLocationAttrib(instancing_shader.id, "vertexPosition")); + // infoln("LOC instanceTransform: {}", + // rlGetLocationAttrib(instancing_shader.id, "instanceTransform")); + // infoln("LOC instanceColor: {}", rlGetLocationAttrib(instancing_shader.id, "instanceColor")); // vertex_mat.maps[MATERIAL_MAP_DIFFUSE].color = VERTEX_COLOR; vertex_mat.shader = instancing_shader; diff --git a/include/state_manager.hpp b/include/state_manager.hpp index f95c010..f527ab1 100644 --- a/include/state_manager.hpp +++ b/include/state_manager.hpp @@ -34,7 +34,7 @@ private: std::unordered_set path_indices; // For faster lookup if a vertex is part of the path in renderer - std::stack move_history; // Moves between the starting state and the current state + std::vector move_history; // Moves between the starting state and the current state std::unordered_map visit_counts; // How often each state was visited size_t starting_state_index = 0; diff --git a/src/puzzle.cpp b/src/puzzle.cpp index 40f97be..69c41e9 100644 --- a/src/puzzle.cpp +++ b/src/puzzle.cpp @@ -498,7 +498,7 @@ auto puzzle::explore_state_space() const ZoneScoped; #endif - infoln("Exploring state space, this might take a while..."); + // infoln("Exploring state space, this might take a while..."); std::vector state_pool; std::unordered_map state_indices; // Helper to construct the links vector diff --git a/src/state_manager.cpp b/src/state_manager.cpp index b34ab84..6b0044c 100644 --- a/src/state_manager.cpp +++ b/src/state_manager.cpp @@ -6,7 +6,7 @@ #include #ifdef TRACY - #include +#include #endif auto state_manager::synced_try_insert_state(const puzzle& state) -> size_t @@ -35,8 +35,7 @@ auto state_manager::synced_insert_link(size_t first_index, size_t second_index) } auto state_manager::synced_insert_statespace(const std::vector& states, - const std::vector>& _links) - -> void + const std::vector>& _links) -> void { if (!state_pool.empty() || !state_indices.empty() || !links.empty()) { warnln("Inserting statespace but collections haven't been cleared"); @@ -71,7 +70,7 @@ auto state_manager::synced_clear_statespace() -> void winning_path.clear(); path_indices.clear(); - move_history = std::stack(); + // move_history.clear(); visit_counts.clear(); // Queue an update to the physics engine state to keep in sync @@ -186,7 +185,7 @@ auto state_manager::update_current_state(const puzzle& p) -> void current_state_index = index; if (current_state_index != previous_state_index) { - move_history.push(previous_state_index); + move_history.emplace_back(previous_state_index); } if (p.won()) { @@ -208,7 +207,7 @@ auto state_manager::edit_starting_state(const puzzle& p) -> void { clear_graph_and_add_current(p); - move_history = std::stack(); + move_history.clear(); total_moves = 0; for (int& visits : visit_counts | std::views::values) { visits = 0; @@ -226,7 +225,7 @@ auto state_manager::goto_starting_state() -> void visits = 0; } visit_counts[current_state_index]++; - move_history = std::stack(); + move_history.clear(); total_moves = 0; } @@ -251,11 +250,11 @@ auto state_manager::goto_previous_state() -> void return; } - update_current_state(get_state(move_history.top())); + update_current_state(get_state(move_history.back())); // Pop twice because update_current_state adds the state again... - move_history.pop(); - move_history.pop(); + move_history.pop_back(); + move_history.pop_back(); } auto state_manager::goto_most_distant_state() -> void @@ -287,23 +286,24 @@ auto state_manager::goto_closest_target_state() -> void auto state_manager::populate_graph() -> void { -#ifdef TRACY + #ifdef TRACY ZoneScoped; -#endif + #endif // Need to make a copy before clearing the state_pool + const puzzle s = get_starting_state(); const puzzle p = get_current_state(); // Clear the graph first so we don't add duplicates somehow synced_clear_statespace(); // Explore the entire statespace starting from the current state - const auto& [states, _links] = p.explore_state_space(); + const auto& [states, _links] = s.explore_state_space(); synced_insert_statespace(states, _links); current_state_index = state_indices.at(p); previous_state_index = current_state_index; - starting_state_index = current_state_index; + starting_state_index = state_indices.at(s); // Search for cool stuff populate_winning_indices(); @@ -345,9 +345,9 @@ auto state_manager::populate_winning_indices() -> void auto state_manager::populate_node_target_distances() -> void { -#ifdef TRACY + #ifdef TRACY ZoneScoped; -#endif + #endif if (links.empty() || winning_indices.empty()) { return;