Using a GA to Using a GA to Create Prey Create Prey Tactics Tactics Presented by Tony Morelli on Presented by Tony Morelli on 11/29/04 11/29/04
Dec 20, 2015
Using a GA to Using a GA to Create Prey TacticsCreate Prey Tactics
Presented by Tony Morelli on 11/29/04Presented by Tony Morelli on 11/29/04
AbstractAbstract
Evolve a predator/prey system Evolve a predator/prey system Inputs are the distances/angles between Inputs are the distances/angles between
each predator/prey and other obstacleseach predator/prey and other obstacles Outputs are the bearing and speed to Outputs are the bearing and speed to
avoid confrontations while maintaining a avoid confrontations while maintaining a task.task.
Focus on a prey whose mission is to Focus on a prey whose mission is to follow the shoreline.follow the shoreline.
IntroductionIntroduction
Use a Genetic Algorithm to evolve a prey Use a Genetic Algorithm to evolve a prey tactic when being attacked.tactic when being attacked.
This example uses animals placed inside This example uses animals placed inside the SWARM architecture. the SWARM architecture.
Objective for the prey is to identify a Objective for the prey is to identify a predator and avoid contact with it.predator and avoid contact with it.
Prey behaviors/actions will be evolved Prey behaviors/actions will be evolved against a hand coded predator. against a hand coded predator.
IntroductionIntroduction
Evolving predator/prey is useful because Evolving predator/prey is useful because it can demonstrate what happens in it can demonstrate what happens in nature as well as create new military nature as well as create new military tactics.tactics.
GA is useful because we have a set of GA is useful because we have a set of behaviors and a set of triggers for those behaviors and a set of triggers for those behaviors. Hand coding this is difficult. behaviors. Hand coding this is difficult. A GA should find the best set of A GA should find the best set of behaviors and triggers.behaviors and triggers.
BackgroundBackground
Bauson & ZiemkeBauson & Ziemke Evolved View Angle, View RangeEvolved View Angle, View Range Speed was used as a constraintSpeed was used as a constraint Prey prefers a camera with wide angle and Prey prefers a camera with wide angle and
short range, while a predator prefers small short range, while a predator prefers small angle and long rangeangle and long range
Predators dominated preyPredators dominated prey
Results SummaryResults Summary
Evolved prey outperformed hand coded Evolved prey outperformed hand coded prey when placed against a hand coded prey when placed against a hand coded predator.predator.
Evolved predator outperformed hand Evolved predator outperformed hand coded predator when placed against coded predator when placed against hand coded preyhand coded prey
Evolved predator outperformed evolved Evolved predator outperformed evolved preyprey
IntroductionIntroduction
MethodologyMethodology Results and AnalysisResults and Analysis Conclusions/Future WorkConclusions/Future Work
MethodologyMethodology
Prey needs to know it Prey needs to know it is being attacked and is being attacked and then react to the then react to the situationsituation
Prey’s primary goal is Prey’s primary goal is to follow the to follow the shoreline clock-wiseshoreline clock-wise
Must avoid predators Must avoid predators and landand land
Avoid Land
Avoid Predators
Follow Shoreline
MethodologyMethodology
Genetic Algorithm was used to evolve prey Genetic Algorithm was used to evolve prey tacticstactics GA by Ryan LeighGA by Ryan Leigh 1 Point Crossover1 Point Crossover Elitist SelectionElitist Selection Crossover: 0.7Crossover: 0.7 Mutation: 0.1Mutation: 0.1 Population: 20Population: 20 Generations: 20Generations: 20
MethodologyMethodology
ParametersParameters Distance from predator Distance from predator
Far, Near, Close, TooCloseFar, Near, Close, TooClose 50-944 pixels50-944 pixels
SpeedSpeed Slow, Normal, Fast, SuperfastSlow, Normal, Fast, Superfast 0.025-0.30.025-0.3
Turning RateTurning Rate π/16 – π / 2 radiansπ/16 – π / 2 radians
Vision RangeVision Range π/16 – π / 2 radiansπ/16 – π / 2 radians
MethodologyMethodology
51 Bit String51 Bit String Bits 0-7 – FarBits 0-7 – Far Bits 8-15 – NearBits 8-15 – Near Bits 16-23 – CloseBits 16-23 – Close Bits 24-30 – Too CloseBits 24-30 – Too Close Bits 31-33 – Turning RateBits 31-33 – Turning Rate Bits 34-36 – Vision RangeBits 34-36 – Vision Range Bits 37-43 – Fast SpeedBits 37-43 – Fast Speed Bits 44-50 – Normal SpeedBits 44-50 – Normal Speed
MethodologyMethodology
Parameter values were evolvedParameter values were evolved When each parameter was used was not When each parameter was used was not
evolvedevolved If enemy is too close change speed to Super If enemy is too close change speed to Super
FastFast The values for super fast and too close were The values for super fast and too close were
evolved, not the logic surrounding themevolved, not the logic surrounding them
MethodologyMethodology
Once an attack is identified, the prey will Once an attack is identified, the prey will try to avoid contact. try to avoid contact.
When anything gets within certain When anything gets within certain ranges, or a crash is projected within a ranges, or a crash is projected within a certain range, the prey will react to itcertain range, the prey will react to it
Fitness EvaluationFitness Evaluation
Success is measured by timeSuccess is measured by time Until the prey thinks he is being attacked, Until the prey thinks he is being attacked,
fitness increments by 1 every updatefitness increments by 1 every update If the prey is wondering around and never If the prey is wondering around and never
encounters a predator, his evasive skills are not encounters a predator, his evasive skills are not tested, so this allows to keep that prey alive in the tested, so this allows to keep that prey alive in the gene poolgene pool
Once an attack is detected fitness is Once an attack is detected fitness is incremented by 5 every updateincremented by 5 every update We really want to measure the prey’s evasive ability. We really want to measure the prey’s evasive ability.
This weight allows for that. This weight allows for that.
MethodologyMethodology
The simulation was run for 5 minutesThe simulation was run for 5 minutes This was at an accelerated rateThis was at an accelerated rate
5 minutes would take a few seconds5 minutes would take a few seconds If at any point the predator/prey collide, If at any point the predator/prey collide,
or either one hits land, the simulation or either one hits land, the simulation endsends
Fitness was calculated and the GA Fitness was calculated and the GA performed its job.performed its job.
MethodologyMethodology
First the default predator and the default prey First the default predator and the default prey went head to head to calculate a fitness.went head to head to calculate a fitness.
Next the prey was evolved against the default Next the prey was evolved against the default predator. The top prey then went head to head predator. The top prey then went head to head against the default predatoragainst the default predator
The predator was evolved against the default The predator was evolved against the default prey. The top predator then went head to head prey. The top predator then went head to head against the default preyagainst the default prey
Finally the evolved predator and the evolved Finally the evolved predator and the evolved prey were matched up and the fitness of the prey were matched up and the fitness of the prey was evaluated.prey was evaluated.
ResultsResults
Default Predator vs Default PreyDefault Predator vs Default Prey
SeedSeed FitnessFitness
0.13370.1337 130189130189
0.87120.8712 7486774867
0.71070.7107 8902389023
0.8350.835 6716167161
Average: 90310Average: 90310
ResultsResults
Average Fitness Vs Generation
0
50000
100000
150000
200000
250000
300000
350000
0 5 10 15 20
Generation
Fitn
ess Avg Fitness
Avg Max Fitness
Avg Min Fitness
ResultsResults
Evolved Prey vs Default PredatorEvolved Prey vs Default Predator
SeedSeed FitnessFitness
0.13370.1337 173523173523
0.87120.8712 303250303250
0.17070.1707 116531116531
0.8350.835 205971205971
Average: 199819Average: 199819 221% Increase221% Increase
ResultsResults
Evolved Predator vs Default PreyEvolved Predator vs Default Prey
SeedSeed FitnessFitness
0.13370.1337 2269322693
0.87120.8712 5003750037
0.17070.1707 4199141991
0.8350.835 5918159181
Average: 43476Average: 43476 48% Decrease48% Decrease
ResultsResults
Evolved Predator vs Evolved PreyEvolved Predator vs Evolved Prey
SeedSeed FitnessFitness
0.13370.1337 2687326873
0.87120.8712 3432634326
0.17070.1707 1930319303
0.8350.835 3018130181
Average: 27671Average: 27671 70% Decrease70% Decrease
ResultsResults
Evolved Predator vs Evolved - Evolved PreyEvolved Predator vs Evolved - Evolved Prey
SeedSeed FitnessFitness
0.13370.1337 172865172865
0.87120.8712 152757152757
0.17070.1707 200454200454
0.8350.835 249813249813
Average: 193972Average: 193972 214% Increase214% Increase
AnalysisAnalysis
As expected, evolved prey was highly As expected, evolved prey was highly successful when compared to the default successful when compared to the default predatorpredator
Evolved predator was much better than Evolved predator was much better than evolved preyevolved prey Evolved prey developed specialized parameters that Evolved prey developed specialized parameters that
were successful against 1 type of predatorwere successful against 1 type of predator Once paired against a different predator, the learned Once paired against a different predator, the learned
tactics no longer appliedtactics no longer applied No general knowledgeNo general knowledge
ConclusionsConclusions
The GA did work against a known The GA did work against a known predatorpredator
My evolved prey did not develop any My evolved prey did not develop any general knowledgegeneral knowledge
Future WorkFuture Work
Need to evolve prey against the evolved Need to evolve prey against the evolved predator and see if the prey can survive.predator and see if the prey can survive.
Need to add in logic for random turning Need to add in logic for random turning when there is no limit on turningwhen there is no limit on turning
Need to add in logic for handling multiple Need to add in logic for handling multiple predators.predators.
Should plan a route instead of just Should plan a route instead of just reacting and running away.reacting and running away.