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.
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).