A little game I was playing around with making to just give my little grand-niece something to waste time on when she comes to visit.
Dim Shared f
, f1
, lastsolved
, guess
(10), guesses
f1
= _LoadFont("courbd.ttf", 32, "monospace")
n$ = GetNum(5)
guess$ = "": wheel = 0: Xon = 0
DrawLock guess$, n$
If y
> 105 And y
< 195 Then 'we're on the proper spot to be in the combination area Xon
= Int((X
- 105) / (300 / Len(n$
)) + 1) 'this is the tumbler we're on guess(Xon) = guess(Xon) + wheel
If guess
(Xon
) > 9 Then guess
(Xon
) = 0 If guess
(Xon
) < 0 Then guess
(Xon
) = 9 If y
> 205 And y
< 295 Then 'in the solved row lastsolved = 0: guesses = guesses + 1
If Asc(guess$
, i
) = Asc(n$
, i
) Then lastsolved
= lastsolved
+ 1 oldmouse = mb: oldmouse2 = mb2
Print "YAY! You got it in"; lastsolved;
"tries!"
Sub DrawLock
(guess$
, num$
) s = 300 / size
Line (100, 100)-(400, 200), SlateGray
, BF
Line (100, 100)-(400, 300), SlateGray
, BF
Line (105, 105)-(395, 195), LightGray
, BF
Line (105, 205)-(395, 295), Green
, BF
Line (100 + i
* s
, 100)-Step(5, 100), SlateGray
, BF
This should be easy enough to figure out:
Use the mouse wheel or the buttons to increase or decrease the values of a tumbler.
Click in the green area to make a guess and see how many numbers you got correct out of your attempt.
Match the actual combination and win!
At this point, this only runs through the creation and puzzle process a single time, for a single 5-digit combination lock. I suppose all it really needs at this point to become a "replayable game" is to offer an option to select difficulty (it can generate anywhere up to 9-digit locks for increased difficulty), and then an option to replay/quit again afterwards -- but that's a simple enough mod for another day, when I have a little more free time again.
Now the question is: How fast can someone solve these type of puzzles? What's the best strategy to get to the win in the least possible number of moves normally?
Randomly type in a number and you *could* get it in one guess, but where's the logic in that?
Type in each number one at a time, click to check, and you're guaranteed to get the solution in 10 * wordlength guesses.
Type in all 5 digits the same, and you can eliminate a whole number from your guess each time. (For example guess five zeros 00000, find out that there's no matches, you've now dropped the possible data pool down to only using numbers 1 to 9. Do it for each of the numbers from 0 to 10, and you've eliminated half the puzzle in 10 guesses, as your 5 digit number can't hold 10 different values!)
Now that I've came up with the little problem to create the puzzles, I'm now left pondering on what might be the best solution for an AI to use to guess the puzzle in the fewest amount of tries possible. Anyone have any thoughts on a surefire Code Breaker solution routine with the fewest possible attempts usually?
I may end up trying to incorporate some sort of competition where a player tries to compete against the computer to shoot for the answer first, so various ideas for AI attempts could be written into the game as different opponents to try your luck against. Suzy might just try random numbers. Jane might do the meticulous one by one approach. Fred might do an elimination approach to solving. Anybody have any other methods to attempt for an AI?