Let's Make Robots!

Tic Tac Toe machine

Play "Tic Tac Toe" using a TV remote
TicTacToe.zip8.3 KB

Now has video of the robot playing a game and I've attached the code used in the video. You can run this on an Arduino even if you don't have the robot as the game is also displayed on the serial monitor for debuging. Only an IR receiver on D4 and a Sony TV remote is required.

This robot is designed to move your pieces as well as it's own. At the end of the game it will clear the board in preparation for a new game. You enter your moves using a TV remote.

This may sound complicated to build but it actually simplifies construction a lot as there are no switches or sensors other than the single IR receiver built into the Micro Magician. Because the robot moves all pieces, it knows which pieces are in what square eliminating the need for switches or sensors. Because you enter your moves with a TV remote there is no need for a control pannel or keypad.

I made this machine from my son's LOZ blocks (Chinese K'nex) as the rules for creating a challenge say that you cannot post a challenge that you cannot solve yourself. As it is made from LOZ blocks construction is fairly simple. It still took about 10 hours to build as I rebuilt parts of the arm several times to try and make it as strong and flexible as possible.

I converted four of my motors to servos by adding the PCB and sensor pot from some broken servos. The pot is just held in place with a lot of hot glue. Since there was no place in the original geartrain for the pot I found a plastic gear that meshed well with the existing gears and used a soldering iron and needle file to make the hole into a slot that fitted the pot. Now the gear press fits neatly on the pot and meshes directly with the output gear.

The "servo" motors are a bit of a problem as there is a lot of play in the clutch mechanism. I will need to add some of my wife's hair bands to apply spring tension and take up the play. Another problem is that the LOZ motors are 3V. If I run the servo controller at too high a voltage then the motors will draw more current than the PCB is rated for. For this reason I am using the Micro Magician and limiting the voltage to 4.8V maximum. Click on the photo below for a hi-res image.

The gripper assembly is very simple. The gripper is just slightly smaller than the balls and relies on friction to hold the balls. Pushing the gripper down over the ball is all that is required to hold it. When it is raised above a certain height, a prod in the center pushes the ball back out as shown in the first video.

During the game, the balls are dropped into the grid. At the end of the game, pins push up from below, raising the balls high enough for the gripper to collect them and return them to their chutes. The robots balls sit in the red chute. The players balls sit in the grey chute. The photo below shows the pins raised.

In the picture below you can see the mechanism for raising and lowering the pins. It is important for the pin assembly to stay level when moving up and down otherwise it can stick. The mechanism pushes up both sides evenly from the center. Click on the photo for a hi-res image. The second video shows how the mechanism works.

The arm is very simple. It is basically a shoulder and an elbow that allow the robot to reach any place in the grid. As this is not a straight forward X-Y mechanism the easiest way for me to program the co-ordinates of each position is to add a manual mode in the code. This will allow me to control the arm manually with the TV remote and record the servo positions into the Micro Magician's EEPROM.

Unfortunately it seems that I have fried the FETs on some of my servo control PCBs. This is because the LOZ motors are designed to run at 3V or less and draw more current that the 6V motors the servo control PCB is intended to drive. As these are a fairly standard little motor it would be quite easy to replace them with 6V motors.

Fortunately I have some FET's rated at over 4A each that I can repair the PCBs with but for now my project is on hold.



A.I. - Artificially illogicial!

One nice thing about this design is that there are no switches or sensors except for the IR receiver. I have included commands in the code so that the grid and player moves are all displayed on the serial monitor. This allowed me to play against the Micro Magician even though the robot was broken using just the Micro Magician and a TV remote.

Normally the A.I. in these games is impossible to beat so it quickly becomes very boring playing against the machine. I've written my A.I. so it plays more like a person so even at the hardest level it is possible to beat the A.I. occasionally. Despite the simplicity of the game I have enjoyed trying to beat the robot at the hardest level.

Unlike some other tic tac toe machines mine does not always let the robot start first. The looser of the previous game starts the next game. My A.I. also makes the first move randomly. Since the random number generator is seeded by the timer and the time taken by the human player to make a move is random, the game play is different every time.

The code now has 4 levels of difficulty.

  1. BEGINNER: the robot just makes random moves. Good for teaching the game to a person who has never played before.
  2. NOVICE: the robot attempts to complete a line and will block you 3 out of 5 times if you have two in a line.
  3. HARD: the robot attempts to complete a line and blocks any attempt you make to complete a line.
  4. EXPERT: Same as hard but the robot uses simple strategy in it's second move to make it harder to beat.


UPDATE: 9-2-2013


Now that DAGU has closed for Chinese New Year I have had time to work on this robot. Unfortunately my motors that I modified to be used as servos had too much loose movement in the clutches to accurately control the robot arm. I have replaced these with standard servos. As the LOZ blocks are not high precision the accuracy of the arm is still not great.

Calibration of the arm is done using the TV remote and can be done during game play without disrupting the game. Calibration consist of selecting a position and then controlling the arm using the TV remote. Once your happy with the new position the robot saves the position in it's EEPROM memory.

As the built in IR receiver is the only sensor used, the wiring is very simple. Just the battery wires and 4x servo cables. I'm thinking of adding an LCD display and a speaker.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Wow. It looks great and will work great too, I'm sure! How did you come up with the idea for the design?

Looking at those LOZ parts makes it look VERY complicated. When will you post a video of this machine playing against you or your son? Last time I saw him in the glorious battle against the roomba fighter. Another thing,have you implemented AI into the programming?

In some ways the LOZ parts did make the build more complicated than if I just used heavy cardboard or balsa wood but it also makes it easier to adjust.

I am currently upgrading my servo control PCB's to handle more current. I should be able to post video tomorrow if all goes well. The AI has 3 levels of difficulty.

  1. Beginner level just makes random moves so it is easy to beat.
  2. Novice level tries to make a line and randomly checks if it needs to block you
  3. Expert level always checks to block your moves while trying to make a line

The beginners level will help my son learn the game but he is pretty smart and will switch to novice level very quickly. Beginner and expert levels will get boring very quickly because either you can always beat the robot or will never beat the robot.