Tic-Tac-Toe Playing Robot With Picaxe 08M
This is my Tic-Tac-Toe playing robot controlled by a Picaxe 08M . It plays a perfect game as long as it goes first and it always goes first . It is a work in progress so it doesn't look very good right now . It uses plastic beads as the machines play pieces . It will use steel ball bearings as the human play pieces, but I don't have any right now so I'm using some fishing sinkers .
The algorithm for playing came from an article in the December 1971 issue of Radio Electronics called Tic-Tac-Tronix by Don Lancaster . The flow chart at the top of the article is what I implemented in Picaxe code using lookup tables . It plays by always going first and playing the same corner square . It always wins or ties .
The robot consists of servos that rotate the arm and position a slide that holds the board . The third servo operates the gripper . The servos are old and slow which may be a good thing . The servo that moves the sled with the board is a Royal Titan from the mid 80s which was the original cheap servo at $19.95 . It still had the EK Logictrol connector on it .
The play board consist of 9 switches made from brass stock in a V shaped trough . The humans conductive play piece , in this case a ball bearing or fishing sinker , bridges the gap and closes the connection . The Picaxe reads the switches state by using a CMOS 4017 decade counter . Only one output of the 4017 is high at a time . The Picaxe pulses the clock line 9 times to cycle through the switches and a tenth time to set it back to the start position with output 0 high . Each output is run through a 1n914 diode so the high output and low outputs of the 4017 aren't connected through the common of the switches . If the switch is made and its output from the 4017 is high the high shows up on the pin3 input of the Picaxe . Pin3 has a 10K pulldown resistor . I chose this method because I needed to read 9 switches and only had 2 I/O pins left . It may not be the best way but it seems to work .
The program uses 253 of the 08m's 256 bytes and all the I/O pins so the operation is pretty basic . To signal the game is over , instead of a win light the gripper is closed in the home position instead of being left open . You have to look at the board to decide if you lost or tied . I see the 08m is being replaced by the 08m2 with a lot more memory and another I/O pin so I may continue the project with an 08m2 . It should be possible to let either player go first and have a lot more features .
I started building this because I wanted to see if it was possible to do with an 08m . After finding the Tic-Tac-Tronix article , I thought it might be possible , but I still had to do several rewrites to get it to fit . If you want to see the game logic without the robot , I have included a serial version of the program that runs in the simulator . I have also include the schematic that I drew after I built so I hope it's right .
Here is a link to the 1971 Radio Electronics article . It's very interesting . It's about halfway down the page .
Here is a link to the Youtube video . It used to be embedded in the page but it disappeared and I can't get the embed code to work .