(define "LightOn" (= 1 (state at:(site)))) (define "FirstButton" (= (last To) 0)) (define "SecondButton" (= (last To) 1)) (define "ToggleLight" (set State at:3 (abs (- (state at:3) 1)))) (define "SwapTwoFirstLights" (swap Pieces 3 4)) (define "SwapTwoLastLights" (swap Pieces 4 5)) //------------------------------------------------------------------------------ (game "Buttons And Lights" (players 1) (equipment { (board (rectangle 2 3)) (piece "Light" Shared) }) (rules (start (place "Light" (sites Top))) (play (move Select (from (sites Bottom)) (then (if ("FirstButton") ("ToggleLight") (if ("SecondButton") ("SwapTwoFirstLights") ("SwapTwoLastLights") ) ) ) ) ) (end { (if (all Sites (sites Top) if:("LightOn")) (result Mover Win)) (if (= 4 (counter)) (result Mover Loss)) }) ) ) //------------------------------------------------------------------------------ (metadata (info { (description "Buttons And Lights is a planning puzzle.") (rules "Three buttons and three lights. The first button toggles the first light. The second button interchanges first and second lights. The third button interchanges the second and third lights. All lights initially off. The goal is to get them all on. The game terminates when all three lights are on or after 6 steps, whichever comes first.") (id "1775") (source "http://ggp.stanford.edu/") (version "1.3.14") (classification "puzzle/planning") (credit "Eric Piette") (date "2005") } ) (graphics { (piece Colour "Light" state:0 fillColour:(colour White)) (piece Colour "Light" state:1 fillColour:(colour Yellow)) (show Symbol "Disc" (sites Bottom) fillColour:(colour Black) scale:0.5) (show Symbol "Disc" (sites Bottom) fillColour:(colour White) scale:0.25) }) (ai "Buttons And Lights_ai" ) )