You can play TicTacToe with this LEGO Mindstorms EV3 robot. It uses three motors to drop the balls into the right field. It uses a NXTCam to view the board and then calculates the best move using a MiniMax Algorithm. All future moves are explored an rated according to their winning chances. The work is based on the TicTacToe code of Thomas Kaffka. An IR sensor detects your hand when you drop your ball. The robot is using red balls and the human player uses blue balls. The Java code is available over at Github. The building instructions are available for LEGO Digital Designer. I used the MinuteBot baseplate, which is useful for building static Technic/Mindstorms models.
LDD does not have all the required pars in its database. You will have to replace 22961 with 27940. You will also need to add a worm wheel 27938. In addition you should use a lamp to provide consistent lighting. I used a USB powered LED circular lamp the can be powered through the USB port of the EV3. I only had to take out the lens in the middle so that the camera fits through the hole. A rubber band holds the light in place. To calibrate the robot I added a little arm at the end of the base plate against which the robot arm rotates. The position of the camera can be centered on the board using the wrench and through sliding along the axles.
You can also find information about the robot over at Rebrickable. The inventory there is correct and complete. Except for the base plate of course.
14 thoughts on “TicTacToe Playing LEGO Mindstorms Robot Using Computer Vision”
is it possible that you can come out with a parts list? It would be greatly appreciated.
You can download the LDD file from the link in the text. This will give you a parts list. You can also follow the link to Rebrickable, which lists all the parts.
I am collecting the parts to do this project. I found most of the things. I just wanted to ask whether it is ok to use the Pixy LEGO Camera rather than the NXT Camera you have used.
I have no experience wit the Pixy camera. The camera hardware is probably the lesser issue. Make sure that the software works. The NXT Camera software did all the recognition and simply communicated back the coordinates of the balls. This was very convenient.
Hey! This is a great project! Thank you for sharing it.
I have one question: which program did you use to transfer the code onto the EV3? Did you use Eclipse?
Which program did you use to transfer the code to the robot? Was it Eclipse?
Yes, I used Eclipse. I created a tutorial for the whole process here: http://www.bartneck.de/2017/06/04/tutorial-on-how-to-install-and-run-java-on-lego-mindstorms-ev3-using-eclipse-on-mac-os-x/
Did you use the Home edition or the Education school edition?
It does not make a difference. The hardware is identical.
can lego pixie cam be used instead of nxtcam?
I have not tried it myself, but in principle it could work.
What is that red housing looking part under the main marble dropper?
Those are two parts. Have a look at the building instructions to figure out exactly what parts go where: http://www.bartneck.de/projects/design/lego/ticTacToe/ticTacToe.lxf