carrots, and an A* algorithm!
- carrot game mechanic!
new entity type: carrots! they can be placed on top of existing tiles. carrots subtract 3 from your move count, when a bunny consumes a carrot! consume a carrot by moving a bunny on top of a carrot.
- optimized solving algorithm, accounting for carrots
instead of the O(N^2 * 2^C * C) BFS solver, I made a O(N^2 * 2^C * (C + log N)) A* algorithm! to avoid doing a linear scan over the board for every carrot, i implemented a bigint bitmask and used brian kernighan’s bit trick to efficiently read carrots in O(1) time.
although the BFS technically has a better worse case, A* uses a distance heuristic to prioritize paths that lead towards goals, avoiding dead paths.
finally, ive implemented creating a web worker to solve the solution on a different thread, preventing the UI from freezing while the solver tries to solve the level.
- undo/redo in editor
used stacks for undoing/redoing in editor, available through ctrl + z or cmd + z/ctrl + y or cmd + y
Comments 1
Yay carrots for bunni
Sign in to join the conversation.