Implement Live State Editing

This commit is contained in:
2025-08-31 19:24:28 +02:00
parent 847d61ecca
commit e0275b12af
4 changed files with 155 additions and 2 deletions

View File

@ -183,6 +183,22 @@ const visualize_path = (from_state, to_state) => {
// For each state in path: visualize(state)
};
const add_block = (state, x0, y0, x1, y1) => {
let dir;
if (x1 - x0 > y1 - y0) {
dir = HORIZONTAL;
} else if (x1 - x0 < y1 - y0) {
dir = VERTICAL;
} else {
// No square blocks for this model
return null;
}
let new_block = [state.board.length, dir, x0, y0, x1, y1];
state.board.push(new_block);
return new_block;
};
export const restricted_sliding_blocks_model = {
name: "Restricted Sliding Blocks",
generate,
@ -192,4 +208,11 @@ export const restricted_sliding_blocks_model = {
initial_states,
select,
move,
empty_state: {
name: "Custom",
width: 5,
height: 5,
board: [],
},
add_block,
};