Mastermind

advertisement
MASTERMIND
Henning Thomas
(joint with Benjamin Doerr,
Reto Spöhel and Carola Winzen)
Mastermind
 Board game invented by Mordechai Meirovitz in 1970
Henning Thomas
Mastermind
ETH Zurich 2012
Mastermind
 The “Codemaker” generates a secret color combination of
4
length 4 with 6 colors, m Î [6]
 The “Codebreaker” queries such color combinations,
q Î [6]4
 The answer by Codemaker is
 {i : mi = qi }
, depicted by black pegs
 max {i : mi = qp (i) } - {i : mi = qi }
p
, depicted by white pegs
 The goal of Codemaker is to identify m with as few
queries as possible.
secret
query
Henning Thomas
answer
Mastermind
ETH Zurich 2012
Mastermind with n slots and k colors
 The “Codemaker” generates a secret color combination of
n
length n with k colors, m Î [k]
 The “Codebreaker” queries such color combinations,
q Î [k]n
 The answer by Codemaker is
 {i : mi = qi }
, depicted by black pegs
 max {i : mi = qp (i) } - {i : mi = qi }
p
, depicted by white pegs
 The goal of Codemaker is to identify m with as few
queries as possible.
secret
query
Henning Thomas
answer
Mastermind
ETH Zurich 2012
Mastermind with n slots and k colors
 The “Codemaker” generates a secret color combination of
n
length n with k colors, m Î [k]
 The “Codebreaker” queries such color combinations,
q Î [k]n
This talk:
Black Peg
 The answer by Codemaker is
 {i : mi = qi }
, depicted by black pegs
Mastermind
 max {i : mi = qp (i) } - {i : mi = qi }
p
, depicted by white pegs
 The goal of Codemaker is to identify m with as few
queries as possible.
secret
query
Henning Thomas
answer
Mastermind
ETH Zurich 2012
Mastermind with n slots and k colors
 The “Codemaker” generates a secret color combination of
n
length n with k colors, m Î [k]
 The “Codebreaker” queries such color combinations,
q Î [k]n
This talk:
Black Peg
 The answer by Codemaker is
 {i : mi = qi }
, depicted by black pegs
Mastermind
 max {i : mi = qp (i) } - {i : mi = qi }
p
, depicted by white pegs
 The goal of Codemaker is to identify m with as few
queries as possible.
secret
What is the minimum number t = t(k,n) of queries
such that there exists a deterministic strategy to
queryidentify every secret color combination?
answer
Henning Thomas
Mastermind
ETH Zurich 2012
Some Known Results & Our Results
 [Knuth ’76], In the original board game (4 slots, 6 colors)
5 queries are optimal.
Henning Thomas
Mastermind
ETH Zurich 2012
Some Known Results & Our Results
 [Knuth ’76], In the original board game (4 slots, 6 colors)
5 queries are optimal.
 [Erdős, Rényi, ’63], Analysis of non-adaptive strategies
for 0-1-Mastermind
In this talk:
1-e
 [Chvátal, ’83], Asymptotically optimal strategy fork £ n
using random queries
 [Goodrich, ’09], Improvement of Chvátals results by a
factor of 2 using deterministic strategy
Our Result:
 Improved bound for k=n by combining Chvátal and
Goodrich
Henning Thomas
Mastermind
ETH Zurich 2012
Lower Bound
 Information theoretic argument:
start
1 leaf
0
n
...
query 1
n leaves
query 2
n2 leaves
query t
nt leaves
n ³k
t
Henning Thomas
n
n logk
Û t ³ log n k =
log n
n
Mastermind
ETH Zurich 2012
Upper Bound (Chvátal)
n/k
 Idea: Ask Random Queries. 0
 Intuition:




n/k
n
n/k
The number of black pegs of a query is Bin(n, 1/k) distributed.
Hence, we ‚learn‘ roughlylog( n / k )
bits per query.
We need to learn n log k bits.
t satisfies
n log k
t log( n / k ) » n log k Û t » (2 + e )
log(n / k)
Henning Thomas
Mastermind
n logk
» C
log n
k=o(n)
ETH Zurich 2012
Comparison Lower Bound vs Chvátal
 The optimal number of queries t satisfies
n logk
n log k
£ t £ (4 + e )
log n
log(n / k)
good if
k=o(n)
 Problem for k=n:
 Non-Adaptive: Learning does not improve during the
game.
 For k=n we expect 1 black peg per query.
 We learn a constant number of bits.
 This yields
n £ t £ O(nlogn)
Henning Thomas
Mastermind
ETH Zurich 2012
Upper Bound (Goodrich)
 Idea:
 Answer “0” is good since we can eliminate one color
from every slot!
Henning Thomas
Mastermind
ETH Zurich 2012
Upper Bound (Goodrich)
 Implementation: Divide and Conquer
1. Ask monochromatic queries for every color.
Obtain Xi = # appearances of color i.
2. Ask
b2
11 ... 1
22 ... 2
b3
11 ... 1
33 ... 3
11 ... 1
kk ... k
11 ... 1
22 ... 2
kk ... k
bk
3. Calculate Li = # appearnace of color i in left half
Ri = # appearnace of color i in right half
k
n
åbi = (k -1)L1 + 2 - (X1 - L1 )
i=2
Henning Thomas
Mastermind
ETH Zurich 2012
Upper Bound (Goodrich)
 Implementation: Divide and Conquer
1. Ask monochromatic queries for every color.
Obtain Xi = # appearances of color i.
2. Ask
b2
11 ... 1
22 ... 2
b3
11 ... 1
33 ... 3
11 ... 1
kk ... k
11 ... 1
22 ... 2
kk ... k
bk
3. Calculate Li = # appearnace of color i in left half
Ri = # appearnace of color i in right half
4. Recurse in the left and right half (without step 1)
 Runtime for k=n:O(k + n logn)
Henning Thomas
Mastermind
ETH Zurich 2012
Comparison Lower Bound vs Goodrich
 For k=n Goodrich yields
n £ t £ O(nlogn)
 Problem:
 When Goodrich runs for a while, the blocks eventually
become too small that we cannot learn as many bits as
we would like to.
Henning Thomas
Mastermind
ETH Zurich 2012
Combining Chvátal and Goodrich
 Goodrich is good at eliminating colors.
 Chvátal is good for k << n.
Idea: 2 phases.
(i) Goodrich
(ii)Chvátal
Henning Thomas
Mastermind
ETH Zurich 2012
Henning Thomas
Mastermind
ETH Zurich 2012
Henning Thomas
Mastermind
ETH Zurich 2012
Download