(define "NumNonEmptySitesBetween" (= 0 (count Sites in:(intersection (difference (sites Occupied by:All) (sites {#1 #2})) (forEach (union (sites #3 (#4 of:#1)) (sites #3 (#4 of:#2))) if:#5 ) ) ) ) ) (define "IsEmptyLine" (if (> (#3 of:#1) (#3 of:#2)) ("NumNonEmptySitesBetween" #1 #2 #4 #5 (and (<= (#3 of:(site)) (#3 of:#1)) (>= (#3 of:(site)) (#3 of:#2)) ) ) ("NumNonEmptySitesBetween" #1 #2 #4 #5 (and (<= (#3 of:(site)) (#3 of:#2)) (>= (#3 of:(site)) (#3 of:#1)) ) ) ) ) (define "IsEmptyRectangle" ("IsEmptyLine" #1 #2 column Row row) ("IsEmptyLine" #1 #2 row Column column) ) //------------------------------------------------------------------------------ (game "BoxOff" (players 1) (equipment { (board (rectangle 6 8)) (piece "Disc1" P1) (piece "Disc2" P1) (piece "Disc3" P1) }) (rules (start { (place Random {"Disc1"} count:16) (place Random {"Disc2"} count:16) (place Random {"Disc3"} count:16) }) (play (move Select (from (sites Occupied by:All)) (to (difference (sites Occupied by:All) (from)) if:(and { (= (what at:(from)) (what at:(to))) ("IsEmptyRectangle" (from) (to)) }) ) (then (and (remove (last From)) (remove (last To)))) ) ) (end { (if (no Pieces Mover) (result Mover Win)) (if (no Moves Mover) (result Mover Loss)) }) ) ) //------------------------------------------------------------------------------ (metadata (info { (description "Steven Meyers' BoxOff has the feel of a classic solitaire abstract game. Brightly coloured pieces are distributed on a rectangular grid of squares and removed in pairs of like colour until the board is empty. ") (rules "Start: The game starts with a piece in each cell, which defines the challenge to be solved. Play: The player then makes a series of moves, each involving the removal of a pair of same-coloured pieces that occupy a box (rectangle) that includes no other pieces of any colour. End: The player wins by removing all pieces from the board. Conversely, the player loses if there are no legal moves at any point while pieces remain on the board.") (id "974") (source "www.abstractgames.org") (version "1.3.14") (classification "puzzle/planning") (author "Steven Meyers") (publisher "Google Play") (credit "Eric Piette") (date "01-2013") } ) (graphics { (piece Colour "Disc1" fillColour:(colour White)) (piece Colour "Disc2" fillColour:(colour Black)) (piece Colour "Disc3" fillColour:(colour Grey)) }) (ai "BoxOff_ai" ) )