Game Design Studio 1

Evolutionary Algorithms
Jim Whitehead
UC Santa Cruz
School of Engineering
courses.soe.ucsc.edu/courses/cmps265/Spring14/01
[email protected]
6 May 2014
Evolutionary Algorithms
 An approach for searching large solution spaces
 As a generative method, a way of finding acceptable content in a large
space of possible content
 Inspired by biological evolution
 Has populations of solutions that are selected via a process of
reproduction, mutation, recombination, and selection
 Good for finding solutions to many kinds of problems
 Evolutionary approach can be applied in many contexts
UC SANTA CRUZ
Progress of Evolutionary Algorithm
 Have a fixed population of
“individuals” (candidate
solutions)
 Evaluation is with respect to
a “fitness function”
 Usually related to one or
more desired qualities of the
solution
 Also: “objective function”
 New population is created
by selecting some of the
most fit (parents) and then
combining them
(reproduction), and adding
randomness (mutation)
UC SANTA CRUZ
Fitness Function
 Captures the qualities of desirable solutions
 Often function that outputs a real number representing the goodness
of a particular solution.
 Can also be a vector of real numbers
 Makes it possible to determine one solution is better than another
 For generative methods, developing a fitness function can be
difficult
 What is a good fitness function for a dungeon? A platformer level?
 Sometimes you have humans act as the fitness function…
 Ideally should be inexpensive to compute
 Will be evaluated many times
 Leads to fitness functions that approximate desirable solutions: once
strong solutions are found, can perform more expensive evaluation
UC SANTA CRUZ
Selection
 Picking individuals to contribute to the next generation
 Roulette wheel (fitness proportional)
 Individuals evaluated for fitness. Probability of
selection increases with fitness.
 Most fit tend to be selected, but some lesser
fit individuals will also be selected
 Tournaments
 Run several tournaments among individuals selected at random
 Winner of each tournament is selected for crossover (or, has
increased probability of selection for crossover)
UC SANTA CRUZ
Crossover (Reproduction)
 How to vary individual solutions from one generation
(iteration) to the next
 Performed on selected individuals, so, generally, individuals with higher
fitness
 In general, idea is to exchange information between parents
 Many approaches, depends on representation of individuals
 Assuming individuals represented as strings:
One-point crossover
Two-point crossover
Uniform crossover
UC SANTA CRUZ
Mutations
 Allows for insertion of randomness into solution search
process
 Avoids getting stuck in a local optima
 Typically some number of individuals are selected for
mutation
 Can be performed on individuals in lieu of crossover, or after
crossover
 Many possibilities
 For bit string: flip bits at random positions
 For ranges: randomly select value in valid range (either with uniform,
or Gaussian distribution)
UC SANTA CRUZ
Representing individuals
 Major challenge: how to map solutions into a representation
suitable for genetic evolution
 Major dividing line between evolutionary approaches




Strings of numbers (often binary): genetic algorithms
Trees (representing programs): genetic programming
Vectors of real numbers: evolution strategy
Artificial neural networks (ANNs): neuroevolution
UC SANTA CRUZ
Generative methods
 Search-based procedural content generation: Evolutionary
approaches for generating content for games
 “Search-based” term used so as to also include other approaches such
as simulated annealing, particle swarm optimization, random local
search
Different PCG
approaches
(from Search-Based
Procedural Content
Generation: A
Taxonomy and Survey,
Togelius et al.)
UC SANTA CRUZ