//------------------------------------------------------------------------- // Single pawn moves. //------------------------------------------------------------------------- (define "StepToEmptyForwards" ("StepToEmpty" (directions Forwards of:All))) (define "StepCapture" ("StepToEnemy" (directions {Forwards Rightward Leftward} of:All))) (define "EnemyAround" (not (all Sites (sites Around (from) All) if:(not ("IsEnemyAt" (site))) ) ) ) (define "RetreatMove" (if ("EnemyAround") (move Hop (directions Backwards of:All) (between if:(is Empty (between)) ) (to if:(is Empty (to))) ) ) ) //------------------------------------------------------------------------- // Cannon moves. //------------------------------------------------------------------------- (define "CannonMove" (move Hop All (between (exact 2) if:("IsPieceAt" "Pawn" Mover (between)) ) (to if:(is Empty (to)) ) ) ) (define "AheadSite" (ahead (from) #1 (directions Vertex from:(from) to:(to)))) (define "IsCannon" (and ("IsPieceAt" "Pawn" Mover (to)) ("IsPieceAt" "Pawn" Mover ("AheadSite" steps:2)) ) ) (define "CannonShoot" (forEach Direction All (if (and { ("IsCannon") (is Empty ("AheadSite" steps:3)) }) (if ("IsEnemyAt" ("AheadSite" steps:4)) (move Remove ("AheadSite" steps:4)) (if (and (is Empty ("AheadSite" steps:4)) ("IsEnemyAt" ("AheadSite" steps:5)) ) (move Remove ("AheadSite" steps:5)) ) ) ) ) ) //------------------------------------------------------------------------- (game "Cannon" ("TwoPlayersNorthSouth") (equipment { (board (square 10) use:Vertex) (piece "Pawn" Each (or { ("StepToEmptyForwards") ("StepCapture") ("RetreatMove") ("CannonMove") ("CannonShoot") }) ) (piece "Town" Each) (hand Each) (regions "Home" P1 (sites Bottom)) (regions "Home" P2 (sites Top)) }) (rules (start { (place "Town" "Hand") (place "Pawn1" (forEach (difference (expand (sites Row 2)) (sites Right)) if:(is Even (column of:(site))))) (place "Pawn2" (forEach (difference (expand (sites Row 7)) (sites Left)) if:(is Odd (column of:(site))))) }) phases:{ (phase "Placing" (play (move (from (handSite Mover)) (to (difference (sites Mover "Home") (sites Corners))) ) ) (nextPhase Mover "Moving") ) (phase "Moving" (play (forEach Piece)) (end (if (or ("IsOffBoard" (where "Town" Next)) (no Moves Next) ) (result Mover Win) ) ) ) } ) ) //------------------------------------------------------------------------------ (metadata (info { (description "Cannon is a two-player board game invented in 2003 by David E. Whitcher.") (rules "The objective of Cannon is to capture or shoot the opponent's Town. The player also wins the game if his opponent doesn't have legal moves. Players move alternately. On their first turns both players put a special piece called \"Town\" anywhere on the rows closest to them excluding corners. Once placed, Towns don't move during the entire game. A soldier may move one step forward or diagonally forward to an adjacent empty point. A soldier may capture an enemy piece (a soldier or the Town) standing on an adjacent point by moving one step sideways, forward or diagonally forward. A soldier can retreat two points backwards or diagonally backwards if it is adjacent to an enemy soldier and if the target and intermediate spots are empty. Cannon is a (orthogonal or diagonal) line of 3 adjacent friendly soldiers. A cannon may slide along its line in either direction if the target spot is empty. A cannon may make a capture without sliding, i.e. to \"shoot\" an enemy piece (either a soldier or the Town) standing on the same line as the shooting cannon if there is one or two empty points between the cannon's front soldier and the enemy piece.") (id "1927") (source "www.iggamecenter.com") (version "1.3.12") (classification "board/war/replacement/eliminate/target") (author "David E. Whitcher") (credit "Eric Piette") (date "2003") } ) (graphics { (board Style Board) (board Colour Phase0 (colour 255 230 150)) (board Colour InnerEdges (colour 160 140 100)) (board Colour OuterEdges (colour 0 0 0)) (player Colour P1 (colour White)) (player Colour P2 (colour Red)) }) (ai "Cannon_ai" ) )