Improve Generation Performance: Store states in HashMap and don't update the GraphData incrementally

This commit is contained in:
2025-08-30 15:39:07 +02:00
parent 4738e5f2d4
commit 478fa10afd
6 changed files with 90 additions and 52 deletions

View File

@ -6,6 +6,7 @@ import {
DIRECTIONS,
invert_direction,
} from "../../constants.js";
import { key_of } from "../../main.js";
export const arrays_are_equal = (array, other_array) => {
if (array.length != other_array.length) {
@ -39,6 +40,8 @@ export const state_contains_block = (state, block) => {
};
export const states_are_equal = (state, other_state) => {
return key_of(state) === key_of(other_state);
if (state.board.length != other_state.board.length) {
return false;
}
@ -74,6 +77,7 @@ export const index_of_state = (states, state) => {
export const remove_block = (state, block) => {
let new_state = structuredClone(state);
delete new_state.name;
new_state.board.splice(block[0], 1);