SlideShare a Scribd company logo
1 of 28
Neural Networks in 
Games 
Rawan Al-Samman Noor Alhuda Espil
Why Neural Network ?? 
Simplifying the games code (complex state 
machines ,rules-based systems) 
offer the potential for the game's AI to adapt as the 
game is played 
1 
2
Cool Ways to Use NN in Games 
Threat Assessment (strategy) 
Inputs: types of units and their 
movement 
Output: Aerial threat, a ground threat, 
both an aerial and ground threat, or no 
threat. 
1
Cool Ways to Use NN in Games 
Attack or Flee 
Used for mobs 
Inputs: class, group size, level, range 
Decision making process: that is, 
whether the creature will attack, evade, 
or wander, depending on whether or not 
there's an enemy (a player) in the 
creature's proximity. 
2
Cool Ways to Use NN in Games 
Anticipation 
Computer tell what the player is going to 
do based on past attacks (low kick, low 
kick, high kick, punch) 
Inputs: a few previous attacks 
Outputs: next predicted attack 
Computer can then decide to block, 
move, punch, etc 
3
Cool Ways to Use NN in Games 
Control: 
 robotics applications. 
 handle the flight controls for a space 
ship or an aircraft. 
 racing games. 
4
Pong 
One of the first video games ever made. 
Developed by Atari Company. 
Based on NeuroEvolution of Augmenting 
Topologies (NEAT) which is the artificial evolution 
of neural networks using 
Genetic Algorithm.
Genetic Algorithm 
What is Genetic Algorithm?? 
 adaptive heuristic search algorithm based on the 
evolutionary ideas of natural selection and genetics. 
Why Genetic Algorithm?? 
 do not break easily even if the inputs changed slightly. 
 in searching a large state-space or n-dimensional 
surface, it may offer significant benefits over more 
typical search of optimization techniques.
Genetic Algorithm 
Population 
Ranking 
by fitness 
Mate selection 
“selection probability is 
proportional to fitness” 
Mutation 
“explore 
unknown” 
Crossover 
“exploit 
goodness of 
parent” 
Best 
Solution
NEAT Algorithm 
It combines the usual search for appropriate 
network weights with Complexity of the network 
structure. 
Has advantages: 
1. historical marking. 
2. Specification. 
3. Complexification.
NEAT Algorithm 
Genetic Encoding
NEAT Algorithm 
Topologies innovation:
NEAT Algorithm 
Connection Weight Mutation: 
 A random number is added or subtracted to 
the current weight. 
 the number can be chosen from uniform, 
Gaussian or the distributions.
NEAT Algorithm 
Matching up genomes for different network 
topologies using innovation number:
NEAT Algorithm 
Speciation in Neat: 
in order to let survive useful topological 
innovation it have to be protected. 
NEAT solve this problem with specification: 
• Similar networks are clustered. 
• Competition and mating is restricted with the same 
space. 
• Fitness sharing prevent from a single species taking 
over the hole population.
NEAT Algorithm
NEAT Algorithm 
Complexification: 
NEAT begins with simple networks with no 
hidden nodes differing only in their initial random 
weights. 
 NEAT : 
In other words, NEAT searches for the 
optimal topology by incrementally 
 searches through a minimal number of weight 
dimensions. 
complexifying existing structure 
 reducing the number of generations necessary to find 
a solution 
 ensuring that networks become no more complex 
than necessary.
NEAT Algorithm in Pong 
This game uses NEAT algorithm to control the 
right paddle. 
The NEAT algorithm is given 5 normalized 
inputs: 
• The center of the paddle (Y value). 
• the center of the ball (2 values). 
• the motion vector of the ball (2values). 
The NEAT algorithm gives 1 output that is the 
movement direction and velocity of the paddle. 
6 trial runs were used to test several different 
fitness functions.
Pong “Evolution” 
Trail 1: 
After 50 generations: 
It had not learned to follow the ball. 
It does not anticipate, but reacts to the changes in the 
ball's position 
often misses balls with shallow angles.
Pong “Evolution” 
Trail 2: 
The controller behaves similarly to that of Trial 1. 
After a few generations: 
the paddle would begin to shake at the edges of the 
screen. 
after generation 12, simulations take much longer to 
complete. For these reason, this trial was cut short.
Pong “Evolution” 
Trail 3: 
The controller behaves similarly to the one evolved in 
Trial 1 . 
until generation 15 : 
stops ball tracking, lying in wait until the ball is near 
enough to be hit by the paddle. 
at generation 17: 
becomes entirely unresponsive to the ball, and shakes 
in one of the corners indefinitely.
Pong “Evolution” 
Trail 4: 
The controller is able to predict the ball movement more 
than previous trials. 
After 25 generations: 
 began moving from one edge to the other before the 
ball hit the wall. 
2 hidden nodes. 
58.3% hit rate
Pong “Evolution” 
Trail 5: 
 No new Fitness function, the size of the ball and 
paddles is reduced signicantly. 
 This trial behaved similarly to those before it. 
 it continued to exhibit the behavior, but to much less 
effect than before. 
 It demonstrated more of Trial 3's behavior around 
generation 25. 
 it would still miss the ball more often than not.
Pong “Evolution” 
Trail 6: 
After 25 generations: 
 unable to find the ball. It was able to predict where the 
ball was going to go. 
constant shaking, especially near the edges. 
generation 22: 
had a perfect hit percentage.
Possible Remedies 
To solve the problems appeared in the previous 
trail: 
Warning input used to let the paddle know when the ball 
is imminently close. 
Reducing the size of the ball and paddles would reduce 
the advantage of staying on one of the edges. 
Increasing the score to win would make the 
change in fitness more gradual as the controllers got 
better.
Conclusion 
This study has applied NN with GA for the 
Pong Game. 
Some problems has appeared but as we 
mentioned above it can be solved. 
The main conclusion is that NEAT is a powerful 
method for artificially evolving neural networks. 
NEAT Algorithm can be used in many 
application like games.
Referances Ramirez, L. E. (May 9th, 2014). Using Artificial 
Ne ura l 
Ne two rks to Pla y Po ne . 
FANG, S.-K. W.-W. (2012). A Stud y o n G e ne tic 
Alg o rithm a nd Ne ura l Ne two rk fo r Mini-Gam e s . 
Hsinchu, 300 Taiwan: Department of Computer 
Science National Chiao Tung University . 
Kenneth O. Stanley, R. M. (2002). Evo lving Ne ura l 
Ne two rks thro ug h Aug m e nting To p o lo g ie s . 
the Massachusetts Institute of Technolog. 
David M. Bourg, G. S. (2004, 9 30). Cool Ways to 
Use 
Neural Networks in Games. 
Rawlins, G. J. (2000). Genetic Algorithm. 
Stanley, K. O. ( 2004, 2 8). NeuroEvolution of 
Augmenting Topologies (NEAT).
Thank You

More Related Content

What's hot

NEURAL NETWORKS
NEURAL NETWORKSNEURAL NETWORKS
NEURAL NETWORKS
ESCOM
 
A neuro fuzzy decision support system
A neuro fuzzy decision support systemA neuro fuzzy decision support system
A neuro fuzzy decision support system
R A Akerkar
 
Ppt on artifishail intelligence
Ppt on artifishail intelligencePpt on artifishail intelligence
Ppt on artifishail intelligence
snehal_gongle
 

What's hot (20)

Project presentation
Project presentationProject presentation
Project presentation
 
Ai and neural networks
Ai and neural networksAi and neural networks
Ai and neural networks
 
NEURAL NETWORKS
NEURAL NETWORKSNEURAL NETWORKS
NEURAL NETWORKS
 
A neuro fuzzy decision support system
A neuro fuzzy decision support systemA neuro fuzzy decision support system
A neuro fuzzy decision support system
 
Neural
NeuralNeural
Neural
 
Artificial Neural Network Abstract
Artificial Neural Network AbstractArtificial Neural Network Abstract
Artificial Neural Network Abstract
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
 
Reinforcement Learning: Chapter 15 Neuroscience
Reinforcement Learning: Chapter 15 NeuroscienceReinforcement Learning: Chapter 15 Neuroscience
Reinforcement Learning: Chapter 15 Neuroscience
 
Artificial Neural Network seminar presentation using ppt.
Artificial Neural Network seminar presentation using ppt.Artificial Neural Network seminar presentation using ppt.
Artificial Neural Network seminar presentation using ppt.
 
Deep Learning Survey
Deep Learning SurveyDeep Learning Survey
Deep Learning Survey
 
Introduction to Spiking Neural Networks: From a Computational Neuroscience pe...
Introduction to Spiking Neural Networks: From a Computational Neuroscience pe...Introduction to Spiking Neural Networks: From a Computational Neuroscience pe...
Introduction to Spiking Neural Networks: From a Computational Neuroscience pe...
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
 
deona
deonadeona
deona
 
Introduction Of Artificial neural network
Introduction Of Artificial neural networkIntroduction Of Artificial neural network
Introduction Of Artificial neural network
 
Artificial Neural Networks: Pointers
Artificial Neural Networks: PointersArtificial Neural Networks: Pointers
Artificial Neural Networks: Pointers
 
Introduction to Spiking Neural Networks: From a Computational Neuroscience pe...
Introduction to Spiking Neural Networks: From a Computational Neuroscience pe...Introduction to Spiking Neural Networks: From a Computational Neuroscience pe...
Introduction to Spiking Neural Networks: From a Computational Neuroscience pe...
 
Artificial Neural Network in Medical Diagnosis
Artificial Neural Network in Medical DiagnosisArtificial Neural Network in Medical Diagnosis
Artificial Neural Network in Medical Diagnosis
 
Artificial Neural Network and its Applications
Artificial Neural Network and its ApplicationsArtificial Neural Network and its Applications
Artificial Neural Network and its Applications
 
Ppt on artifishail intelligence
Ppt on artifishail intelligencePpt on artifishail intelligence
Ppt on artifishail intelligence
 
Artificial Neural Network Topology
Artificial Neural Network TopologyArtificial Neural Network Topology
Artificial Neural Network Topology
 

Viewers also liked

Game Informed Learning - Newcastle Keynote 2008
Game Informed Learning - Newcastle Keynote 2008Game Informed Learning - Newcastle Keynote 2008
Game Informed Learning - Newcastle Keynote 2008
MVMLTS
 
Artificial intelligence In Modern-Games.
Artificial intelligence In Modern-Games. Artificial intelligence In Modern-Games.
Artificial intelligence In Modern-Games.
Nitish Kavishetti
 
Google hummingbird algorithm ppt
Google hummingbird algorithm pptGoogle hummingbird algorithm ppt
Google hummingbird algorithm ppt
Priyodarshini Dhar
 

Viewers also liked (9)

PROCEDURAL CONTENT GENERATION FOR MAZE- GAME
PROCEDURAL CONTENT GENERATION FOR MAZE- GAMEPROCEDURAL CONTENT GENERATION FOR MAZE- GAME
PROCEDURAL CONTENT GENERATION FOR MAZE- GAME
 
A Serious Game For Better Understanding of Behaviour Differences Between Chil...
A Serious Game For Better Understanding of Behaviour Differences Between Chil...A Serious Game For Better Understanding of Behaviour Differences Between Chil...
A Serious Game For Better Understanding of Behaviour Differences Between Chil...
 
Game Informed Learning - Newcastle Keynote 2008
Game Informed Learning - Newcastle Keynote 2008Game Informed Learning - Newcastle Keynote 2008
Game Informed Learning - Newcastle Keynote 2008
 
Maze solver robot presentation
Maze solver robot presentationMaze solver robot presentation
Maze solver robot presentation
 
Artificial Intelligence in games
Artificial Intelligence in gamesArtificial Intelligence in games
Artificial Intelligence in games
 
Artificial intelligence In Modern-Games.
Artificial intelligence In Modern-Games. Artificial intelligence In Modern-Games.
Artificial intelligence In Modern-Games.
 
Google hummingbird algorithm ppt
Google hummingbird algorithm pptGoogle hummingbird algorithm ppt
Google hummingbird algorithm ppt
 
Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligence
 
Data Science - Part XIV - Genetic Algorithms
Data Science - Part XIV - Genetic AlgorithmsData Science - Part XIV - Genetic Algorithms
Data Science - Part XIV - Genetic Algorithms
 

Similar to Ai in games

Chess end games using Neural Networks
Chess end games using Neural NetworksChess end games using Neural Networks
Chess end games using Neural Networks
piuprabhu
 
Learning to Play Complex Games
Learning to Play Complex GamesLearning to Play Complex Games
Learning to Play Complex Games
butest
 
lecture notes about decision tree. Its a very good
lecture notes about decision tree. Its a very goodlecture notes about decision tree. Its a very good
lecture notes about decision tree. Its a very good
ranjankumarbehera14
 
Evolving Neural Network Agents In The Nero Video
Evolving Neural Network Agents In The Nero VideoEvolving Neural Network Agents In The Nero Video
Evolving Neural Network Agents In The Nero Video
Stelios Petrakis
 

Similar to Ai in games (20)

ThesisDefense_rev
ThesisDefense_revThesisDefense_rev
ThesisDefense_rev
 
How DeepMind Mastered The Game Of Go
How DeepMind Mastered The Game Of GoHow DeepMind Mastered The Game Of Go
How DeepMind Mastered The Game Of Go
 
Optimizing search-space-of-othello-using-hybrid-approach
Optimizing search-space-of-othello-using-hybrid-approachOptimizing search-space-of-othello-using-hybrid-approach
Optimizing search-space-of-othello-using-hybrid-approach
 
AlphaZero and beyond: Polygames
AlphaZero and beyond: PolygamesAlphaZero and beyond: Polygames
AlphaZero and beyond: Polygames
 
Artificial Intelligence Applications in Petroleum Engineering - Part I
Artificial Intelligence Applications in Petroleum Engineering - Part IArtificial Intelligence Applications in Petroleum Engineering - Part I
Artificial Intelligence Applications in Petroleum Engineering - Part I
 
Understanding AlphaGo
Understanding AlphaGoUnderstanding AlphaGo
Understanding AlphaGo
 
Chess end games using Neural Networks
Chess end games using Neural NetworksChess end games using Neural Networks
Chess end games using Neural Networks
 
Darwin’s Magic: Evolutionary Computation in Nanoscience, Bioinformatics and S...
Darwin’s Magic: Evolutionary Computation in Nanoscience, Bioinformatics and S...Darwin’s Magic: Evolutionary Computation in Nanoscience, Bioinformatics and S...
Darwin’s Magic: Evolutionary Computation in Nanoscience, Bioinformatics and S...
 
Plant recognition system
Plant recognition systemPlant recognition system
Plant recognition system
 
Deep Learning in Recommender Systems - RecSys Summer School 2017
Deep Learning in Recommender Systems - RecSys Summer School 2017Deep Learning in Recommender Systems - RecSys Summer School 2017
Deep Learning in Recommender Systems - RecSys Summer School 2017
 
Ai final module (1)
Ai final module (1)Ai final module (1)
Ai final module (1)
 
Critique Of The Lode Runner
Critique Of The Lode RunnerCritique Of The Lode Runner
Critique Of The Lode Runner
 
Learning to Play Complex Games
Learning to Play Complex GamesLearning to Play Complex Games
Learning to Play Complex Games
 
Artificial neural networks introduction
Artificial neural networks introductionArtificial neural networks introduction
Artificial neural networks introduction
 
lecture notes about decision tree. Its a very good
lecture notes about decision tree. Its a very goodlecture notes about decision tree. Its a very good
lecture notes about decision tree. Its a very good
 
02 - Emergence and Progression
02 - Emergence and Progression02 - Emergence and Progression
02 - Emergence and Progression
 
04 1 evolution
04 1 evolution04 1 evolution
04 1 evolution
 
Evolving Neural Network Agents In The Nero Video
Evolving Neural Network Agents In The Nero VideoEvolving Neural Network Agents In The Nero Video
Evolving Neural Network Agents In The Nero Video
 
2. NEURAL NETWORKS USING GENETIC ALGORITHMS.pptx
2. NEURAL NETWORKS USING GENETIC ALGORITHMS.pptx2. NEURAL NETWORKS USING GENETIC ALGORITHMS.pptx
2. NEURAL NETWORKS USING GENETIC ALGORITHMS.pptx
 
An analysis of minimax search and endgame databases in evolving awale game pl...
An analysis of minimax search and endgame databases in evolving awale game pl...An analysis of minimax search and endgame databases in evolving awale game pl...
An analysis of minimax search and endgame databases in evolving awale game pl...
 

Ai in games

  • 1. Neural Networks in Games Rawan Al-Samman Noor Alhuda Espil
  • 2. Why Neural Network ?? Simplifying the games code (complex state machines ,rules-based systems) offer the potential for the game's AI to adapt as the game is played 1 2
  • 3. Cool Ways to Use NN in Games Threat Assessment (strategy) Inputs: types of units and their movement Output: Aerial threat, a ground threat, both an aerial and ground threat, or no threat. 1
  • 4. Cool Ways to Use NN in Games Attack or Flee Used for mobs Inputs: class, group size, level, range Decision making process: that is, whether the creature will attack, evade, or wander, depending on whether or not there's an enemy (a player) in the creature's proximity. 2
  • 5. Cool Ways to Use NN in Games Anticipation Computer tell what the player is going to do based on past attacks (low kick, low kick, high kick, punch) Inputs: a few previous attacks Outputs: next predicted attack Computer can then decide to block, move, punch, etc 3
  • 6. Cool Ways to Use NN in Games Control:  robotics applications.  handle the flight controls for a space ship or an aircraft.  racing games. 4
  • 7. Pong One of the first video games ever made. Developed by Atari Company. Based on NeuroEvolution of Augmenting Topologies (NEAT) which is the artificial evolution of neural networks using Genetic Algorithm.
  • 8. Genetic Algorithm What is Genetic Algorithm??  adaptive heuristic search algorithm based on the evolutionary ideas of natural selection and genetics. Why Genetic Algorithm??  do not break easily even if the inputs changed slightly.  in searching a large state-space or n-dimensional surface, it may offer significant benefits over more typical search of optimization techniques.
  • 9. Genetic Algorithm Population Ranking by fitness Mate selection “selection probability is proportional to fitness” Mutation “explore unknown” Crossover “exploit goodness of parent” Best Solution
  • 10. NEAT Algorithm It combines the usual search for appropriate network weights with Complexity of the network structure. Has advantages: 1. historical marking. 2. Specification. 3. Complexification.
  • 13. NEAT Algorithm Connection Weight Mutation:  A random number is added or subtracted to the current weight.  the number can be chosen from uniform, Gaussian or the distributions.
  • 14. NEAT Algorithm Matching up genomes for different network topologies using innovation number:
  • 15. NEAT Algorithm Speciation in Neat: in order to let survive useful topological innovation it have to be protected. NEAT solve this problem with specification: • Similar networks are clustered. • Competition and mating is restricted with the same space. • Fitness sharing prevent from a single species taking over the hole population.
  • 17. NEAT Algorithm Complexification: NEAT begins with simple networks with no hidden nodes differing only in their initial random weights.  NEAT : In other words, NEAT searches for the optimal topology by incrementally  searches through a minimal number of weight dimensions. complexifying existing structure  reducing the number of generations necessary to find a solution  ensuring that networks become no more complex than necessary.
  • 18. NEAT Algorithm in Pong This game uses NEAT algorithm to control the right paddle. The NEAT algorithm is given 5 normalized inputs: • The center of the paddle (Y value). • the center of the ball (2 values). • the motion vector of the ball (2values). The NEAT algorithm gives 1 output that is the movement direction and velocity of the paddle. 6 trial runs were used to test several different fitness functions.
  • 19. Pong “Evolution” Trail 1: After 50 generations: It had not learned to follow the ball. It does not anticipate, but reacts to the changes in the ball's position often misses balls with shallow angles.
  • 20. Pong “Evolution” Trail 2: The controller behaves similarly to that of Trial 1. After a few generations: the paddle would begin to shake at the edges of the screen. after generation 12, simulations take much longer to complete. For these reason, this trial was cut short.
  • 21. Pong “Evolution” Trail 3: The controller behaves similarly to the one evolved in Trial 1 . until generation 15 : stops ball tracking, lying in wait until the ball is near enough to be hit by the paddle. at generation 17: becomes entirely unresponsive to the ball, and shakes in one of the corners indefinitely.
  • 22. Pong “Evolution” Trail 4: The controller is able to predict the ball movement more than previous trials. After 25 generations:  began moving from one edge to the other before the ball hit the wall. 2 hidden nodes. 58.3% hit rate
  • 23. Pong “Evolution” Trail 5:  No new Fitness function, the size of the ball and paddles is reduced signicantly.  This trial behaved similarly to those before it.  it continued to exhibit the behavior, but to much less effect than before.  It demonstrated more of Trial 3's behavior around generation 25.  it would still miss the ball more often than not.
  • 24. Pong “Evolution” Trail 6: After 25 generations:  unable to find the ball. It was able to predict where the ball was going to go. constant shaking, especially near the edges. generation 22: had a perfect hit percentage.
  • 25. Possible Remedies To solve the problems appeared in the previous trail: Warning input used to let the paddle know when the ball is imminently close. Reducing the size of the ball and paddles would reduce the advantage of staying on one of the edges. Increasing the score to win would make the change in fitness more gradual as the controllers got better.
  • 26. Conclusion This study has applied NN with GA for the Pong Game. Some problems has appeared but as we mentioned above it can be solved. The main conclusion is that NEAT is a powerful method for artificially evolving neural networks. NEAT Algorithm can be used in many application like games.
  • 27. Referances Ramirez, L. E. (May 9th, 2014). Using Artificial Ne ura l Ne two rks to Pla y Po ne . FANG, S.-K. W.-W. (2012). A Stud y o n G e ne tic Alg o rithm a nd Ne ura l Ne two rk fo r Mini-Gam e s . Hsinchu, 300 Taiwan: Department of Computer Science National Chiao Tung University . Kenneth O. Stanley, R. M. (2002). Evo lving Ne ura l Ne two rks thro ug h Aug m e nting To p o lo g ie s . the Massachusetts Institute of Technolog. David M. Bourg, G. S. (2004, 9 30). Cool Ways to Use Neural Networks in Games. Rawlins, G. J. (2000). Genetic Algorithm. Stanley, K. O. ( 2004, 2 8). NeuroEvolution of Augmenting Topologies (NEAT).