SlideShare a Scribd company logo
1 of 53
MINESWEEPER
A. Couëtoux, O. Teytaud
TAO, Inria, Lri, U-Psud,
Umr Cnrs 8623
+ OASE, NUTN
MINESWEEPER
A. Couëtoux, O. Teytaud
TAO, Inria, Lri, U-Psud, Umr Cnrs 8623 + OASE, NUTN
                                     Sometimes we work
                                         on (visibly)
                                        serious stuff.
MINESWEEPER
  A. Couëtoux, O. Teytaud
  TAO, Inria, Lri, U-Psud, Umr Cnrs 8623 + OASE, NUTN
                                       Sometimes we work
                                           on (visibly)
                                          serious stuff.




   But I think the best
challenge for proving that
we have good algorithms
        is games
And a great challenge is MineSweeper!




Yes I'm serious!
RULES
I play
here!
Good news!

 No mine in
     the
neighborhood!

 I can “click”
    all the
 neighbours.
I have 3
  uncovered
  neighbors,
 and I have 3
 mines in the
neighborhood
 ==> 3 flags!
I know
  it's a
 mine,
so I put
 a flag!
No info !
I play here and I lose...
The most
successful
game ever!
Who never
 played
  Mine-
Sweeper ?
Do you
think it's
 easy ?
(10 mines)
What is
the optimal
  move ?
What is
                                        the optimal
                                          move ?



     Remark: the question makes sense.
You don't need the history for playing optimaly.
            ==> (non-trivial proof!)
What is
                                     the optimal
                                       move ?



             This one is easy.

Both remaining locations win with proba 50%.
More
difficult!
 Which
move is
optimal ?
Probability
  of a mine ?
- Top:
- Middle:
- Bottom:
Probability
  of a mine ?
- Top: 33%
- Middle:
- Bottom:
Probability
  of a mine ?
- Top: 33%
- Middle: 33%
- Bottom:
Probability
  of a mine ?
- Top: 33%
- Middle: 33%
- Bottom: 33%
Probability
    of a mine ?
- Top: 33%
- Middle: 33%
- Bottom: 33%

==> so all moves
    equivalent ?
Probability
    of a mine ?
- Top: 33%
- Middle: 33%
- Bottom: 33%

==> so all moves
    equivalent ?
==> NOOOOO!!!
MineSweeper approaches
- exact MDP: very expensive. 4x4 solved.
- CSP: the main approach.
    - (unknown) state:
          x(i) = 1 if there is a mine at location i
    - each visible location is a constraint:
           If location 15 is 4, then
           x(04)+x(05)+x(06)
          +x(14)+         x(16)
          +x(24)+x(25)+x(26) = 4.
    - find all solutions X1, X2, X3,...,XN
    - P(mine in j) = sumi Xij / N
    - play j such that P(mine in j) minimal
    - randomly break tie.
          MDP= Markov Decision Process
        CSP = Constraint Satisfaction Problem
CSP
- is very fast
- but it's not optimal
- because of




Here CSP plays randomly!
Also for the initial move: don't play
 randomly the first move!   (sometimes opening book)
Why not UCT ?
- looks like a stupid idea at first view
- can not compete with CSP in terms of speed
- But at least UCT is
  consistent: if given
  sufficient
  time, it will play
  optimally.
Should I present UCT ?
UCT (Upper Confidence Trees)




Coulom (06)
Chaslot, Saito & Bouzy (06)
Kocsis Szepesvari (06)
UCT
UCT
UCT
UCT
UCT
      Kocsis & Szepesvari (06)
Exploitation ...
Exploitation ...
            SCORE =
                5/7
             + k.sqrt( log(10)/7 )
Exploitation ...
            SCORE =
                5/7
             + k.sqrt( log(10)/7 )
Exploitation ...
            SCORE =
                5/7
             + k.sqrt( log(10)/7 )
... or exploration ?
              SCORE =
                  0/2
               + k.sqrt( log(10)/2 )
What do I need for implementing UCT ?
A complete generative model.
Given a state and an action,
I must be able to simulate possible transitions.
State S, Action a:
(S,a) ==> S'
Example: given the state below, and the action “top left”, what
are the possible next states ?
What do I need for implementing UCT ?

A complete generative model.
Given a state and an action,
I must be able to simulate possible transitions.

State S, Action a:
(S,a) ==> S'

Example: given the state below, and the action “top left”, what are the possible next
states ?
What do I need for implementing UCT ?

A complete generative model.
Given a state and an action,
I must be able to simulate possible transitions.

State S, Action a:
(S,a) ==> S'

Example: given the state below, and the action “top left”, what are the possible next
states ?
What do I need for implementing UCT ?

A complete generative model.
Given a state and an action,
I must be able to simulate possible transitions.

State S, Action a:
(S,a) ==> S'

Example: given the state below, and the action “top left”, what are the possible next
states ?
What do I need for implementing UCT ?

A complete generative model.
Given a state and an action,
I must be able to simulate possible transitions.

State S, Action a:
(S,a) ==> S'

Example: given the state below, and the action “top left”, what are the possible next
states ?
Can you please
                       forgive me for that ?
What do I need for implementing UCT ?


Given a state andI've been lazy, I have just
A complete generative model.
                   an action,
      implemented the rejection algorithm.
I must be able to simulate possible transitions.

State S, Action a:
(S,a) ==> S'

Example: given the state below, and the action “top left”, what are the possible next
states ?
Rejection algorithm:
      1- randomly draw the mines
What do I need for implementing UCT ?


Given 2- if and an action, return the new observation
       a state it's ok,
A complete generative model.


      3- otherwise, go back to 1.
I must be able to simulate possible transitions.

State S, Action a:
(S,a) ==> S'

Example: given the state below, and the action “top left”, what are the possible next
states ?
(being lazy is good:
          I could write a second paper with
What do I need for implementing UCT ?


                    a better algorithm :-) )
A complete generative model.
Given a state and an action,
                       (using CSP for this!)
I must be able to simulate possible transitions.

State S, Action a:
(S,a) ==> S'

Example: given the state below, and the action “top left”, what are the possible next
states ?
An example showing that the initial
move matters (and our algorithm finds it!)..

                                 3x3, 7 mines:
                               the optimal move
                          is anything but the center.
                         Optimal winning rate: 25%.
                           Optimal winning rate if
                              random uniform
                            initial move: 17/72.

                              (yes we get 1/72
                               improvement!)
15 mines on 5x5 board with
       GnoMine rule
   (i.e. initial move is 0)
           Optimal success rate = 100%!!!!!
Play the center, and you win (well, you have to work...)
UCT vs CSP + opening book (play corners)
         in the Windows mode
Probability
    of a mine ?
- Top: 33%
- Middle: 33%
- Bottom: 33%

Top or bottom:
  66% of win!

Middle: 33%!
CONCLUSIONS
- MineSweeper is not dead!
  ==> still a challenge

- When you have a myopic solver
   (i.e. which neglects long term
   effect, as often in industry!) ==>
   combine with UCT

- More to come, big boards are far
  from optimal
Thanks for your attention!




    9 Mines.
   What is the
 optimal move ?

More Related Content

Viewers also liked (9)

Functional programming
Functional programmingFunctional programming
Functional programming
 
Bias and Variance in Continuous EDA: massively parallel continuous optimization
Bias and Variance in Continuous EDA: massively parallel continuous optimizationBias and Variance in Continuous EDA: massively parallel continuous optimization
Bias and Variance in Continuous EDA: massively parallel continuous optimization
 
Keywords and examples of machine learning
Keywords and examples of machine learningKeywords and examples of machine learning
Keywords and examples of machine learning
 
Direct policy search
Direct policy searchDirect policy search
Direct policy search
 
Power systemsilablri
Power systemsilablriPower systemsilablri
Power systemsilablri
 
Artificial intelligence for power systems
Artificial intelligence for power systemsArtificial intelligence for power systems
Artificial intelligence for power systems
 
Simulation-based optimization: Upper Confidence Tree and Direct Policy Search
Simulation-based optimization: Upper Confidence Tree and Direct Policy SearchSimulation-based optimization: Upper Confidence Tree and Direct Policy Search
Simulation-based optimization: Upper Confidence Tree and Direct Policy Search
 
Examples of operational research
Examples of operational researchExamples of operational research
Examples of operational research
 
Bias correction, and other uncertainty management techniques
Bias correction, and other uncertainty management techniquesBias correction, and other uncertainty management techniques
Bias correction, and other uncertainty management techniques
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Artificial intelligence for minesweeper

  • 1. MINESWEEPER A. Couëtoux, O. Teytaud TAO, Inria, Lri, U-Psud, Umr Cnrs 8623 + OASE, NUTN
  • 2. MINESWEEPER A. Couëtoux, O. Teytaud TAO, Inria, Lri, U-Psud, Umr Cnrs 8623 + OASE, NUTN Sometimes we work on (visibly) serious stuff.
  • 3. MINESWEEPER A. Couëtoux, O. Teytaud TAO, Inria, Lri, U-Psud, Umr Cnrs 8623 + OASE, NUTN Sometimes we work on (visibly) serious stuff. But I think the best challenge for proving that we have good algorithms is games
  • 4. And a great challenge is MineSweeper! Yes I'm serious!
  • 7. Good news! No mine in the neighborhood! I can “click” all the neighbours.
  • 8. I have 3 uncovered neighbors, and I have 3 mines in the neighborhood ==> 3 flags!
  • 9.
  • 10. I know it's a mine, so I put a flag!
  • 12. I play here and I lose...
  • 13. The most successful game ever! Who never played Mine- Sweeper ?
  • 14. Do you think it's easy ? (10 mines)
  • 16. What is the optimal move ? Remark: the question makes sense. You don't need the history for playing optimaly. ==> (non-trivial proof!)
  • 17. What is the optimal move ? This one is easy. Both remaining locations win with proba 50%.
  • 19. Probability of a mine ? - Top: - Middle: - Bottom:
  • 20. Probability of a mine ? - Top: 33% - Middle: - Bottom:
  • 21. Probability of a mine ? - Top: 33% - Middle: 33% - Bottom:
  • 22. Probability of a mine ? - Top: 33% - Middle: 33% - Bottom: 33%
  • 23. Probability of a mine ? - Top: 33% - Middle: 33% - Bottom: 33% ==> so all moves equivalent ?
  • 24. Probability of a mine ? - Top: 33% - Middle: 33% - Bottom: 33% ==> so all moves equivalent ? ==> NOOOOO!!!
  • 25. MineSweeper approaches - exact MDP: very expensive. 4x4 solved. - CSP: the main approach. - (unknown) state: x(i) = 1 if there is a mine at location i - each visible location is a constraint: If location 15 is 4, then x(04)+x(05)+x(06) +x(14)+ x(16) +x(24)+x(25)+x(26) = 4. - find all solutions X1, X2, X3,...,XN - P(mine in j) = sumi Xij / N - play j such that P(mine in j) minimal - randomly break tie. MDP= Markov Decision Process CSP = Constraint Satisfaction Problem
  • 26. CSP - is very fast - but it's not optimal - because of Here CSP plays randomly! Also for the initial move: don't play randomly the first move! (sometimes opening book)
  • 27. Why not UCT ? - looks like a stupid idea at first view - can not compete with CSP in terms of speed - But at least UCT is consistent: if given sufficient time, it will play optimally.
  • 29. UCT (Upper Confidence Trees) Coulom (06) Chaslot, Saito & Bouzy (06) Kocsis Szepesvari (06)
  • 30. UCT
  • 31. UCT
  • 32. UCT
  • 33. UCT
  • 34. UCT Kocsis & Szepesvari (06)
  • 36. Exploitation ... SCORE = 5/7 + k.sqrt( log(10)/7 )
  • 37. Exploitation ... SCORE = 5/7 + k.sqrt( log(10)/7 )
  • 38. Exploitation ... SCORE = 5/7 + k.sqrt( log(10)/7 )
  • 39. ... or exploration ? SCORE = 0/2 + k.sqrt( log(10)/2 )
  • 40. What do I need for implementing UCT ? A complete generative model. Given a state and an action, I must be able to simulate possible transitions. State S, Action a: (S,a) ==> S' Example: given the state below, and the action “top left”, what are the possible next states ?
  • 41. What do I need for implementing UCT ? A complete generative model. Given a state and an action, I must be able to simulate possible transitions. State S, Action a: (S,a) ==> S' Example: given the state below, and the action “top left”, what are the possible next states ?
  • 42. What do I need for implementing UCT ? A complete generative model. Given a state and an action, I must be able to simulate possible transitions. State S, Action a: (S,a) ==> S' Example: given the state below, and the action “top left”, what are the possible next states ?
  • 43. What do I need for implementing UCT ? A complete generative model. Given a state and an action, I must be able to simulate possible transitions. State S, Action a: (S,a) ==> S' Example: given the state below, and the action “top left”, what are the possible next states ?
  • 44. What do I need for implementing UCT ? A complete generative model. Given a state and an action, I must be able to simulate possible transitions. State S, Action a: (S,a) ==> S' Example: given the state below, and the action “top left”, what are the possible next states ?
  • 45. Can you please forgive me for that ? What do I need for implementing UCT ? Given a state andI've been lazy, I have just A complete generative model. an action, implemented the rejection algorithm. I must be able to simulate possible transitions. State S, Action a: (S,a) ==> S' Example: given the state below, and the action “top left”, what are the possible next states ?
  • 46. Rejection algorithm: 1- randomly draw the mines What do I need for implementing UCT ? Given 2- if and an action, return the new observation a state it's ok, A complete generative model. 3- otherwise, go back to 1. I must be able to simulate possible transitions. State S, Action a: (S,a) ==> S' Example: given the state below, and the action “top left”, what are the possible next states ?
  • 47. (being lazy is good: I could write a second paper with What do I need for implementing UCT ? a better algorithm :-) ) A complete generative model. Given a state and an action, (using CSP for this!) I must be able to simulate possible transitions. State S, Action a: (S,a) ==> S' Example: given the state below, and the action “top left”, what are the possible next states ?
  • 48. An example showing that the initial move matters (and our algorithm finds it!).. 3x3, 7 mines: the optimal move is anything but the center. Optimal winning rate: 25%. Optimal winning rate if random uniform initial move: 17/72. (yes we get 1/72 improvement!)
  • 49. 15 mines on 5x5 board with GnoMine rule (i.e. initial move is 0) Optimal success rate = 100%!!!!! Play the center, and you win (well, you have to work...)
  • 50. UCT vs CSP + opening book (play corners) in the Windows mode
  • 51. Probability of a mine ? - Top: 33% - Middle: 33% - Bottom: 33% Top or bottom: 66% of win! Middle: 33%!
  • 52. CONCLUSIONS - MineSweeper is not dead! ==> still a challenge - When you have a myopic solver (i.e. which neglects long term effect, as often in industry!) ==> combine with UCT - More to come, big boards are far from optimal
  • 53. Thanks for your attention! 9 Mines. What is the optimal move ?