I previously wrote about an AI for the Columns game. It was actually not written for the web to start with, but for a set of NeoPixel displays. Now I have fixed it up a little, made the code public and even have a picture to show.
The hardware for this build is a NodeMCU board (ESP8266 based) hooked up to two CJMCU-64 RGB LED displays in cascade. The displays are very easy to connect. After soldering on the connectors (DIN, +5V, GND) simply hook them up to D4, Vin and GND on the board. The displays will share USB power with the NodeMCU board and I would recommend also adding a large capacitor in parallel with Vin and GND.
If you are using something other than a NodeMCU then you’ll need to change the method parameter to the NeoPixelBus strip. See the documentation for the NeoPixelBus library for more details. Similarly if your displays have a different layout you will need to change the tiles object:
// Neopixel displays const uint16_t PixelCount = 8*8*2; const uint8_t PixelPin = D4; NeoPixelBus<NeoGrbFeature, NeoEsp8266Uart800KbpsMethod> strip(PixelCount); const int PanelWidth = 8; const int PanelHeight = 8; const int TileWidth = 1; const int TileHeight = 2; NeoTiles <ColumnMajorLayout, RowMajorLayout> tiles( PanelWidth, PanelHeight, TileWidth, TileHeight);
I have pushed the code to weinholt/columns on GitHub. You can either load it as a sketch in the Arduino IDE or use the makefile to test it with ncurses.
Please leave a comment if you use the code in your own project!