Post Reply 
(11C) Code guessing game
04-30-2018, 08:11 AM (This post was last modified: 04-30-2018 08:55 AM by Dieter.)
Post: #13
RE: (11C) Code guessing game
(04-29-2018 09:58 PM)Rogier Wrote:  I compare each digit of the code to the last digit of the guess, then I divide the guess by 10 and repeat the procedure until the guess is all sliced up.

OK, this makes sense – let's do this for the example:

(04-29-2018 09:58 PM)Rogier Wrote:  The scores I quoted are correct (at least: as intended within the parameters of the program):
Code = 451
Guess = 112 > 2,0 Two digits correct, not in the right place
Guess = 111 > 3,1 All correct, one in the right place

Take the last digit of the guess, 1. Compare it with the code from right to left:
1: correct and in the right place => +0,1
5: no match
4: no match

Slice off the rightmost digit, so the remaining guess is 11.

Take the last digit of the guess, 1. Compare it with the code from right to left:
1: correct, but in wrong place => +1,0
5: no match
4: no match

Slice off the rightmost digit, so the remaining guess is 1.

Take the last digit of the guess, 1. Compare it with the code from right to left:
1: correct, but in wrong place => +1,0
5: no match
4: no match

Slice off the rightmost digit, so the remaining guess is 0 => scoring completed.
Score is 0,1 + 1,0 + 1,0 = 2,1

You say you get 3,1. So the three guess digit gets four (!) scores. On a real Mastermind board you this would be equivalent to 3 white pegs and 1 black one. The correctly positioned "1" gets two (!) ratings: both a black one and a white one.

So the rightmost 1 in the code is evaluated this way:

Take the last digit of the guess, 1. Compare it with the code from right to left:
1: correct (is part of the code) => +1,0
furthermore it also is in the right place => +0,1
5: no match
4: no match

(04-29-2018 09:58 PM)Rogier Wrote:  If the code were 333, a guess of 333 should score 3,3; 3 digits correct, all of which in the right place.

OK, so again the 3 guess digits are rated twice:
Once for the right digit being somewhere in the code, and another time for it being in the right position. If this is your intention the score is fine. But I wonder if it matches the Mastermind rules.

(04-29-2018 09:58 PM)Rogier Wrote:  You never see that, but entering 3333 yields 4,3. (I don't check for the right length when you enter a guess. Would be relatively easy to fix of course.)
I'll have to adapt your program by the way Sto/,0 doesn't work on an HP-11c.

I suspected this (my good old 34C didn't allow storage arithmetics on R,0...R,9 either). Actually I wrote the program on a 15C emulator. #-)

You may simply swap R,0 and R7. I now have edited the original listing. Thank you very much for this hint.

(04-29-2018 09:58 PM)Rogier Wrote:  Pier4r: I have thought about reversing the roles and let the calculator guess, but gave up on it. Not a chance of fitting it in an HP-11c, and too complex (at least for me) to program it in my ZX-Spectrum or in GW-basic.

Back in the days I have been thinking about such a program either, but even if it could have been done on a more powerful calculator like the 41C I admit my skills were (and still are) too limited for such a project.

Dieter
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



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