A few years ago Gabriele Cirulli developed a sliding puzzle where the goal is to grow tiles and get up to 2048. My “Proj 2048” is about implementing several agents to play. Which should get tiles up to 4096 or maybe even 64536 (if it’s possible of course) 😉.
As a start point, I implemented elementary clockwise and anticlockwise agents, I was surprised how easy they can get the tile with 256 scores. My first few games stuck on 128.
Let get to implementation details.
Entity Component System (ECS) pattern.
What exactly is ESC let’s discuss it late. For now, let’s agree to use it as a pattern to separate data (component), processing logic (system), and entities group components under single roof.
ESC requires some kind of library that will manage components, entities, and execute systems. The project was made with mizu lib.
I used ESC for the first time and probably didn’t do the correct declaration of components.
I faced an issue to use pointers as a field type. To quickly solve it - wrapped by extra tier check code example below. Workaround highlighted.
It could be limitation of used ECS library (it based on reflection) or incorrect usage on my side 😀
The agent has to decide about next move base on current game state
valueList and some other values such as
noMove flag (
true if was not possible to move by previous try, i.e. full board but collapsible vertically, but tried to move horizontally) or game
The direction is just a string typed as “Direction”
Please try to play on the project page (WebAssembly) or check how far agents’ progress can be.