4 ms·
I forked the main 2048 repo and modified it so that you can write your own "brain" for it: https://github.com/loisaidasam/2048 https://github.com/loisaidasam/2
by loisaidasam 13y ago
I forked the main 2048 repo and modified it so that you can write your own "brain" for it:
https://github.com/loisaidasam/2048 https://github.com/loisaidasam/2048
Essentially it communicates via an API to a webserver where you write your "brain" logic and respond to the API requests with which move to choose next:
https://github.com/loisaidasam/2048/blob/master/js/autonomous_brain.js https://github.com/loisaidasam/2048/blob/master/js/autonomou...
Since it's over web, you can write your webserver in the language of your choosing. I wrote a small dumb Python webserver using the Flask microframework:
https://github.com/loisaidasam/2048/blob/master/py/webserver.py https://github.com/loisaidasam/2048/blob/master/py/webserver...
And it simply returns a random direction:
https://github.com/loisaidasam/2048/blob/master/py/game.py https://github.com/loisaidasam/2048/blob/master/py/game.py
This can be adapted obviously for whatever logic you choose. The reason I forked this version and not a totally server-side one (which would be better for performance obviously) is that you can actually watch the moves this one makes as it chooses them, which makes it kinda fun.
Enjoy!
- elwell 13y agoThis is the most efficient version I was able to get: https://news.ycombinator.com/item?id=7475031 https://news.ycombinator.com/item?id=7475031