Post Reply 
(11C) Code guessing game
05-31-2020, 07:43 PM
Post: #18
RE: (11C) Code guessing game
(07-23-2018 01:14 AM)Thomas Klemm Wrote:  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.
...

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

I read with interest all your interventions in all your posts for this thread.
Thanks for the link, Thomas Klemm.

So, I propose to everyone, the program I wrote for the HP11C.

Be assured, this is one of my achievements that I did not do in one step. This program indeed required several phases spread over several calculators. One of my last versions, among the most successful, was intended for the HP12C and works without the use of the indirect addressing mode on the registers.

I note with pleasure (and I reassure myself) by noting that my successive versions were indeed in accordance with the principles formulated in the document published by Donald E. Knuth.

So, this version gives the possibility to choose the size of the code to find (4 or 5 digits, for example) and the number of distinct colors that can be used (from 1 to 9) to compose the code.

Here is how to use it :

On LBL A, you choose the number of digits in the code : 4 or 5
On LBL B, you give the number of colors : 6 or 9
On LBL C, you enter the number of authorized trials before the calculator reveals the code if you have not yet discovered it (usually 6 or 12, but personally I choose 99)

Compose GSB D to prepare the code
Key in 4 or 5 digits and press GSB E (or R/S) to examine a proposition

The return format is c1c2c3c4c5.BW where c1c2c3c4c5 is your try, B the number of Black positions and W the number of White positions

Code:

001 -  f  LBL  E
002 -  STO  2
003 -  STO  4
004 -  EEX
005 -  STO + 0
006 -  GSB  C
007 -  RCL  0
008 -  f  x > y
009 -  GTO  6
010 -  g  CLx 
011 -  STO  7
012 -  STO  8
013 -  RCL  1
014 -  STO  3
015 -  GSB  A
016 -  10^x
017 -  STO ÷ 3
018 -  STO ÷ 4
019 -  f  LBL  1
020 -  RCL  4
021 -  g  x = 0
022 -  GTO  2
023 -  RCL  5
024 -  STO x 3
025 -  STO x 4
026 -  RCL  3
027 -  g  INT
028 -  STO - 3
029 -  RCL  4
030 -  g  INT
031 -  STO - 4
032 -  f  x = y
033 -  GTO  3
034 -  10^x
035 -  STO + 8
036 -  x ↔ y
037 -  10^x
038 -  STO + 7
039 -  GTO  1
040 -  f  LBL  3
041 -  RCL  5
042 -  1/x
043 -  STO + 2
044 -  GTO  1
045 -  f  LBL  2
046 -  GSB  B
047 -  STO  I  
048 -  10^x
049 -  STO ÷ 7
050 -  STO ÷ 8
051 -  f  LBL  5
052 -  RCL  7
053 -  g  INT
054 -  STO - 7
055 -  RCL 8
056 -  g  INT
057 -  STO - 8
058 -  f  x > y
059 -  x ↔ y
060 -  RCL  5
061 -  STO x 7
062 -  STO x 8
063 -  g  x^2
064 -  1/x
065 -  x
066 -  STO + 2
067 -  f  DSE
068 -  GTO  5
069 -  RCL  0
070 -  RCL  2
071 -  g  RTN
072 -  f  LBL  6
073 -  RCL  1
074 -  RCL  0
075 -  EEX
076 -  4
077 -  ÷
078 -  +
079 -  CHS
080 -  f  FIX  4
081 -  g  RTN
082 -  f  LBL  D
083 -  f  FIX  2
084 -  f  CLEAR  Σ
085 -  GSB  A
086 -  STO  I  
087 -  f  LBL  0
088 -  EEX
089 -  1
090 -  STO  5
091 -  STO  x  1
092 -  GSB  B
093 -  f  RAN#
094 -  x
095 -  EEX
096 -  +
097 -  g  INT
098 -  STO + 1
099 -  g  CLx
100 -  f  DSE
101 -  GTO  0
102 -  x
103 -  f  LBL  A
104 -  5
105 -  g  RTN
106 -  f  LBL  B
107 -  9
108 -  g  RTN
109 -  f  LBL  C
110 -  1
111 -  2
112 -  g  RTN

P-00  r- ,2
112 lines


Example of use :

0.123 STO f RAN#
GSB D
--> 5.00

(see RCL 1 with 26829)

22689 R/S (or GSB E)
--> 22689.23

22222 R/S
--> 22222.20

26829 R/S
--> 26829.50
x ↔ y
--> 3.00 so you win in 3 tries !!
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 - Nihotte(lma) - 05-31-2020 07:43 PM



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