A disclaimer: I was being flaky about the two puzzles in Purple Pearl. They are the “find the right combination” type of puzzle. There is a riddle, and it was described more than adequately.
But all the same, it wasn’t the first game where I tried stuff by brute force. And I thought I’d share the code I had.
This snippet of AutoIt code worked for me to run through the dial-spin pretty quickly, pushing F10 to stop the incessant command-writing:
dial puzzle
#include <MsgBoxConstants.au3>
Opt("WinTitleMatchMode", -2)
; Opt("SendKeyDelay", 0)
HotKeySet("{F10}", "MyBail")
WinActivate("Purple Pearl")
WinWaitActive("Purple Pearl")
for $q = 0 to 999
Send("spin dial to ")
Send($q)
Send("{ENTER}")
Next
Func MyBail()
exit
EndFunc
(Note: where I goofed was, I switched what 2 of the numbers should be. I vaguely considered trying the 3 numbers in all 6 orders before actually writing this script, but I somehow talked myself out of it.)
I suspect other games have this too although some have the additional mechanism of having a flag to say, if you didn’t read a certain piece of paper, the safe will never open! But this is at least one way to check for tha. Of course you can change the number. And with some modifications, you could also tweak a safe with, say, numbers from 0 to 5 so it goes a bit faster.
The other puzzle was having 3 switches in down/medium/up position. My solution was
switch puzzle
>push button
>flip 1
>push button
>flip 1
>push button
>flip 2
>push button
>flip 1
>push button
>flip 1
>push button
>flip 2
>push button
>flip 1
>push button
>flip 1
>push button
>flip 3
>push button
>flip 1
>push button
>flip 1
>push button
>flip 2
>push button
>flip 1
>push button
>flip 1
>push button
>flip 2
>push button
>flip 1
>push button
>flip 1
>push button
>flip 2
>push button
>flip 1
>push button
>flip 1
>push button
>flip 3
>push button
>flip 1
>push button
>flip 1
>push button
>flip 2
>push button
>flip 1
>push button
>flip 1
>push button
The point being, at move N, we see how many powers of 3 go into N+1, and we add that to 1, and we have the switch we flip. If you want to, you can use mathematical induction to prove it. For relatively small puzzles you can just use the up arrow a lot and remember what’s there.
Below is python code to show all the text that I didn’t convert to AutoIt because I was lazy and lost my old script. But the idea works, I think.
python code to get all the combos
levers = 4
settings = 3
def powers_into(settings, y):
ret_val = 0
while y % settings == 0:
y /= settings
ret_val += 1
return ret_val
print(">push button")
for x in range(1, settings**levers):
mults = powers_into(settings, x) + 1
print(">flip switch {}".format(mults))
print(">push button")