( Installation of this program requires that a puzzle object have some ) ( action attached to it and linked to this program, and that the object ) ( be described as @ so that looking at it weill trigger the help ) ( facility. ) () : tloc ( -- d ) trigger @ location ; : say ( s -- ) me @ swap notify ; : explode_pop ( x1 .. xX X -- ) begin dup while swap pop 1 - loop pop ; : reset ( -- ) tloc "_posit" "ULLLLL00000" 0 addprop ; : do_install ( -- ) me @ name " installs and resets the puzzle." strcat loc @ #-1 rot notify_except tloc "_01" " " 0 addprop tloc "_02" " " 0 addprop tloc "_03" " " 0 addprop tloc "_04" " " 0 addprop tloc "_05" " " 0 addprop tloc "_U1" " /\\ " 0 addprop tloc "_U2" " //\\\\" 0 addprop tloc "_U3" " \\||/" 0 addprop tloc "_U4" " /||\\" 0 addprop tloc "_U5" " \\/\\/" 0 addprop tloc "_L1" " " 0 addprop tloc "_L2" " /\\/\\" 0 addprop tloc "_L3" "//--/" 0 addprop tloc "_L4" "\\\\--\\" 0 addprop tloc "_L5" " \\/\\/" 0 addprop reset ; : do_look ( -- ) 1 = not if tloc "_posit" getpropstr "" "0" subst "<" "L" subst "^" "U" subst "Now: " swap strcat say else "The knobs currently look like:" say " ___________________________________" say 1 begin dup 6 < while "" 1 begin dup 12 < while tloc "_posit" getpropstr over strcut pop over 1 - strcut swap pop tloc "_" rot strcat 5 pick intostr strcat getpropstr rot swap strcat swap 1 + loop pop "|" swap strcat over 1 = if 36 strcut pop "\\___________________" strcat then over 1 > if "|" strcat then say 1 + loop pop " ~~~~~~~~~~~~~~~~~~~~~~~~~\\____/~~~~~~~~~~~~~~~~~~~~~~~~" say " 1 2 3 4 5 6" say then ; : do_move ( s -- i ) atoi tloc "_posit" getpropstr "" "0" subst over 5 < if dup 3 pick 1 + strcut swap pop "U" instr if "Knob " rot intostr strcat " can't turn because " strcat "knob " strcat swap "U" rinstr intostr strcat " is pointing up." strcat say 1 do_look 0 exit then then over 6 = not if dup 3 pick strcut swap pop "L" 1 strncmp not if pop "Knob " over intostr strcat " is held in place by knob " strcat swap 1 + intostr strcat "." strcat say 1 do_look 0 exit then then dup 3 pick strcut swap 4 pick 1 - strcut dup "L" stringcmp not if pop "U" else pop "L" then strcat swap strcat swap pop "00000" rot 1 - strcut pop strcat "00000" over strlen 11 swap - strcut pop swap strcat tloc "_posit" rot 0 addprop 1 ; : do_winner ( -- ) "You solved the puzzle!" say me @ name " solved the puzzle!" strcat loc @ me @ rot notify_except prog me @ intostr getpropstr not if "Your first solution! You get $250!" say me @ name " gets $250 for %p first time solution!" strcat me @ swap pronoun_sub loc @ me @ rot notify_except me @ 250 addpennies prog me @ intostr systime intostr 0 addprop then "The puzzle automagically resets." loc @ #-1 rot notify_except reset ; : do_turn ( s -- ) "" " " subst "" explode dup 1 = if "a knob." else "a few knobs." then me @ name " turns " strcat swap strcat loc @ me @ rot notify_except begin dup while over atoi dup 0 > swap 7 < and if over do_move not if explode_pop exit else dup do_look then then swap pop 1 - loop pop tloc "_posit" getpropstr "LLLLLL" instr if do_winner then ; : do_help "+----------------------------------------------------+" say "| SPINOUT PUZZLE V1.10, written by Sjade of HoloMUCK |" say "| Original concept implemented by Albedo of LustyMUD |" say "+----------------------------------------------------+" say "| The object of the puzzle is simple: Get all six |" say "| knobs pointing to the left. Getting them there is |" say "| perhaps not as simple. You turn the knobs so they |" say "| are either up or left within the following guide- |" say "| lines. A knob may only be turned at position 6. |" say "| If the rack of knobs can't be slid far enough to |" say "| the right because knobs are pointing up, then you |" say "| may not be able to get a certain knob to position |" say "| 6 in order to turn it. Also, the knob immediately |" say "| to the left of a knob pointing left is locked in |" say "| position and cannot be turned, even if it is able |" say "| to reach position 6. You may turn one knob at a |" say "| time or many at once. For example, you may either |" say "| 'turn 4' or 'turn 1342312'. If in a long sequence |" say "| the puzzle finds a bad move, all subsequent moves |" say "| will be erased. The position of the knobs is dis- |" say "| played after each move, or can be looked at if you |" say "| use 'look at knobs'. Use the numbers of the knobs |" say "| you want to turn, not their position on the board. |" say "+----------------------------------------------------+" say ; : main ( s -- ) trigger @ thing? if pop do_help exit then trigger @ name tolower "at" instr if pop 1 do_look exit then trigger @ name tolower "install" instr if pop do_install exit then trigger @ name tolower "turn" instr if do_turn exit then ;