How to analyze a game similar to the mastermind using logical conclusions


DISCLAIMER: I DO NOT SEEK A SOLUTION FOR Mastermind.


I'm trying to write a program to solve a game like a mastermind, and I'm a little stuck. I do not want a complete solution, only help with the part that I can’t get through. Here is the game:

Known Npossible colors, known in advance. There is an unknown set (possibly with repetitions) kthat is selected and kept secret. The goal is to guess the colors (with repetitions) in a secret set. Let me emphasize once again that this is a set, so the order does not matter, but repetitions are allowed. for instance

The colors are a,b,c,d,e,f,g,h( N=8), and the unknown value is {a,c,c}( k=3).

Successive conjectures have been made that lead to additional information about the secret set. Each conjecture should be a set (repetition allowed) of colors k. The answer to each guess is the number of colors common between assumptions and vague repetition counts. for instance

  • Guess a,d,eThe Result:1

  • Guess b,c,fThe Result:1

  • Guess a,a,gThe Result:1

  • Guess a,c,hThe Result:2

  • Guess b,e,hThe Result:0

Guess made by someone else. My goals:

- determine when information about a particular color is known.

- determine when an unknown set can be inferred.

( N>1). , 0, , , . k, , , . . , . , , a,c,c. :

  • 5, b,e,h
  • 4, a,c
  • 1, d
  • 2, f
  • 3, g
  • a c.
  • 3, a .
  • a,c,c.

, , . - , . , . .

+5
4

: . , , , . , . , , , () .

+1

. N, i +1, i - , -1, i - 0, , i th .

, . r, (k choose r) ( , ) . ( + +1 - -1 )

  • (+,0,0,-,-,0,0,0) | (-,0,0,+,-,0,0,0) | (-,0,0,-,+,0,0,0)
  • (0,+,-,0,0,-,0,0) | (0,-,+,0,0,-,0,0) | (0,-,-,0,0,+,0,0)
  • (+,0,0,0,0,0,-,0) | (-,0,0,0,0,0,+,0)
  • (+,0,+,0,0,0,0,-) | (+,0,-,0,0,0,0,+) | (-,0,+,0,0,0,0,+)
  • (0,-,0,0,-,0,0,-)

. , . 9 (1 3 1 3), . 18 , 9 . , 3 1 . 5 . 1 , :

  • (+,0,0,-,-,0,0,0)
  • (0,-,+,0,0,-,0,0)
  • (+,0,0,0,0,0,-,0)
  • (+,0,+,0,0,0,0,-)
  • (0,-,0,0,-,0,0,-)

/ . .

+1

Knuth . .

0

: ade = 1 = > 3 100, 010, 001

: bcfgh =? = > 5 = 32

, 32 * 3 = 96

repeat for the next line and delete those that are not possible for all lines

until only one left is left

0
source

All Articles