FULLTEXT02
FULLTEXT02
June 2020
The authors declare that they are the sole authors of this thesis and that they have not used
any sources other than those listed in the bibliography and identified as references. They further
declare that they have not submitted this thesis at any other institution to obtain a degree.
Contact Information:
Author(s):
Naga Sai Dattu Appaji
E-mail: [email protected]
University advisor:
Dr. Prashant Goswami
Department of Computer Science
Keywords: Artificial intelligence -AI, Behaviour Tree -BT, Finite State machines-
FSM, Reinforcement Learning -RL.
Acknowledgments
I would like to thank my parents, teachers, and friends who were behind me to
complete my bachelor’s degree. I would also thanks to my sister who shares her
value knowledge each time.
I am very much thankful to Professor Prashant Goswami sir for supervising my
thesis project and also helped me to create interest in the AI field with his teaching.
iii
Contents
Abstract i
Acknowledgments iii
1 Introduction 1
1.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.1 Finite State Machines . . . . . . . . . . . . . . . . . . . . . . 2
1.1.2 Behaviour Trees . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1.3 Tree Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.4 Evolutionary Computation . . . . . . . . . . . . . . . . . . . . 4
1.1.5 Reinforcement Learning . . . . . . . . . . . . . . . . . . . . . 5
1.1.6 Supervised Learning . . . . . . . . . . . . . . . . . . . . . . . 5
1.1.7 Unsupervised Learning . . . . . . . . . . . . . . . . . . . . . . 6
1.1.8 Snake Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2 Aim and Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.1 Aim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.2 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 Research Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4 Research Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2 Related Work 8
3 Method 10
3.1 UnInformed Searching Techniques . . . . . . . . . . . . . . . . . . . . 10
3.1.1 Depth-First Search . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.2 Breadth-First Search . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.3 Uniformed Cost Search . . . . . . . . . . . . . . . . . . . . . . 11
3.1.4 Iterative-Deepening Search . . . . . . . . . . . . . . . . . . . . 12
3.1.5 Bidirectional Search . . . . . . . . . . . . . . . . . . . . . . . 12
3.2 Informed Search Techniques . . . . . . . . . . . . . . . . . . . . . . . 13
3.2.1 Best First Search . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2.2 A* Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2.3 Iterative deepening-A* Search . . . . . . . . . . . . . . . . . . 15
3.3 Constrain Satisfaction Problems . . . . . . . . . . . . . . . . . . . . . 16
3.3.1 Brute Force Backtracking . . . . . . . . . . . . . . . . . . . . 16
3.3.2 Limited Discrepancy Search . . . . . . . . . . . . . . . . . . . 16
3.3.3 Intelligent Backtracking . . . . . . . . . . . . . . . . . . . . . 16
3.3.4 Constraint Recording . . . . . . . . . . . . . . . . . . . . . . . 17
v
3.4 Problem Reduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.5 Hill Climbing Search . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.6 Implementation of the Algorithms in Snake Game . . . . . . . . . . . 18
3.6.1 Experimental setup . . . . . . . . . . . . . . . . . . . . . . . . 18
3.6.2 Using Breadth First Search . . . . . . . . . . . . . . . . . . . 18
3.6.3 Using Depth First Search . . . . . . . . . . . . . . . . . . . . 20
3.6.4 Using Best First Search . . . . . . . . . . . . . . . . . . . . . 22
3.6.5 Using A* Search . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.6.6 Using Hamilton Search . . . . . . . . . . . . . . . . . . . . . . 26
3.6.7 Human Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
References 36
A Supplemental Information 38
vi
Chapter 1
Introduction
AI is one of the most important subjects in the field of Computer Science. Nowadays
AI is used to solve complex task with ease. AI consists of many algorithms which
try to mimic the human behaviour [3]. With the AI, the machines behave like a
computer-controlled robot to accomplish tasks commonly associated with intelligent
beings. The term AI is most commonly applied to computer programmed robots
because they posses the smart characteristic of humans, such as the ability to learn,
discover new things, learn from past, generalize. As this is the era of new technologies,
the AI is developed in such a way that has attained more performance level of the
human experts and becomes professional in performing tasks. So the AI is found in
many applications such as voice reorganization, handwriting recognition, self-driving
cars, etc [20] [21].
AI in the real-world and AI in games is quite different. Computer gaming is one
of the AI research area. If anybody has played a video game at any time in their
life, that means they have interacted with AI. In games, AI is the reason behind of
programming an opposition player who calls it as the Non-player characters(NPC).
AI in games provide a good playing experiences. AI in games does not require a
great amount of knowledge, the only thing is to apply specific rules and conditions
to appear the character as an intelligent [27].
Today the software industry provides much research on the gaming field but the
companies are mainly focusing on the graphics but not on the AI of the agents.
There are a lot of games that were successfully completed by Human Agents. So
in order to increase interest among the Human Agents more hard levels should be
provided to play. The design of the levels in the games are designed by using the
performance of the algorithms only. If the performance of the algorithm is good
it is used to implement the hard levels of the game. One of the most important
AI implementations in the games was the searching algorithms because to move
an NPC’s from one place to another place, searching algorithms are required. So
searching helps the AI agents to reach a specific location in the game. Implementing
the agent by using each searching algorithm in a game takes a lot of time and
difficulty. So the best searching algorithm is to be implemented in the game to get
efficient results.
In this thesis, the implementation of some of the searching algorithms is to done
to find their performance in a snake game and compared the performance of these
algorithms against the Human Agent and each other. Breadth-First Search, Depth
First Search, A* Search, Best First Search, Hamiltonian path are some of the selected
searching algorithms. The reason for selecting these algorithms is these are the
1
2 Chapter 1. Introduction
commonly used searching algorithms and are path finding type algorithms.
1.1 Background
The are many methods used in the AI. Here some of the popular methods which are
mainly used to develop AI are
• Finite State Machines (FSM)
• Behaviour Trees (BT)
• Tree Search
• Evolutionary Computation
• Reinforcement Learning (RL)
• Supervised Learning
• Unsupervised Learning
In this game, the states are the patrolling, shooting enemy, dive for cover. The
transition states are the No enemy in sight, Enemy insight, Grenade insight, and
Grenade detonated. If the FSM controller in the patrolling states is lookout for the
enemy if the enemy is the insight the state of the FSMs changes to the Shooting
enemy state where the controller tries to kill the opponent. If any Grenard nearby
distance of the controller, the controller is used to run away from it and look for
cover and health. If there is sufficient health and enemy insight, the FSM controller
activates the Grenade detonated and again lookout for enemies. This is how the
FSMs is worked in the games.
1.1. Background 3
mutation, recombination, and selection for optimization of the solution [6]. Evolu-
tionary computation in games
By using the evolutionary computation the 8 puzzle game or sliding tile game is
easily optimized. In this example, the initial population of the game is p[ 2 0 4 7 6
3 5 1 8]. It first generates different populations based on the misplaced tiles to the
goal state p1 [2 0 4 7 1 3 5 6 8 ] and p2 [7 6 4 5 0 3 1 8 2 ]. For each population,
the fitness function values are calculated. The cross over of the populations was
done. The resulting population is p[0 2 4 7 6 5 3 1 8.] Finally, the mutation of the
population was done by changing the random position of the population p[0 2 4 7 6
5 3 1 8 ]to p[ 0 2 4 1 6 5 3 7 8 ]. For the new population again fitness function
estimates if its maximum value it stops or it again tries for selection of the population
and run the steps.
1.2.2 Objectives
1. To identify some of the different searching algorithms used in the AI in games.
1.3. Research Questions 7
2. To develop the snake game by using the some of the selected searching algo-
rithms.
Electronic Arts is one of the topmost leading companies in developing games. They
also have shown very great success in developing AI in games. Their one of the most
successful application AI is Ms. Pacman. Their most important paradigm in the
development of AI is to optimize the parameters of the controller in the game. Ms.
Pacman is a game has three or more ghosts those are at the closing position of the
door when the game starts the Ms. Pacman needs to collect the points as the time
goes on, the ghosts choose different paths to kill Ms. Pacman. Gallager and Ryan
[8] developed a rule-based controller for the Ms. Pacman game. The current state
of Ms. Pacman is determined by the controller based on the distance between the
ghosts. So Ms. Pacman can retreat or explore in the game. The rule-based controller
consists of a set of rules in which help to determine the new direction of movement for
Ms.Pacman. with the distance threshold and direction probabilities, different weight
parameters are evolved for the controller which helps in the implementation of the
machine learning at a minimum level in the game. This related work helps in the
development of the snake game by applying some of the rules which makes the algo-
rithms more efficient than normal. For example, if the snakes head collides with the
box then the game should stop by using the set of the rules we developed the snake in
such a way that it moves away if any danger occurs in the games. So, this work helps
to apply some of the constraints and rules that should apply to the snake in the game.
Eight puzzles are one of the classical board game, where it consists of eight dis-
tinct movable tiles, plus blank tile. The tiles are numbered from one to eight and
are arranged randomly on the board. The game contains the two types of config-
urations initial and final. The blank tile is used to change the positions of the tile
by swapping it with any tile horizontally or vertically adjacent to it to achieve the
initial configuration to the final configuration of the tiles in the game. Daniel R.
Kunkle [18] developed different Hurestic search functions by using the Manhattan
distance and Manhattan distance plus Reversal Penalty Search between the original
tile position to the goal tile position to achieve the final configuration. The Heuristic
Search function methods find the optimal solutions which take a different amount of
time to do so. So by this solution, AI can produce the minimum number of moves
in the game. This paper provides more information about the Heuristic Search func-
tion which is used in the development of the A* Search algorithm and the Best First
Search algorithm in the snake game.
Mario AI is a benchmark that aims to develop the best controller for playing games.
8
9
The game consists of stages where enemies and destructible blocks are present. The
controller manipulates the Mario agent to reach the goal by dodging the enemies. To
enhance an agent, the controller should operate according to the appropriate situa-
tion. Shunsuke Shinohara, Toshiaki Takano, Haruhiko Takase, Hiroharu Kawanaka
[24] proposed the Mario AI agent by using the combination of the A* algorithm and
Q-Learning in the game. The Q-Learning is used in the game to memorize the target
location to the present location of the Mario. With the location nodes between the
target and the present, the A* algorithm is used and to find the optimal path for the
Mario to reach the goal. So the controller moves the Mario agent according to the
path and becomes effective to reach the goal quickly in the game. This work provides
the way for developing the heuristic function in the game by using the Q-learning
method. The heuristic function is developed by calculating the Manhattan distance
between the fruit coordinates to the adjacent coordinates of the snakes head in the
game.
Kalaha is a simple two-player board game which six holes of rows on each side
and a store on players right side. Each hole on both sides contains a specific number
of stones or marbles or pebbles. The game starts by picking off any of his or her hole
of all stones and dropping by the in the anti-clock by direction. If the dropping of
the stones ends with the hole of his or her store then the player gains another chance
in the game. The game ends with all the completion of his or her stones in all the
holes. The AI agent by using the Minimax algorithm with the alpha-beta pruning
has been developed with the utility function as the knowledge-based which is used
to create a tree and searched the deeper of the tree at the depth of the 12 [12]. Thus
it makes the AI agent which performs better than different algorithms like Minimax
algorithm with utility function as simple and Minimax algorithm with the utility as
the knowledge-based and Minimax with knowledge-based alpha-beta pruning with
utility function as simple.Related work gave us understanding of the Minimax algo-
rithm with different utility functions and their performance results. This work helps
in understanding how the depth of the tree is developed in the game and why the
game trees are more helpful in the two-player games.
Robo code is a game that plays with tank bullets of the player on one side and
opponents on the other side is called as armored tanks. In this game, the player
can collect the points by shooting to the opponent tank and their space. Yehonatan
Sichel[13] developed the controller for the game by using genetic programming. The
controller is used to move the NPCs, to change the direction of the NPCs, to attack
the opponent, and to armor itself. With the Genetic programming, the chromosomes
are the trees in the game and used to represent the attributes of the game and numeric
constants. The genetic programming is used to generate different operations based
on the situations for the controller. So the controller is effective in the game playing.
This study helps in understanding the effectiveness of the controller in the game
and also the implementation of the genetic algorithms in the games. This study
is helpful and motivated us for the further development of the games by using the
optimization algorithms.
Chapter 3
Method
In this chapter, the literature review of the searching algorithms and the implemen-
tation of the searching algorithms in the snake game was performed. From sections
3.1 to 3.5 the theoretical study of the algorithms was presented and in section 3.6
the implementation of the algorithms was done.
Advantages:
1. It uses the minimum time when the target is nearer, i.e. stops the searching
when the goal node reaches.
2. In the worst cases also, there is a chance of reaching the target using many
paths to find goal state.
3. The main reason to use the Depth-First Search because of its space requirement
in a linear manner while searching.
10
3.1. UnInformed Searching Techniques 11
the nodes in the first-level and then expands in the second level and reaches the goal
on its way. So it is called as the level by level traversal technique. In this technique,
all solutions for each node are found out. This guarantees the optimal solution. The
Breadth-First Search uses a queue data structure to store the values. Though there
are cycles in the graph, it uses an array to store the visited vertices in the search
tree. It works in the principle of the FIFO( first in first out). The time and space
complexity of the Breadth-First Search is O(bd + 1) and O(bd + 1) respectively where
b is the branching factor and n is the number of levels.
Advantages
1. The shortest number of steps is required to reach the goal node in the search
tree.
1. It finds the optimal solution by considering the minimum cost for each node.
Disadvantages
1. It finds many ways to get the minimum cost traversal from root to destination
hence time complexity increases.
2. Its space complexity also increases when one path cannot find the optimal
solution.
12 Chapter 3. Method
3. If the path chosen cannot find the optimal solution it compares with the previ-
ous solution and takes a decision which makes space complexity and execution
time more.
Advantages
1. Iterative Deepening Depth First Search uses both a Depth-First Search and
Breadth-First Search to find the minimum cost weighted edge path.
2. It uses a new threshold to find the minimum cost of all nodes generated by
cutting off the previous iterations.
Disadvantages
1. Iterative Deepening Depth First Search recursively performs the previous phases
hence it requires more space.
2. It uses a lot of time to perform iterations before the one to find a solution.
Advantages
1. It reduces the time complexity because it only searches half of the tree.
Disadvantages
2. If the breadth first search on either forward pointer or backward pointer fails
the space complexity increases.
3. Time complexity increases while breadth first search using with greater depths.
Heuristic Search
A Heuristic Search is a technique that is used to find an optimal solution in an
accurate amount of time and evaluates the available information each time while
exploring to other nodes when classical methods do not work. Heuristic Search
algorithms work faster than the uninformed search algorithms.
Heuristic Evaluating Function is defined as the evaluation of the problem desir-
ability usually, represented as the cost between the nodes in the states space search
tree. Heuristic Evaluating Function estimates an optimal cost between a pair of
nodes in the states space tree. It iteratively calculates the distances for each node
cost optimally until the goal state reaches. The key things for the heuristic eval-
uation function are the problem domain, cost metrics, heuristic information in the
problem. Lower bounds are chosen by heuristic functions between two pairs of nodes
than actual cost hence it is referred to as admissibility [16]. This evaluating function
used in playing games to evaluate the next move favorable to win. It evaluates the
probability to win, lose, or draw in the games. The heuristic function used graphs
with cycles, trees. These evaluating functions are in linear form [7].
tree, the heuristic function is used for the determination of the distance between the
nodes. The algorithm uses the two lists which are the open list and the closed list.
The open list maintains the nodes that are to be explored in the state space tree
and the closed list is used to maintain the nodes that are visited in the state-space
search tree. When an open node found the shortest path then it is saved and longer
one discarded. When the closed node found the shortest path then it is moved to
an open node associated with it. The Best First Search uses the best node in all the
unvisited nodes in the state-space search tree. It is the combination of Depth-First
Search and Breadth-First Search algorithms by using the heuristic function for the
cost estimation of the nodes. The Best First Search algorithm uses the priority queue
data structure to maintain the distance between the nodes in the ascending order.
The time complexity of the algorithm is O(bd+1) and space complexity is O(bd) [27].
Advantages
1. It uses both the breadth first search and depth first search techniques.
Disadvantages
1. It is not optimal.
3.2.2 A* Search
A* search algorithm combines both the best features of Uniform Cost Search and
pure Heuristic Search to find an optimal solution and completeness of the path and
optimal efficiency in the state space search tree. A* Search algorithm aims to find
the path from starting node to the goal node by maintaining the tree of nodes and
extending them to reach the goal state until. A* Search algorithm iterates each time
and extends the path from by using the cost estimation, which helps in reaching to
the goal node. The A* Search algorithm uses the formulae for the cost estimation
which selects the minimize path in the state space search tree is f(n) = g(n) + h(n)
where g(n) cost of the path from the source node to n, h(n) is the estimated heuristic
cost from the target node to n, f(n) is the total optimal cost of a path going through
node n [7]. If the heuristic function in the algorithm is admissible, the A* Search
algorithm always chooses the least cost from the start to the goal node. The A*
Search uses the priority queue data structure. At each step, the lower f values are
removed, the adjacent nodes of f(n) and g(n) values are updated accordingly the
iteration stops until the least f(n) value than any node in the queue. The time com-
plexity of the algorithm is O(bd ) and space complexity is O(bd ) [19].
Advantages
1. It finds the best path in minimum time and reduces time complexity.
Disadvantages
1. The space complexity increases when the optimal solution cannot be found in
a Best-First Search.
Example In the 9*9 matrix of a Sudoku game the values are fixed in 1 to 9 numbers
any number cannot be in the same row and the same column then each 3*3 box
occur 1 to 9 numbers which makes a sum 45 on each 3*3 then the player thinks to fit
the values in boxes. firstly the player checks for the auto-generated present numbers
and then for every single number checks at row and column so that player finishes
in time. If one number put wrong in a single block then overall boxes cannot suit.
Advantages
Disadvantages
priorly checks all the uninstantiated variables associated with it are satisfied that is
consistent with previously assigned variables. If not the variable is assigned with its
next value.
Advantages
1. It can find the best solution in an optimal time.
2. It generates all possible solution for a problem such that an optimal solution
can find easily.
Disadvantages
1. It can quit searching when the neighbor state has worse value than the current
state.
2. The process terminates even it can find the best solution.
18 Chapter 3. Method
Working
• Step 1: In this step, the initial coordinates of the snake are pushed on the
queue and set the initial coordinates as visited coordinates.
• Step 2: In this step, Dequeue the coordinates in the queue one by one, and
its all unvisited adjacent coordinates are pushed on the queue and set them as
visited coordinates.
• Step 3 :In this step, the step2 will be repeated continuously until the fruit
coordinates are visited.
• Step 4: In this step, if the fruit coordinates are visited it stop and traces the
path and returns it.
3.6. Implementation of the Algorithms in Snake Game 19
In this, the pseudo-code and working steps of the Breadth-First Search algorithm
was presented.
Figure 3.1: Pseudo code for the BFS algorithm in Snake game
Working
• Step 1: The initial coordinates of the snake are pushed on the stack and set
the initial coordinates as visited coordinates.
• Step 2: The next adjacent unvisited coordinates are pushed on to the stack
recursively and set the coordinates as the visited coordinates.
• Step 3: The step2 will be repeated continuously until the fruit coordinates are
visited.
3.6. Implementation of the Algorithms in Snake Game 21
• Step 4: If the fruit coordinates are visited it stop and traces the path and
returns it.
Figure 3.5: Pseudo code for the DFS algorithm in Snake game
Working
• Step 1: The initial coordinates of the snake are appended and set it as the
current node.
• Step 2: The Manhattan distance between the adjacent coordinates of the cur-
rent node and fruit coordinates are calculated and appended in the open list.
• Step 4: The step2 and step3 repeat continuously until the fruit coordinates
were visited and the path was returned.
Figure 3.10: Pseudo code for the Best first algorithm in Snake game
24 Chapter 3. Method
Working
• Step 1: The initial coordinates of the snake are appended and set it as the
current node.
• Step 2: The neighbors of the current node were appended in the open list.
• Step 3: The Manhattan distance between the adjacent coordinates of the cur-
rent node to the fruit coordinates is calculated and the estimated cost of the
adjacent coordinates to the current node is added which is called the f(n) value.
• Step 4: The least f(n) value is from the open list coordinates are selected and
makes it to the current node and the current node is set in the closed list.
• Step 5: The step 4,step 2, and step 3 repeat continuously until the fruit coor-
dinates were visited and the path was returned.
Figure 3.14: Pseudo code for the A* Search algorithm in Snake game
26 Chapter 3. Method
Working
• Step 1: The initial coordinates of the snake are pushed on the stack and set
the initial coordinates as visited coordinates
• Step 2: The next adjacent unvisited coordinates are pushed on to the stack
recursively and set the coordinates as the visited coordinates.
• Step 3: If any coordinates are visited already once it backtracks and changes
the path.
• Step 4: The step 2, step 3 will be repeated continuously until the fruit coordi-
nates are visited.
• Step 5: If the fruit coordinates are visited it stops and returns the traces path.
Figure 3.18: Pseudo code for the Hamilton Seach algorithm in Snake game
4.1 Experiment 1
The experiment of the algorithms was done by setting the timer of the 120 seconds
and run each algorithm about three times and the height and width of the game
are 300 and 300 respectively. The fruit coordinates of the game were generated ran-
domly. The score of each algorithm was noted down in the below tables.
In the second run the algorithms run about 90 seconds and the fruit coordinates
of the game were generated randomly here also.
In the third run the algorithms run about 60 seconds and the fruit coordinates of
the game were generated randomly here also.
28
4.2. Experiment 2 29
4.2 Experiment 2
In the second experiment, we place the fruit coordinates at some fixed coordinates
and run the algorithms each time. This experiment is used to calculate the time
taken by each algorithm to reach a specified goal. These are specified positions of
the fruit coordinates are placed in the game and run the algorithms. For example we
place the fruit coordinates at coordinates (30,60) and run each algorithm at starting
location at (0,0) coordinates of the snake head.
Table 4.4: Results of the Algorithms at fixed positions of the fruit coordinates
each between the selected algorithm and opposing algorithms and predicted the win-
ner based on the score of the food eaten and experiment 2 between the algorithms.
In Table 4.5 the results for Breadth-First Search Algorithm are Shown below where
the opposing algorithms Depth First Search, Best First Search, A* Search, Human-
Agent, Hamiltonian Search. Firstly the Breadth-First Search and Depth-First Search
was run separately by using the experiment 1 and experiment 2 based on the score
of these experiments the winner between the algorithms are decided. These experi-
ments were done ten times and the win and loss of the algorithms were noted. Here
we have done the experiments ten times the Breadth-First Search algorithm was won
ten out of the ten times against the Depth First Search. The winner was decided
based on the score and time taken to reach specific coordinates of the fruit. Simi-
larly the entire all the results of the algorithms noted by using the win or loss method.
In the Table 4.5 the results for Breadth Search Algorithm are Shown below where
the opposing algorithms are Depth First Search, Best First Search, A* Search, Hu-
man Agent, Hamiltonian Search and the selected algorithm is Depth First Search
algorithm.
In the Table 4.6 the results for Depth Search Algorithm are Shown below where
the opposing algorithms are Breadth First Search, Best First Search, A* Search,
Human Agent, Hamiltonian Search and the selected algorithm is Depth First Search
algorithm.
In the Table 4.7 the results for Best Search Algorithm are Shown bellow where
the opposing algorithms are Breadth First Search, Depth First Search, A* Search,
Human Agent, Hamiltonian Search and the selected algorithm is Best First Search
algorithm.
In the Table 4.8 the results for A* Search Algorithm are Shown bellow where the
opposing algorithms are Breadth First Search, Depth First Search, Best first Search,
Human Agent, Hamiltonian Search and the selected algorithm is A* Search algo-
rithm.
In the Table 4.9 the results for Human Agent are Shown bellow where the oppos-
ing algorithms are Breadth First Search, Depth First Search, A* Search, Best First
Search, Hamiltonian Search and the selected algorithm is Human Agent.
In the Table 4.10 the results for Hamiltonian Search Algorithm are Shown bellow
where the opposing algorithms are Breadth First Search, Depth First Search, A*
Search, Human Agent, Best First Search the selected algorithm is the Hamiltonian
Search algorithm.
Search and Depth-First Search which traverses level by level of the depth. It is also
time consuming to reach the goal node. Bidirectional search uses to find the path in
both directions from source to goal and goal to source. So exploring from both sides
is unnecessary.
The informed searching technique uses an estimation function, which is used to reach
the goal node in the tree. The selection of the estimation function depends on the
problem domain or programmer selection, etc. A* Search, Best First Search, Iterative
A* Search, etc are the different informed searching technique algorithms. Best-First
Search uses the heuristic function for the cost estimation between the adjacent nodes
to the goal node. So this makes the algorithm efficient in searching. A* Search uses
the heuristic function for the cost estimation between the adjacent nodes to the goal
node and its heuristic value. So this makes the algorithm more efficient in searching.
It takes less time to reach a long path. Iterative A* Search uses the threshold value
and cut off the greater estimation value and uses the minimum threshold value in
the list for each step to reach the goal node in the search.
The Problem Reduction is used to solve the hard problem by diving into the
tree and solve these divided problems using the AND-OR graphs. AO* algorithm
estimates the heuristic value for each nodes and arcs, and changes the values heuristic
values and finds the optimal path in solution. There will be a chance of not finding
the optimal path in the solution also.
The main use of the constraint satisfaction problem is to satisfy the given set
of variables. There are different methods used to solve the constraint satisfaction
problems which are brute force backtracking, limited discrepancy search, intelligent
backtracking, constraint recording, etc. The brute force backtracking search assigns
all possible values to explicit constraints and verify that with all the implicit con-
straints. The limited discrepancy does not use the left root search in the tree and
uses the heuristic function and explores the tree. The limited discrepancy is used to
search the entire huge tree also. The intelligent backtracking is used to back jump-
ing, forward checking, restoring values to make more efficient in solving the problems.
Constraint recording is to rediscover the constraint in the time of backtracking.
The hill-climbing is one of the local search technique which continuously searches
until it reaches the optimal solution which is the maximum point but if there are
different optimal solutions it was unable to find out when it reaches one optimal
solution.
distance fruit coordinates and adjacent coordinates and traverses it. By using this
algorithm the number of nodes processed is also less. The time complexity of the
algorithm is low compared to others. The A* Search algorithm also uses cost esti-
mation by calculating the heuristic value between the adjacent coordinates to fruit
coordinates and adjacent coordinates heuristic value. The performance of the algo-
rithm is effective compared to others and take the optimal path to reach the fruit
coordinates.
5.1 Conclusions
The purpose of the thesis is to identify a few searching algorithms used in AI by
literature review and also to conduct the performance analysis of the human agent
and a few algorithms in the snake game. The selected algorithms were compared
with each other as well as against the human agent in terms of performance such as
the score achieved by each algorithm in the game. From the Background work of the
thesis, we concluded that the different AI methods are useful in the development of
AI in games. The Literature review and related works provided enough knowledge
to implement the algorithms in the snake game.We implemented the snake game by
using some of the algorithms. The results of some algorithms and human agent in
the snake game were done by using the experiments one and two. From the results
of the algorithms, we concluded that the performance of the A* Search algorithm
was relatively good when compared with other algorithms in the game. Because A*
Search algorithm uses the Manhattan distance and heuristic cost that makes the AI
take the shortest path and helps the AI to proceed less number of the nodes to reach
the goal. A* Search algorithm also takes less time to execute. While many algorithms
rather than A* Search algorithm travels the longer path that usually proceeds to
takes more nodes and more time to execute in the game. While a Human Agent uses
the random path, So the path to reach the goal is unpredictable in the game. We
concluded that the performance of the algorithms was better than the human agent
in the game.
35
References
36
References 37
[14] Daniel Johnson and Janet Wiles. Computer games with intelligence. In 10th
IEEE International Conference on Fuzzy Systems.(Cat. No. 01CH37297), vol-
ume 3, pages 1355–1358. IEEE, 2001.
[16] Richard E Korf. Real-time heuristic search, volume 42. Elsevier, 1990.
[17] Richard E Korf. Improved limited discrepancy search. pages 286–291, 1996.
[20] Carlos Ramos, Juan Carlos Augusto, and Daniel Shapiro. Ambient intel-
ligence—the next step for artificial intelligence. IEEE Intelligent Systems,
23(2):15–18, 2008.
[21] Tom Schaul, Julian Togelius, and Jürgen Schmidhuber. Measuring intelligence
through games. arXiv preprint arXiv:1109.1314, 2011.
[22] Yoones A Sekhavat. Behavior trees for computer games. International Journal
on Artificial Intelligence Tools, 26(02):1730001, 2017.
[23] Bart Selman and Carla P Gomes. Hill-climbing search. volume 81, page 82.
John Wiley & Sons, Ltd Chichester, 2006.
[25] Sen Song, Kenneth D Miller, and Larry F Abbott. Competitive Hebbian learning
through spike-timing-dependent synaptic plasticity, volume 3. Nature Publishing
Group, 2000.
[26] Csaba Szepesvári. Algorithms for reinforcement learning, volume 4. Morgan &
Claypool Publishers, 2010.
[27] Georgios N Yannakakis and Julian Togelius. A panorama of artificial and compu-
tational intelligence in games. IEEE Transactions on Computational Intelligence
and AI in Games, 7(4):317–335, 2014.
Appendix A
Supplemental Information
38
Faculty of Computing, Blekinge Institute of Technology, 371 79 Karlskrona, Sweden