Successfully reported this slideshow.
Upcoming SlideShare
×

# An Algorithm for solving the game of Mastermind

22,700 views

Published on

Presentation of our paper on an algorithm for cracking the code in a Mastermind Game. You can understand a bit more about the game in this blog post http://geneura.wordpress.com/2012/07/06/why-mastermind/ Please post your questions and/or feedback wherever.

Published in: Technology
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

### An Algorithm for solving the game of Mastermind

1. 1. J. J. Merelo , T. P. Runarsson U. Granada (Spain) & U. Iceland Finding better solutions to the Mastermind puzzle using evolutionary algorithms
2. 2. Game of MasterMind
3. 3. Why should I care? I want to frag!
4. 4. 7 reasons why you should <ul><li>Donald Knuth
5. 5. NP-Complete
6. 6. Differential cryptanalisis
7. 7. Circuit and program test
8. 8. Genetic profiling
9. 9. Minimize guesses
10. 10. Minimize evaluations </li></ul>
11. 11. Let's play, then
12. 12. Consistent combinations
13. 13. Naïve Algorithm <ul><li>Repeat </li><ul><li>Find a consistent combination and play it. </li></ul></ul>
14. 14. Looking for consistent solutions <ul><li>Optimization algorithm based on distance to consistency (for all combinations played) </li></ul>D = 2
15. 15. Not all consistent combinations are born the same <ul><li>There's at least one better than the others (the solution)
16. 16. Some will reduce the remaining search space more.
17. 17. But scoring them is an open issue </li></ul>
18. 18. Score consistent set
19. 19. Enter partitions Most parts. Score = 5 Best worst case. Score = -3 Entropy. Score = 1.67 1.31 0.96 0.96 1.58 1.52 1.67 1.42 1.52 1.67
20. 20. Less Naïve Algorithm <ul><li>Play initial combination
21. 21. Repeat until end </li><ul><li>Eliminate non-consistent combinations
22. 22. Score them using partitions
23. 23. Play best score </li></ul></ul>
24. 24. And the winner is... <ul><li>Entropy & Most parts obtains the best results ~ 4.408 combinations played
25. 25. Naïve algorithms obtain ~ 4.6
26. 26. Problem : exhaustive search needed </li></ul>
27. 27. We want to do better than exhaustive search <ul><li>Berghman et al.'s used only a subset of the set of consistent combinations with an evolutionary algorithm : non-exhaustive </li><ul><li>Better scaling </li></ul><li>Runarsson/Merelo computed the size of the set which obtains the same result as exhaustive search. </li></ul>That's us!
28. 28. What we do in this paper Evolutionary algorithm Fitness = Distance-to-consistency Gather a set of consistent combinations Score using most-parts Play the best score
29. 29. Canonical GAs and EDA to the rescue <ul><li>Rank-based GA did not yield good results
30. 30. Population = ¼ of search space
31. 31. Reset after stagnation
32. 32. Run until 20 consistent combinations are found or 3 generations without change
33. 33. 10 * 1296 runs (10 for each combination AAAA .. FFFF) </li></ul>
34. 34. Results <ul><li>EDA and CGA obtain results better than (seudo) exhaustive search.
35. 35. It is also comparable with the rest </li><ul><li>And with less effort! </li></ul></ul>
36. 36. The gritty details <ul><li>2-3 combinations drawn from initial population
37. 37. Evolutionary algorithm acting on final stages
38. 38. Mostly exploratory regime. </li></ul><ul><li>2-3 combinations drawn from initial population
39. 39. Evolutionary algorithm acting on final stages
40. 40. Mostly exploratory regime. </li></ul>
41. 41. <ul><li>Exhaustive search can be defeated
42. 42. Running time similar to naïve evolutionary algorithm
43. 43. Conclusions in exhaustive search can be translated to EAs. </li></ul><ul><li>Exhaustive search can be defeated
44. 44. Running time similar to naïve evolutionary algorithm
45. 45. Conclusions in exhaustive search can be translated to EAs. </li></ul>Concluding...
46. 46. That's all Thanks for your attention