AI in Space

AI in Space
Group 3
Raquel Cohen
Yesenia De La Cruz
John Gratton
What is AI In Space?



AI In Space is a collection of 3 different types of Artificial
Intelligence each demonstrated in a unique mini game.
Each mini game is going to be a level of the overall game
and in each level the user will be able to attack, race, or
shoot at very unique enemy AI's.
Each group member was in charge of designing a level
just for the AI that they have selected to implement.
7/31/12
The AI’s in the Game
• Level 1 – Neat
• Level 2 – Neural Networks and Genetic Algorithm.
• Level 3 – Neat Real Time
Story Line
• Our heroic alien, Lerioc, has been out cast from his planet
and must now find his way back.
• He needs to journey through three different
environments:
• Red Arena – Level 1
• Mazy Way – Level 2
• Home – Level 3
Tools: Blender
Tools: SpaceScape
Tools: Unity3D
Level One




A 1 on 1 tournament style mini game that has you face off
with the best enemy on this unknown planet. This enemy
has been training its whole life just to fight, so watch out
as this enemy can move fast and fire even faster.
Placed in an empty arena figure out a way to quickly take
out the enemy before it takes you out.
Use plasma fire to shoot down your enemy and collect
health packs around the arena to give you a second
chance.
Be careful it only takes 1 shot to take you down but with
the help of a health pack you can live a little longer.
Level One How To





To move the red player on the screen use the arrow keys:
the left and right arrows are used to rotate and the up
arrow is used to move forward.
Use the space-bar on the keyboard to fire your plasma.
Note you can only fire plasma after it has been fully
recharged.
Pick up health packs that are around the arena to get a
boost of health.
Stay out of the plasma glow around the enemy to avoid
getting hit.
Level One AI




The artificial intelligence that is used for level 1 is: coevolution, using NEAT, and the dominance tournament.
Co-evolution trains two neural networks at the same
time. Each network will be able to learn from one
another.
NEAT makes the networks more advance and allows the
neural networks to become more complex.
Dominance tournament allows us to track which neural
network is the best out of all the networks.
Co-evolution with NEAT

Co-evolution allows individual fitness based on the
number of rounds won by a neural network.


Example: If neural network wins a round it will get a
plus 1 if it loses or ties then no score will be added.
NEAT allows the neural networks to grow and still keep
track of past innovations.
NEAT Class Diagram
Neural Network
Dominance Tournament




Tracks the best neural network out of all trained
networks.
Allows for a guarantee of the best network.
Example: if d3 beats d2 and d2 beats d1 we can say d3
is the best, but what happens if d1 beats d3. This is
what the dominance prevents.
Dominance tournament states that in order to be the
best you have to beat all of the other best.
Level One Training Data




The time it took on average to complete one generation
was 1 hour.
The time it took to complete one generation with a lot
winners was about 30-45 minutes.
The time to complete 10 generations > 10 hours
After each generation the dominance tournament was ran
and took about 1-3 minutes.
Level One Troubles

Time to train slowed everything down.

Have the neural networks been advanced enough.

Getting real 3d graphics.

Showing that the artificial intelligence is an actual AI and
not something like FSM.
Level 2 – Maze Race
• Race between the Player and the AI character.
• The one to get to the goal first wins.
Maze Maps
•
Prototype used for
training.
•
Final Design of Maze
Dual Camera View
Player Character
AI Character
Environment
• The background is black with stars to simulate space.
• The walls of the maze were created using Blender, and
they look like asteroids.
• Blender was also used to create the spaceship of the
player and of the enemy.
Player Character
• Space Shuttle looking.
• Controlled by the arrow keys or
by the ‘A’ ‘S’ ‘W’ ‘D’ keys.
• The object is going to rotate with
the left and right keys of the ‘A’ and ‘D’ keys.
• The object is going to move forward and backwards with
the up and down arrows and with the ‘W’ and ‘S’ keys.
AI Character
• The enemy looks like a UFO.
• Controlled by the artificial intelligence
algorithm.
• The enemy will have sensors that are going to give the
inputs to the AI.
• The AI is then going to output the displacement of the
enemy.
Artificial Intelligence
• Neural Networks with a Genetic Algorithm
2 outputs
5 inputs
Neural Network: Inputs
• Inputs are going to come from the sensors.
• Sensors are rays that come out of the character and feel
the world around it.
• These rays are going to be invisible to the player.
Neural Network: Inside the Neuron
Neuron:
Inside the neuron:
Activation value =
Neural Network: Outputs
• The sigmoid curve and the activation value are used to
calculate the output of the neuron.
7/31/12
How The Genetic Algorithm Works
• First a population of 40 individuals (Neural Networks) is
created with random weight values.
• Each individual is left to run and a fitness value is
assigned depending on its performance.
7/31/12
How The Genetic Algorithm Works
• The genetic algorithm then looks at this population and
its fitness values to create a new one with better weights
on each individual.
• The new generation then runs to get fitness values and
again enter the GA for the next generation.
• After many generations, all the individuals should be at
around the same fitness value.
Training
• Population = 40 individuals
• Individuals were given 1 minute each to traverse the
maze.
• The GA ran for 21 generations
• That is a total of 14 hours of training!
7/31/12
Enemy at Generation 1
7/31/12
Enemy at Generation 12
Level 3- Game Play
• Dodge Ball Concept
• Offers a better chances of a successful Real Time learning.
• Player controls a single player
• Enemies are continuously regenerating.
• Player wins if hits a certain number of enemies within a
time limit.
• Player loses if each member if he/she is killed before the
time limit or goal is not met before the time limit.
• Players and enemies can shoot at the same time.
Game Objects
Object
Function
Number
User-Model
Model the user will have control of in order to play the
game.
1
Enemy
Models that will be controlled by the neural networks.
18
Shots
Objects that will collide with either user or enemy
1 + 18
Stadium
Where the contest will occur. For appearance as well as
preventing user or enemy from going beyond boundaries.
1
Point Counter
Displays the number of enemies the user has eliminated
verses the total amount needed to win the game.
1
Timer
Counts up to limit. Lets user know how much time she/he
has left until game is over.
1
Light Source
For appearance purposes.
5
Terrain
Appearance
1
Health Counter
Let’s the user know how much health is left
1
Intro to Level
For entertainment purposes and example directions.
1
Overall Game Classes
•
Minion
•
•
In charge of non-player characters
AgentController
•
In charge of player’s characters
• Collision
•
Main
•
In charge of overall follow of game.
• Runs NEAT, checks timer, calculates number of ticks, initialize brains
•
MinionShots
•
•
In charge of the shots made by minion
Shots
•
In charge of the player’s shots
Neural Networks
Minions- Visual
Real Time NEAT Visual
Real Time NEAT
• Remove the worst adjusted fitness minion from
population
• There must be an minion old enough
• Re calculate average fitness of each species
• Choose the Parent species that will produce the child
• Based on the probability of been choosen
• (Average fitness of species k)/ total species fitnesses
• Adjust compatibility threshold and reassign members
• Based on the number of species one wants
• Insert member in the environment.
Planning
Planning
Questions?
AI in Space
• Group 3