Genetic Algorithms for Game Programming Steve Gargolinski

Slides:



Advertisements
Similar presentations
Logical and Artificial Intelligence in Games Lecture 14
Advertisements

Genetic Algorithms Chapter 3. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing Genetic Algorithms GA Quick Overview Developed: USA in.
Genetic Algorithms Vida Movahedi November Contents What are Genetic Algorithms? From Biology … Evolution … To Genetic Algorithms Demo.
Genetic Algorithms (Evolutionary Computing) Genetic Algorithms are used to try to “evolve” the solution to a problem Generate prototype solutions called.
Tetris – Genetic Algorithm Presented by, Jeethan & Jun.
Student : Mateja Saković 3015/2011.  Genetic algorithms are based on evolution and natural selection  Evolution is any change across successive generations.
Tetris and Genetic Algorithms Math Club 5/30/2011.
Case Study: Genetic Algorithms GAs are an area of AI research –used to solve search problems with potentially better performance than traditional search.
Genetic Algorithms By: Anna Scheuler and Aaron Smittle.
Genetic Algorithms Contents 1. Basic Concepts 2. Algorithm
Tuesday, May 14 Genetic Algorithms Handouts: Lecture Notes Question: when should there be an additional review session?
Genetic Algorithms Representation of Candidate Solutions GAs on primarily two types of representations: –Binary-Coded –Real-Coded Binary-Coded GAs must.
1 Lecture 8: Genetic Algorithms Contents : Miming nature The steps of the algorithm –Coosing parents –Reproduction –Mutation Deeper in GA –Stochastic Universal.
Evolutionary Computational Intelligence
Genetic Algorithms GAs are one of the most powerful and applicable search methods available GA originally developed by John Holland (1975) Inspired by.
Imagine that I am in a good mood Imagine that I am going to give you some money ! In particular I am going to give you z dollars, after you tell me the.
Intro to AI Genetic Algorithm Ruth Bergman Fall 2002.
Chapter 14 Genetic Algorithms.
Evolutionary Computation Application Peter Andras peter.andras/lectures.
Intro to AI Genetic Algorithm Ruth Bergman Fall 2004.
Chapter 6: Transform and Conquer Genetic Algorithms The Design and Analysis of Algorithms.
The Standard Genetic Algorithm Dr. Chrisantha Fernando Systems Biology Centre University of Birmingham Dr. Chrisantha Fernando Systems Biology Centre University.
Genetic Algorithms Overview Genetic Algorithms: a gentle introduction –What are GAs –How do they work/ Why? –Critical issues Use in Data Mining –GAs.
Pawel Drozdowski – November Introduction GA basics Solving simple problem GA more advanced topics Solving complex problem Question and Answers.
Prepared by Barış GÖKÇE 1.  Search Methods  Evolutionary Algorithms (EA)  Characteristics of EAs  Genetic Programming (GP)  Evolutionary Programming.
Genetic Algorithm.
SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.
Intro. ANN & Fuzzy Systems Lecture 36 GENETIC ALGORITHM (1)
Genetic algorithms Prof Kang Li
Optimization in Engineering Design Georgia Institute of Technology Systems Realization Laboratory Mixed Integer Problems Most optimization algorithms deal.
Zorica Stanimirović Faculty of Mathematics, University of Belgrade
Genetic Algorithms Michael J. Watts
ART – Artificial Reasoning Toolkit Evolving a complex system Marco Lamieri Spss training day
Design of a real time strategy game with a genetic AI By Bharat Ponnaluri.
Genetic algorithms Charles Darwin "A man who dares to waste an hour of life has not discovered the value of life"
ART – Artificial Reasoning Toolkit Evolving a complex system Marco Lamieri
G ENETIC A LGORITHMS Steve Foster. I NTRODUCTION Genetic Algorithms are based on the principals of evolutionary biology in order to find solutions to.
An Introduction to Genetic Algorithms Lecture 2 November, 2010 Ivan Garibay
Soft Computing A Gentle introduction Richard P. Simpson.
Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or.
2005MEE Software Engineering Lecture 11 – Optimisation Techniques.
Learning by Simulating Evolution Artificial Intelligence CSMC February 21, 2002.
Introduction to Genetic Algorithms. Genetic Algorithms We’ve covered enough material that we can write programs that use genetic algorithms! –More advanced.
Edge Assembly Crossover
Genetic Algorithms What is a GA Terms and definitions Basic algorithm.
Introduction to Genetic Algorithm Principle: survival-of-the-fitness Characteristics of GA Robust Error-tolerant Flexible When you have no idea about solving.
Genetic Algorithms. 2 Overview Introduction To Genetic Algorithms (GAs) GA Operators and Parameters Genetic Algorithms To Solve The Traveling Salesman.
MAE 552 Heuristic Optimization Instructor: John Eddy Lecture #12 2/20/02 Evolutionary Algorithms.
Chapter 12 FUSION OF FUZZY SYSTEM AND GENETIC ALGORITHMS Chi-Yuan Yeh.
EE749 I ntroduction to Artificial I ntelligence Genetic Algorithms The Simple GA.
D Nagesh Kumar, IIScOptimization Methods: M8L5 1 Advanced Topics in Optimization Evolutionary Algorithms for Optimization and Search.
1 Contents 1. Basic Concepts 2. Algorithm 3. Practical considerations Genetic Algorithm (GA)
An Introduction to Genetic Algorithms Lecture 2 November, 2010 Ivan Garibay
Genetic Algorithms. Underlying Concept  Charles Darwin outlined the principle of natural selection.  Natural Selection is the process by which evolution.
Genetic Algorithm Dr. Md. Al-amin Bhuiyan Professor, Dept. of CSE Jahangirnagar University.
Selection and Recombination Temi avanzati di Intelligenza Artificiale - Lecture 4 Prof. Vincenzo Cutello Department of Mathematics and Computer Science.
Artificial Intelligence By Mr. Ejaz CIIT Sahiwal Evolutionary Computation.
Overview Last two weeks we looked at evolutionary algorithms.
CAP6938 Neuroevolution and Artificial Embryogeny Evolutionary Comptation Dr. Kenneth Stanley January 23, 2006.
Genetic Algorithms An Evolutionary Approach to Problem Solving.
Genetic Algorithms And other approaches for similar applications Optimization Techniques.
 Presented By: Abdul Aziz Ghazi  Roll No:  Presented to: Sir Harris.
Chapter 14 Genetic Algorithms.
Genetic Algorithms Author: A.E. Eiben and J.E. Smith
Genetic Algorithms.
Dr. Kenneth Stanley September 11, 2006
Evolutionary Algorithms Jim Whitehead
EE368 Soft Computing Genetic Algorithms.
A Gentle introduction Richard P. Simpson
Genetic Algorithm Soft Computing: use of inexact t solution to compute hard task problems. Soft computing tolerant of imprecision, uncertainty, partial.
Presentation transcript:

Genetic Algorithms for Game Programming Steve Gargolinski

The Basic Idea  We’re going to develop techniques based on the principals of evolutionary biology in order to find solutions to problems.

First, Some Biology  How we survive as a species  Reproduction  DNA  Chromosomes  Genes  Nucleotides: Thymine, Adenine, Cytosine, Guanine  Genome = chromosomes + all other hereditary information

How We Evolve  Natural Selection  Strong members of a population survive to reproduce, passing on their ‘strong’ traits  Crossover  Some from parent A, some from parent B  Mutation  A strange flipped gene that cannot be traced back to a parent

Biology -> Genetic Algorithm  Gene = smallest atom of data  Usually binary, so 0 or 1  Genome = string of genes   Genome Pool = set of genomes  Represents our population

The Basic Idea  Start with a completely random genome pool  Each of these decomposes to a (potential) solution to our problem.  Gradually evolve our way to a solution

Fitness/Strength Heuristic  Turns a binary string into a single floating point value based on how close to our desired result it is.  Maps back to how well an organism can survive in an environment.  0.0f = terrible  1.0f = absolute solution

A Basic Genetic Algorithm  Start with a random genome pool of n members.  Run strength heuristic on each random genome in the pool.  ‘Randomly’ crossbreed strong members of the population until you have n new genomes.  Introduce some mutation.  Repeat until the strength heuristic returns a value within our threshold.

Simple Crossover Parents Children

Genome Selection  We now know how to crossover, but which genomes do we select?  Simplest way is random selection  A better way is to weigh selection based on relative strength  Roulette Wheel Selection

Pathfinding Example (1)  A* is probably “better”, yeah?  Definitely better  Example:  2D grid  Arbitrary number of boundaries  1 start point  1 finish point

Pathfinding Example (2)  Break down binary string into movements across a 2D grid.  00 = up  01 = right  10 = down  11 = left

Pathfinding Example (3)  Heuristic function:  Simulate binary string movement beginning at start point.  Measure distance from finish (simple, Pythagorean)  Fitness score = 1 – (distance / max possible distance)

Pathfinding Example (4) start Genome A: = Right 10 = Down 01 = Right (Bump) 10 = Down 01 = Right 00 = Up (Bump) 01 = Right 00 = Up Fitness = 1 - (2 / 24) finish

Pathfinding Example (5) start Genome B: = Up 01 = Right 10 = Down 11 = Left 10 = Down 01 = Right Fitness = 1 – (2 / 24) finish

Pathfinding Example (6) Genome A: Genome B: Genome C: This is how we take two genomes and create a new one: (assumes no mutation for now)

Pathfinding Example (7) start 01 = Right 10 = Down 01 = Right (Bump) 10 = Down 01 = Right 00 = Up (Bump) 01 = Right Fitness = 1 – (0 / 24) finish Genome C:

Sample Program ( me for the source code!)

Things We Can Tweak  Mutation rate  0.01 is a reasonable starting value  Crossover rate  0.7 or so  Chromosome length  Varies a lot based on specific problem  Population size  Try maybe

How This is Used in Games  Computationally expensive, becoming easier to deal with as hardware speeds up  Most of the time is run offline with the results used in a ‘black box’ fashion in the actual game.  Can be used to tune priorities, behaviors, parameters, etc.

How This Is Used in Games (2)  Some games run it in real time  Black and White  Quake 3 bot AI  Used to optimize the fuzzy logic controller AI.  I am:  45% in favor of grabbing that rocket launcher  62% in favor of picking up the red armor  89% in favor of the Quad Damage  Check out the source code (GPL)

Genetic Algorithms Are Cool  Totally generic if you do it right – All you NEED to override is the heuristic/fitness function.  Algorithm is separate from problem representation.  Can find solutions to problems in very strange solution spaces.

Genetic Algorithms Are Cool (2)  Can result in organic strategies  If you run in real time and seed genomes with values based on character knowledge, intuition, etc.  Much processing can be done offline and incorporated later.

Things to Watch Out For  Easy to lose good members of the population  Tweaks/optimizations are most likely going to be very problem specific.

Things to Watch Out For (2)  Population can converge on similar chromosomes  Removes the benefit of the crossover  Mutation might not be enough to find a solution  This could lead to an infinite loop

Improvements  First, remember the things I mentioned we could tweak earlier?  In real-time applications, figure out optimal parameters offline.  We can improve basically each step of the original algorithm.

Different Types of Crossover Multipoint Parents Children

More Mutation  Displacement Mutation  Grab a random string from parent A  Insert at a random location in parent B  Insertion Mutation  Much like displacement mutation, except only move a single gene  This one is very effective.  Inversion Mutation  Pick a random string, reverse it  Displaced Inversion Mutation

More Chromosome Selection Techniques  Elitism  Select a small group of the strongest to move on  Steady State Selection  Cut out the weakest members  Fitness Proportionate Selection  Roulette Wheel Selection (original technique)

Scaling Techniques  Instead of using the raw fitness score, run it through a function first.  Rank Scaling  Order results by fitness, rescore based on rank.  Prevents quick convergence.  Can get too slow  Sigma Scaling  Attempt to balance between wild variation of the early generations and the similar members of later generations.

Things I Wished I Had Known Before Getting My Job Also, things I was glad that I did know. And things I wished I had known better.

The Most Important Thing I Can Tell You  Make sure that you leave college with a decent project to show off  If you’re lucky, get it done through a job  If not, work on a game or a mod or a tech demo – something!

General Stuff  Always program assignments/solutions to the most general case possible  Extend from there towards the solution you are looking for.  Program to interfaces

General Stuff (2)  Learn where others have already solved your problems.  Read “Head First Design Patterns”  Look for cases to apply these in games  Be consistent in your coding style  Read “Pragmatic Programmer” and “Code Complete”

Implementation Specific  Standard Template Library  Know the situations to use each type of container  3D Stuff  Both OpenGL and D3D implementations  Pay attention in linear algebra

C++  Know when to use pointers and when to use references  Also const pointers, const references  Know when things should be virtual  Read “Effective C++” and “More Effective C++” by Scott Meyers

C++ (2)  Learn how to optimize code  VTune - Hopefully you have an Intel processor  CodeAnalyst is useless  Programmers are notoriously wrong about this sort of thing.

Misc  Pay attention to time.  Remember that it’s just a (really cool) job.

References  AI Techniques For Game Programming by Mat Buckland  AI Game Engine Programming by Brian Schwab