1 / 15

A Heuristic Hillclimbing Algorithm for Mastermind

A Heuristic Hillclimbing Algorithm for Mastermind. Alexandre Temporel and Tim Kovacs. Mastermind. A constraint optimisation problem Studied from perspectives of: combinatorics information theory game theory artificial intelligence evolutionary computation. Rules of Mastermind.

lars
Download Presentation

A Heuristic Hillclimbing Algorithm for Mastermind

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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) 4x6 5x8 6x8 Random 4.66 5.88 - GA (Bento) - 6.86 - GA (Merelo) 4.132 5.904 SHC Code Tracker 4.661 5.888 6.308 SHC without CT 4.64 5.834 6.289

  13. Number of Potential Guesses Evaluated Size of Game 4x6 5x8 6x8 Random 1295 32515 258000 GA (Bento) - 1029.9 - GA (Merelo) 279 2171 - SHC Code Tracker 76.3 835 2800 SHC without CT 41.2 480.1 2759

  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

More Related