Press "Enter" to skip to content

Arduino Game Project: Tic Tac Toe Game with a touch screen and an Arduino from Banggood.com

In this Arduino project video we are going to build an Arduino Game, a Tic Tac Toe game with a touchscreen. It is an easy and fun project for all ages. Let’s start!

In this video we are going to build an Arduino Tic Tac Toe game. As you can see, we are using a touch screen and we are playing against the computer. A simple game like Tic Tac Toe is is a great introduction to game programming and Artificial Intelligence. Even though we won’t be using any Artificial Intelligence Algorithms in this game, we will understand why Artificial Intelligence Algorithms are required in more complex games.

——————–
WHERE TO BUY
——————–

Arduino Uno: http://educ8s.tv/part/ArduinoUno

Touch Screen: http://educ8s.tv/part/TouchScreen28

Power Bank: http://educ8s.tv/part/Powerbank

Full disclosure: All of the links above are affiliate links. I get a small percentage of each sale they generate. Thank you for your support!

——————–
LIBRARIES
——————–

Adafruit TFTLCD: https://github.com/adafruit/TFTLCD-Library

Adafruit GFX: https://github.com/adafruit/Adafruit-GFX-Library

Touchscreen: https://github.com/adafruit/Touch-Screen-Library

Let’s take a quick look at the code of the project. We need three libraries in order for the code to compile. You can find links for all the libraries in the description below. As you can see, even a simple game like this, require more than 600 lines of code. The code is complex, so I won’t try to explain it in a 5-minute video. I will show you the implementation of the algorithm for the Arduino moves though.

At first, we play two random corners. Next, in each round, we check if the player can win in the next move. If yes we block that move, most of the times. We don’t block all the moves in order to give the human player a chance to win. Can you find which moves are not blocked? After blocking the move, we play a remaining corner, or a random move. You can study the code, and implement your own unbeatable algorithm easily. As always you can find the code of the project in a link in the description of the video below.
As you can see, even with an Arduino Uno, we can build an unbeatable algorithm for simple games. This project is great, because it is easy to build, and at the same time a great introduction to Artificial intelligence and game programming. I will try to build some more advanced projects with Artificial Intelligence in the future using the more powerful Raspberry Pi so stay tuned! I would love to hear your opinion about this project. Please post your comments below and don’t forget to like the video if you find interesting. Thanks!

——————–
CODE OF THE PROJECT
——————–

Arduino Tic Tac Toe

——————–
Quiz of Knowledge Android Game
——————–

You can download my latest Android Game which is called Quiz of Knowledge here:

http://bit.ly/QuizOfKnowledge

——————–
MORE PROJECTS
——————–
Arduino Datalogger: https://www.youtube.com/watch?v=oei3Y6tOhVI
Arduino Weather Station Project: https://www.youtube.com/watch?v=9jN-3DtS1RI
Arduino Nokia 5110 LCD Display: https://www.youtube.com/watch?v=aDwrMeu4k9Y
Arduino OLED display tutorial: https://www.youtube.com/watch?v=A9EwJ7M7OsI
DIY Arduino: https://www.youtube.com/watch?v=npc3uzEVvc0

——————–
ABOUT EDUC8S.TV
——————–
Educ8s.tv is a Youtube channel and website which is dedicated in developing high quality videos about DIY hardware and software projects. In this channel we develop projects with Arduino, Raspberry Pi, we build robots and simple electronic circuits. Check out our website as well for more information: http://www.educ8s.tv

——————–
SUBSCRIBE ON YOUTUBE
——————–

Never miss a video: https://www.youtube.com/subscription_center?add_user=educ8s

Video transcription:

Dear friends welcome to another Arduino project
video!Today we are going to build an Arduino Game,
a Tic Tac Toe game with a touchscreen.It is an easy and fun project for all ages. Let’s start!Hello guys, I am Nick and welcome to educ8s.tv
a channel that is all about DIY electronicsprojects with Arduino, Raspberry Pi, ESP8266
and other popular boards.In this video we are going to build an Arduino
Tic Tac Toe game.As you can see, we are using a touch screen
and we are playing against the computer.A simple game like Tic Tac Toe is is a great
introduction to game programming and ArtificialIntelligence.Even though we won’t be using any Artificial
Intelligence Algorithms in this game, we willunderstand why Artificial Intelligence Algorithms
are required in more complex games.I really like games and I love developing
games.For the last 5 years I work as a Game Developer
and I have developed many Android Games.My most popular one is named Quiz of Knowledge
and it is a free quiz game which offers thousandsof multiple choice questions in 6 languages.If you enjoy quiz games you can find a link
for it and for my other games in the descriptionof the video below.Developing games for Android is much easier
than developing games for Arduino.But we can build some simple games for Arduino
because it is fun and it will allow us toexplore some more advanced programming topics,
like Artificial intelligence.Let’s now build this project.The parts needed in order to build this project
are the following:• An Arduino Uno
• A 2.8” Touch ScreenThe cost of the project is around 15$.You can find links for the parts we use in
the description of the video.Before attempting to build this project please
watch the video I have prepared about thetouch display by clicking on the card here.It will help you understand the code, and
calibrate the touch screen.After connecting the screen to the Arduino
Uno, we can load the code and we are readyto play.At first, we press the “Start Game” button
and the game starts.The Arduino plays first.We can then play our move simply by touching
the screen.The Arduino then plays its move and so on.The player who succeeds in placing three of
their marks in a horizontal, vertical, ordiagonal row wins the game.When the game is over, the Game Over screen
appears.We can then press the play again button to
start the game again.The Arduino is very good at this game.It will win most of the games, or if you are
a very good player the game will end in adraw.I intentionally designed this algorithm to
make some mistakes in order to give the humanplayer a chance to win.By adding two more lines to the code of the
game, we can make the Arduino impossible tolose the game.But how can a 2$ chip, the Arduino CPU, beat
the human brain?Is the program we developed smarter than the
human brain?To answer this question, let’s look at the
algorithm I have implemented.The computer always plays first.This decision alone, makes the game much easier
for the Arduino to win.The first move is always a corner.The, second move for the Arduino is also a
random corner from the remaining without caringabout the player move at all.From this point on, the Arduino first checks
if the player can win in the next move andblocks that move.If the player can’t win in a single move,
it plays a corner move if it is availableor a random one from the remaining.That’s it, this simple algorithm can beat
the human player every time or at the worstcase scenario the game will result in a draw.This is not the best tic tac toe game algorithm,
but one of the simplest.This algorithm can be implemented in Arduino
easily, because the Tic Tac Toe game is verysimple, and we can easily analyze it and solve
it.If we design the game tree we can discover
some winning strategies and easily implementthem in code or we can let the CPU compute
the game tree in real time and chose the bestmove by itself.Of course, the algorithm we use in this game
is very simple, because the game is very simple.If we try to design a winning algorithm for
chess, even if we use the fastest computerwe can’t compute the game tree in a thousand
years!For games like this, we need another approach,
we need some Artificial Intelligence algorithmsand of course huge processing power.More on this in a future video.Let’s take a quick look at the code of the
project.We need three libraries in order the code
to compile.You can find links for the all the libraries
in the description below.As you can see, even a simple game like this,
require more than 600 lines of code.The code is complex, so I won’t try to explain
it in a 5 minute video.I will show you the implementation of the
algorithm for the Arduino moves though.At first, we play two random corners.Next, in each round we check if the player
can win in the next move.If yes we block that move, most of the times.We don’t block all the moves in order to
give the human player a chance to win.Can you find which moves are not blocked?After blocking the move, we play a remaining
corner, or a random move.You can study the code, and implement your
own unbeatable algorithm easily.As always you can find the code of the project
in a link in the description of the videobelow.As you can see, even with an Arduino Uno,
we can build an unbeatable algorithm for simplegames.This project is great, because it is easy
to build, and at the same time a great introductionto Artificial intelligence and game programming.I will try to build some more advanced projects
with Artificial Intelligence in the futureusing the more powerful Raspberry Pi so stay
tuned!I would love to hear your opinion about this
project.Please post your comments below and don’t
forget to like the video if you find interesting.Thanks!If you are new to the channel, I would love
to have subscribed by clicking on the channelicon here, because every Saturday I post a
new video about DIY electronics and robotprojects.I hope you will join our community.See you next week![ Translating these subtitles?Add your name here! ]

Tags:

Arduino Project,Arduino Game,Arduino Easy Project,Arduino Easy Game,educ8s,educ8s.tv,Arduino touch screen,arduino touch screen tutorial,Arduino touch,Touch game,Arduino,Tic Tac Toe,Arduino tic tac toe,arduino gaming,arduino AI,Artificial Intelligence,adafruit gfx,Arduino Game Project,Arduino Tutorial,Arduino Touch Screen game,Arduino DIY game

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    8 + 11 =