80 likes | 236 Views
The Standard Genetic Algorithm. Start with a “population” of “individuals” Rank these individuals according to their “fitness” Select pairs of individuals to “reproduce” Higher fitness greater probability of selection Each pair of “parents” produces two “children”
E N D
The Standard Genetic Algorithm • Start with a “population” of “individuals” • Rank these individuals according to their “fitness” • Select pairs of individuals to “reproduce” • Higher fitness greater probability of selection • Each pair of “parents” produces two “children” • Because of “crossover,” children receive “genes” from both parents • Introduce random “mutations” in some of the children • Repeat until a desired fitness level has been reached or some number of generations have elapsed
Individuals and Fitness • In this system, the individuals are utility functions, and the genes are the weights assigned to the different factors. • Population size is set by the user and must be a power of 2. • Fitness is measured in a single-elimination tournament. • Games are played to a maximum of 40 moves. • A win in the tournament is worth 10 fitness points. • A tie is worth 5 fitness points. • The sum of all individuals’ fitnesses is normalized to 1. • Parents are selected with probability equal to their fitness. • Parents are not necessarily monogamous.
Finding Fitnesses Individual Points Fitness A 10 0.1429 B 0 0 C 30 0.4286 D 0 0 E 0 0 F 20 0.2857 G 10 0.1429 H 0 0 Total 70 1
Crossover and Mutation • Genes are listed in a fixed, arbitrary order, and crossover occurs at a single, randomly chosen point in the list. • One child receives from one parent the set of genes that occur before the crossover point. It receives from its other parent the set of genes that occur after the crossover point. • The other child receives the complementary set of genes from each parent. • Each gene is subject to mutation with a small, independent probability that is set by the user. • The size of the mutation is random, but the distribution is skewed toward smaller changes. • A gene can never change by more than its current value.
Generating Children Parents Children 10 2 8 3 5 5 1 4 10 2 8 3 5 8 2 5 10 3 8 3 5 5 2 5 Advancement Back Row Bridge Center Control Diagonal Moment King Center Control Total Mobility Triangle of Oreo Threat 6 9 9 1 4 8 2 5 Advancement Back Row Bridge Center Control Diagonal Moment King Center Control Total Mobility Triangle of Oreo Threat 6 9 9 1 4 5 1 4 6 8 9 1 4 5 1 4 mutation crossover
Encoding Knowledge of Checkers • Move Generator • Incorporates all of the rules of the game. • Computes the legal moves that are available in a given board state. • Utility Function • Attempts to quantify the desirability of a given board state. • Consists of a simple linear combination of 16 factors taken from A. L. Samuel’s original checkers program of 1959. • Coefficients can take on any value in the range of a Java double. • Unfortunately, this function is too simple to represent the game, since it cannot even represent interactions between the factors.
The Computer Player • Basic Strategy: Minimax Search • Searches forward in time to find the best move to make now. • Represents the game as a tree. • Each level corresponds to a turn. • Each node corresponds to a possible game state. • Each edge represents a legal move. • Assumes that, at each turn, players will choose the move that is most beneficial. • In checkers, it is usually impossible to search to the end of the game because there are so many possible moves at each turn. In this system, the search is stopped at an arbitrary depth of 6 moves, and a utility function rates the desirability of every possible game state.