Docker, ShutIt and the Perfect 2048 Game (3 – Brute Force Escapes)
Now that I’m getting near the end of the highest tile on 2048, the air is getting thin.
I often get into a state like this:
where I need a four – not a two – to drop in on the top.
Since fours are less frequent than twos, I have to start up, try, quit, and repeat multiple times, which gets quite tedious.
So I automated it using visgrep.
visgrep is a seemingly obscure tool (part of the xautomation package on ubuntu) to search for images within other images. I won’t go into its use here (it’s _not_ user-friendly and in-depth documentation is perhaps kept by monks somewhere), but there is a man page.
I’ve used it in the commented-out sections here:
https://github.com/ianmiell/shutit/blob/master/library/win2048/resources/start_win2048.sh
To use it, uncomment the lines, and put the appropriate key code in, save the container and run it as below:
host_prompt$ while [ 1 ]; do sudo docker run -t -i -p 5901:5901 -p 6080:6080 -e HOME=/root imiell/2048_left /root/start_vnc.sh; sleep 5; done New 'b80055fbbeff:1 ()' desktop is b80055fbbeff:1 Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/b80055fbbeff:1.log Did you expose ports 5901 and 6080? If so, then vnclient localhost:1 should work. 18874476 307,129 0 307,130 0 306,131 0 307,131 0 308,131 0 307,132 0 307,133 0 0 FAIL [about output loops n times] New '3fd43021ea4a:1 ()' desktop is 3fd43021ea4a:1 Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/3fd43021ea4a:1.log Did you expose ports 5901 and 6080? If so, then vnclient localhost:1 should work. 16777324 0 OK container_prompt$
So when I see an “OK” and a prompt within the container I know I can vnc in and continue playing.
The time saved by doing this is significant.
I’m not really a game player, but I imagine this principle could be applied to a lot of games. Also, the process could be made much more slick, as this is still very much by-hand.