Presentation is loading. Please wait.

Presentation is loading. Please wait.

A Heuristic Hillclimbing Algorithm for Mastermind Alexandre Temporel and Tim Kovacs.

Similar presentations


Presentation on theme: "A Heuristic Hillclimbing Algorithm for Mastermind Alexandre Temporel and Tim Kovacs."— Presentation transcript:

1 A Heuristic Hillclimbing Algorithm for Mastermind Alexandre Temporel and Tim Kovacs

2 Mastermind A constraint optimisation problem Studied from perspectives of: combinatorics information theory game theory artificial intelligence evolutionary computation

3 Rules of Mastermind A 2-player game: code maker selects a secret code and score’s opponents guesses against it code breaker attempts to find secret code with as few guesses as possible Secret code is a sequence of 4 colours from the set {red, yellow, blue, green, black, white}

4 Feedback on Guesses For each guess, code maker returns: a black peg for each correct colour in correct position a white peg for each correct colour in incorrect position NB: each colour only scores 1 peg Example: (using integers instead of colours) Secret code: 2413 Guess: 1233 Score: 1 black peg, 2 white pegs

5 Objectives 1. Traditional objective is to minimise number of guesses needed to find secret code 2. For computer players also of interest to minimise number of codes considered as potential guesses Our algorithm is similar to existing Genetic Algorithm players on (1) but better on (2)

6 General Strategies Number of possible codes is finite Each new guess rules out some possibilities Strategically optimal strategies make guesses we know are incorrect but which maximise number of possibilities ruled out Stepwise optimal make only guesses that could be correct

7 A Useful Property of Mastermind Each guess is scored as 1 of 14 possible combinations of black and white pegs So all guesses belong to 1 of 14 sets of guesses If we score a potential guess against the last guess, the secret code will be in the set which scores the same as the last guess against the secret code This lets us evaluate potential guesses against our last guess before making our next guess

8 Example Secret Code: 2413 Guess 1: 1233 Score: 1 black, 2 white For guess 2, we should use a combination which scores 1 back, 2 white against guess 1 Any combination which does not cannot be the secret code

9 Selecting Potential Guesses How to select potential guesses to score against our last guess? at random (Rosu) using a Genetic Algorithm (Bento, Merelo) our new method

10 Our Method 1. Submit a random guess and call it CFG 2. Induce a New Potential Guess (NPG) from CFG as described on next slide 3. If NPG does not score the same as previous guesses go to (2), otherwise submit it as new guess 4. If new guess scores 0 black 0 white then prevent its colours being used again and go to (1) 5. If new guess scores as good or better than CFG then adopt it as CFG 6. If new guess is secret code stop, otherwise (2)

11 Induction of New Potential Guesses 1. Select as many characters from CFG as it has black pegs (correct colours in correct position) and add to NPG 2. Select as many characters from CFG as it has white pegs and assign them to random empty positions in NPG 3. Fill any remaining positions with random colours (but give higher probability to colours not already used in steps 1 and 2).

12 Number of guesses to find secret code Size of Game (colours x positions) 4x65x86x8 Random4.665.88- GA (Bento)-6.86- GA (Merelo)4.1325.904 SHC Code Tracker4.6615.8886.308 SHC without CT4.645.8346.289

13 Number of Potential Guesses Evaluated Size of Game 4x65x86x8 Random129532515258000 GA (Bento)-1029.9- GA (Merelo)2792171- SHC Code Tracker76.38352800 SHC without CT41.2480.12759

14 Number of Potential Guesses Evaluated

15 Conclusions Our method makes a similar number of guesses but considers far fewer potential guesses Our method is less complex than GA methods Further optimisation may be possible A case where domain knowledge allows randomised hillclimbing to outperform GAs Application to related constraint optimisation problems may be possible


Download ppt "A Heuristic Hillclimbing Algorithm for Mastermind Alexandre Temporel and Tim Kovacs."

Similar presentations


Ads by Google