A game of 6×6 Othello where one player is a human and the other is a computer.
Area of Interest
Electrical engineering and computer science
Urban School of San Francisco
This project taught me a great deal about hardware problem solving and software debugging. My experience with the original RGB LED Matrix taught me the hazards of shoddy manufacturing. y encounter with he NeoPixel Matrix taught me the value of documentation, the annoyances of its absence, and allowed me to practice my knowledge of circuitry. My ups and downs each taught me something: killing my first Arduino reminded me of the most basic facts of Ohm’s law, each problem I had translating code from Python to C++ taught me a new difference between the two languages, and each successful debugging marathon reminded me the value of perseverance while adding a new debugging strategy to my arsenal.
Bill of Materials
|Arduino AT Mega 2560||$14.99||Amazon||Arduino Mega 2560|
|Adafruit 8×8 NeoPixel Matrix||$34.99||Sparkfun||Adafruit NeoPixel Überguide|
|Sunfounder 16×2 LCD Display
+ Arduino to LCD I2C Backpack
|7805 Voltage Regulator||$7.99||Amazon||Sparkfun Datasheet|
Code and Libraries
The project uses an Arduino AT Mega 2560 to control an 8×8 NeoPixel Matrix and LCD Display with I2C backpack and play a game of 6×6 Othello. The LCD displays the score and, when the game is over, who won. The NeoPixel Matrix displays the gameboard, where player one (green) is a human player and player two (blue) is a computer algorithm. Human players can see their potential moves on the serial monitor, accompanied with a letter, and make moves by typing said letter into the serial monitor. The computer algorithm makes moves based on an evaluation function. The LCD I2C uses four pins: gnd connects to ground, VCC connects to 5V, SDA connects to D20, SCL connects to D21. The NeoPixel Matrix is powered by an external power source (a 9 volt battery) with a switch and a 9 volt to 5 volt 7805 voltage regulator. The NeoPixel Matrix has 3 pin holes: gnd connects to the negative end of the battery and ground, 5v connects to the voltage regulator, and DIN connects to D6.
My fourth modification was to increase the quality of the moves made by the computer by having it look at future. The algorithm looks at all of the computer’s valid moves, all of the player’s valid moves should the computer make any given move, and calculates the arct score of the player minus the arct score of the computer. The player will naturally try to maximize its score, thus the computer will pick the best move with the smallest maximum value at the end of the game tree. I also programmed the LCD display to show taunting messages while the computer is calculating its move. Which taunt is displayed depends loosely on how long the game has been going on and how “good” the game board is for each player.
My third modification was to integrate an Adafruit Neopixel Matrix instead of the RGB LED matrix that I had previously been using. The new matrix uses a different hardware and software setup. Instead of using dozens of pins, the Neopixels only require power, ground, and one data pin. The Neopixels are linked up together in a progressive order so instead of addressing the matrix via rows and columns, coordinates in the code must be translated to an index from 0 to 63. The matrix is controlled with the library NeoPixel. An Arduino board does not put out enough current to light all 64 LEDs, so an external power source must be used. I used a 9V battery with a switch and a 5V voltage regulator. After integrating all of these steps, I soldered them to a perf board to reduce the number of wires involved. I also programmed the LCD display to show taunting messages while the computer is calculating its move. Which taunt is displayed depends loosely on how long the game has been going on and how “good” the game board is for each player.
New Circuit Diagram
LCD Circuit Diagram
Button Circuit Diagram
RGB Matrix Circuit Diagram
- Diagram of interaction between RGB Matrix, driver shield, and Arduino. Photo from http://wiki.sunfounder.cc/index.php?title=File:RGBMATRIX1.jpg
- Diagram of RGB matrix driver shield Application Diagram. Photo from http://wiki.sunfounder.cc/images/4/44/DM163_datasheet.pdf
- Diagram of LED matrix from http://wiki.sunfounder.cc/index.php?title=RGB_Dot_Matrix_Explanation