Post Reply 
(11C) Code guessing game
07-23-2018, 01:14 AM
Post: #16
RE: (11C) Code guessing game
This program is based on Donald Knuth's paper The Computer as Master Mind.
It works only with 4 digits and the 6 colours 0-5.

The following formula to count the total number of misses is used:
\[ \max(n_1-n_1', 0)+\max(n_2-n_2', 0)+\ldots+\max(n_6-n_6', 0) \]
From this value the number of "black hits" is subtracted to get the number of "white hits".

Usage

Generate Code

[B]

Check Test Pattern

1 ENTER
2 ENTER
3 ENTER
4 [A]


Result

1.2

Code:
LBL A
STO .0  R↓
STO .1  R↓
STO .2  R↓
ST0 .3
CL∑
1
RCL 6  GSB 0
RCL 7  GSB 0
RCL 8  GSB 0
RCL 9  GSB 0
CHS
RCL .0  GSB 0
RCL .1  GSB 0
RCL .2  GSB 0
RCL .3  GSB 0
4
RCL 0  GSB 1
RCL 1  GSB 1
RCL 2  GSB 1
RCL 3  GSB 1
RCL 4  GSB 1
RCL 5  GSB 1
0
RCL 6  RCL .0  GSB 2
RCL 7  RCL .1  GSB 2
RCL 8  RCL .2  GSB 2
RCL 9  RCL .3  GSB 2
-
LSTx
x<>y
10
÷
+
RTN
LBL 0
STO I
R↓
STO+ (i)
RTN
LBL 1
x<0
CLx
-
RTN
LBL 2
x=y
GTO 3
R↓
R↓
RTN
LBL 3
R↓
R↓
1
+
RTN
LBL B
GSB 4  STO 6  CLx
GSB 4  STO 7  CLx
GSB 4  STO 8  CLx
GSB 4  STO 9  CLx
RTN
LBL 4
RAN#
6
×
INT
RTN

Well, not half as fancy as Dieter's solution but maybe you find the approach still interesting.

(04-28-2018 07:23 PM)pier4r Wrote:  Did anyone create some "computer opponent" on calculators for the game? So an heuristic search for solutions.

Not sure if that's what you are looking for but in the linked paper Donald Knuth proves that the codebreaker can always succeed in five moves or less.

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(11C) Code guessing game - Rogier - 04-25-2018, 06:18 PM
RE: (11C) Code guessing game - Dieter - 04-26-2018, 06:57 PM
RE: (11C) Code guessing game - Rogier - 04-26-2018, 10:10 PM
RE: (11C) Code guessing game - Dieter - 04-27-2018, 06:54 AM
RE: (11C) Code guessing game - Dieter - 04-27-2018, 12:52 PM
RE: (11C) Code guessing game - Rogier - 04-28-2018, 12:24 PM
RE: (11C) Code guessing game - Dieter - 04-29-2018, 09:00 PM
RE: (11C) Code guessing game - pier4r - 04-28-2018, 07:23 PM
RE: (11C) Code guessing game - Rogier - 04-29-2018, 09:58 PM
RE: (11C) Code guessing game - Dieter - 04-30-2018, 08:11 AM
RE: (11C) Code guessing game - Rogier - 04-30-2018, 07:29 PM
RE: (11C) Code guessing game - SlideRule - 07-23-2018, 03:22 PM
RE: (11C) Code guessing game - Rogier - 05-02-2018, 06:49 PM
RE: (11C) Code guessing game - Thomas Klemm - 07-23-2018 01:14 AM



User(s) browsing this thread: 1 Guest(s)