Professional Documents
Culture Documents
Report Sample4
Report Sample4
Artificial Intelligence
CU6051NA
Coursework 2
1 Introduction................................................................................................ 1
1.1 Explanation of the topic/AI concepts used .......................................... 1
1.2 Explanation of the chosen problem domain ........................................ 2
1.3 Reason for selection ........................................................................... 2
2 Mind Map................................................................................................... 3
2.1 Description and design of mind map ................................................... 3
2.1.1 Mind Map 1 .................................................................................. 3
2.1.2 Mind Map 2 .................................................................................. 4
2.1.3 Mind Map 3 .................................................................................. 5
2.1.4 Mind Map 4 .................................................................................. 6
2.1.5 Mind Map 5 .................................................................................. 7
3 Background ............................................................................................... 8
3.1 Research work done on the chosen topic ........................................... 8
3.1.1 Books ........................................................................................... 8
3.1.2 Journals........................................................................................ 8
3.2 Review and analysis of existing work in the problem domain ............. 9
3.2.1 Table Tennis 3D Ping Pong ......................................................... 9
3.2.2 Pong 10 ........................................................................................ 9
3.2.3 Pong RT ..................................................................................... 10
4 Solution ................................................................................................... 11
4.1 Explanation of the solution ................................................................ 11
4.2 AI Algorithm used ............................................................................. 11
4.2.1 Minimax Algorithm ...................................................................... 11
4.3 Pseudocode of the solution............................................................... 12
4.4 Flowchart diagram of the solution ..................................................... 14
4.5 Explanation of the development process .......................................... 14
4.6 Achieved results ............................................................................... 16
5 Conclusion............................................................................................... 19
6 References .............................................................................................. 20
Table of Figures
1 Introduction
1.1 Explanation of the topic/AI concepts used
Artificial Intelligence(AI) is a branch of a computer science that deals with
listening, reasoning, analysing, processing and understanding natural language
as human being. In today’s world, the presence of AI has contributed to several
sectors such as educational sector, household sector, organizational sector,
scientific sector, gaming sector and many more. Talking more specific about
the gaming sector, AI has made great contribution such as making games
realistic, smarter and enhancing the overall gaming experience, etc.
As gaming is becoming popular all over the world among all age groups and
people spend many of their times playing games, I have chosen Adversarial
search and games as the AI concept for the gaming project named Unlimited
Ping Pong. This concept is also known as Minimax search which is popularly
recognized for its helpfulness in calculating the best move in two player games
such as Pong where all the needed information is accessible. It possesses of
navigating through a tree which captures all the possible moves in the game.
Both of the players each move is stated in terms of gain or loss for one of the
players. In zero-sum games, it is used to make decisions which defines one
player’s gain is the other player’s loss. According to von Neumann’s minimax
theorem, “Zero-sum games consists of a set of strategies which leads to both
players gaining the same value and that seeing as this is the best possible value
one can expect to gain, one should employ this set of strategies (Kulenovic,
2008).”
Nikit Gurung 1
CU6051NA Artificial Intelligence
In order to play this game, a user must just click the Unlimited Ping Pong
Icon and can simply play the game and compete against the CPU until the user
closes the program.
Nikit Gurung 2
CU6051NA Artificial Intelligence
2 Mind Map
2.1 Description and design of mind map
2.1.1 Mind Map 1
This is the first or the initial map mind for the gaming application name
Unlimited Ping Pong. As this is a gaming project, Adversarial search and
games is chosen as the AI concept. Moreover, in this mind map 1, we have
introduced the general features such as its game type, guideline, final
outcomes, display, etc.
Nikit Gurung 3
CU6051NA Artificial Intelligence
In the mind map 2, we have given details of some of the general features such
as the game type will be an arcade game in 2D and will have multiplayer
feature. Similarly, guideline for user manual is provided in many points such as
run the program, use paddle to hit the ball, earn points when the CPU misses
the ball and exit the program whenever you want.
Nikit Gurung 4
CU6051NA Artificial Intelligence
In the mind map 3, the final outcomes of the Unlimited Ping Pong is
discussed. i.e. If a user has more points than the CPU, it is declared as a
win. Likewise, if both the user and CPU have same points then, it is a draw
and in the end if the CPU has more points than the user, it is declared as a
loss.
Nikit Gurung 5
CU6051NA Artificial Intelligence
In the mind map 4, the detail introduction of the Unlimited Ping Pong game
is given. This game is an arcade multiplayer game which was released in
1972, consists of two paddles and a ball and points are earned when one
of the user misses to hit the ball with their paddle.
Nikit Gurung 6
CU6051NA Artificial Intelligence
The mind map 5 is the complete description of this gaming project. Here,
the rules are discussed about this game. i.e. A user must use a paddle to
hit the ball, points are earned when a player misses to hit the ball with the
help of the paddle.
Nikit Gurung 7
CU6051NA Artificial Intelligence
3 Background
3.1 Research work done on the chosen topic
For this gaming AI project, I researched many books, websites, watched
different Youtube tutorials to learn how to do coding in the place where I
was facing complications and learned the importance of AI in gaming.
3.1.1 Books
Pac-man was the first game which introduced the use of AI in the gaming
sector. In this game, the Pac-Man definitely has enemy characters that
seems to plot against you, moved around the level just as the user and
made life harder. This game was totally based on a simple AI technique.
Until the mid-1990s, game AI didn’t have a drastic change. AI games
started to sell successfully from the mid-1990s. Although Virtual Theatre AI
system was mostly anticipated system, it only allowed characters to walk
forward and backward in the game which was barely a success (Millington
& Funge, 2009).
This book helps to provide the proper guidance to invent a proper computer
game with the help of python programming language. It provides
knowledge about the interactive shell, writing programs in Python’s file
editor, a program to guess the number. i.e. Whether the selected number
of the user is too high or too low (Sweigart, 2017).
3.1.2 Journals
This journal helps to introduce the variety of initial concepts to be used in
artificial intelligence for games in order to identify what tools or items are
present for facing our AI problems, gives an idea about how they work
jointly and their implementation style and the programming language of
their choice (Sizer, 2018).
Strategy plays a vital part in the field of gaming. Before starting a game,
each player or a team makes a strategy in order to win. So to develop the
feature of strategy in the game, the python uses different algorithms such
as Minimax Algorithm, Negamax Algorithm, etc. Talking in more detail
about the minimax algorithm, this strategy is deployed in those games
which consists of two players. In such algorithm, each player makes an
Nikit Gurung 8
CU6051NA Artificial Intelligence
effort to predict the next move of the opponent and tries to minimize that
function (Bartel, 2017).
3.2.2 Pong 10
Figure 7: Pong 10
Pong 10 is originated from the mythical game of 70’s which is a free multiplayer
game. This is a 2D game. The players should move the paddle to hit the ball
and secure points. In order to move the paddle, the player should use E button
for up and C button for down. The player who secures 9 points first wins the
game.
Nikit Gurung 9
CU6051NA Artificial Intelligence
3.2.3 Pong RT
Figure 8: Pong RT
Nikit Gurung 10
CU6051NA Artificial Intelligence
4 Solution
4.1 Explanation of the solution
This gaming application named “Unlimited Ping Pong” is a two dimensional
arcade game which consists of two players where both of them control an
in-game paddle by moving it vertically up or down side of the screen with
the help of up and down button. In this game, the user must hit the ball back
and forth with the help of the paddle. A player wins the game when he/she
scores more than the CPU’s score. Each point is earned when the player
or the CPU is unable to return the ball to the other.
This gaming application is simply developed for the gamers, the people
who want to spend their leisure time and people who are standing in a
queue. This game will help the people to reduce their boredom, exercise
their brain and play against a competitive system player or the CPU. As this
game is competitive, the user might find it entertaining as well as
challenging.
Nikit Gurung 11
CU6051NA Artificial Intelligence
class paddle
def update()
if key == up
direction = -1
direction = 1
class Ball
def update()
player_score +1
computer_score +1
def detect_collision()
reflect ball
def reset()
set (x,y)
set speed
class computer
def update()
Nikit Gurung 12
CU6051NA Artificial Intelligence
move down
move up
def run()
player_score (x,y)
computer_score (x,y)
player_paddle (x,y)
computer_score (x,y)
ball.reset (x,y)
until exit
paddle.update()
ball.detect_collision()
computer.update()
ball.update()
ball.reset()
run()
Nikit Gurung 13
CU6051NA Artificial Intelligence
Nikit Gurung 14
CU6051NA Artificial Intelligence
In this gaming project, Pycharm has been used as the platform to run my
codes written in python language. The reason behind choosing Pycharm
is that it provides code analysis, excellent code hinting, code navigation,
refactoring, an integrated unit tester, supports popular web technologies
and is cross-platform (Horn, 2019).
Nikit Gurung 15
CU6051NA Artificial Intelligence
This is the Graphical User Interface (GUI) or the main interface of this game
named Unlimited Ping Pong. As shown in the figure above, in the middle there
is the score board of both the player and the CPU. The left paddle is owned by
the player and the right paddle is owned by the CPU. The white ball in this game
moves from left side to right side and vice versa.
Nikit Gurung 16
CU6051NA Artificial Intelligence
In this figure, the change in the scoreboard is shown when the player earns the
point. A point is earned by the player when CPU misses to hit the ball with the
paddle.
Nikit Gurung 17
CU6051NA Artificial Intelligence
In this figure, the change in the scoreboard is shown when the CPU earns the
point. A point is earned by the CPU when the player misses to hit the ball with
the paddle.
Nikit Gurung 18
CU6051NA Artificial Intelligence
5 Conclusion
With the completion of this gaming project, I learned many new things such
as the AI concept of Adversarial search and games, importance of artificial
intelligence in the gaming world and creation of mind maps before
executing the project. Apart from these, I also read books, journals related
to AI and python programming language for the research work. Not only
this, I also made review and analysis of similar existing work. Regarding
the solution section, I explained the solution, gave brief description about
minimax algorithm, wrote pseudocode of the solution, made flowchart
diagram of the solution, gave detail explanation of the development process
and displayed the successful running of the “Unlimited Ping Pong” game
with the help of screenshots.
With the help of this coursework, I am optimistic with the fact that this will
surely help me to develop my coding skills related to python programming
language even more and gives motivation to gain more knowledge about
different AI concepts. Hence, this coursework will surely help me in my
future IT career.
Nikit Gurung 19
CU6051NA Artificial Intelligence
6 References
Bartel, G., 2017. Playing Strategy Games With The Minimax Algorithm.
[Online]
Available at: https://medium.freecodecamp.org/playing-strategy-games-with-
minimax-4ecb83b39b4b
[Accessed 25th January 2019].
Nikit Gurung 20
CU6051NA Artificial Intelligence
Sizer, B., 2018. The Total Beginner's Guide to Game AI. [Online]
Available at: https://www.gamedev.net/articles/programming/artificial-
intelligence/the-total-beginners-guide-to-game-ai-r4942/
[Accessed 24th January 2019].
Sweigart, A., 2017. In: L. Chun, ed. INVENT YOUR OWN COMPUTER
GAMES WITH PYTHON. San Francisco: William Pollock, pp. 1-21.
Nikit Gurung 21