// Hexifact //--------------------------------------------- (define "GridDirection" ) (define "ScoreMover" (do (and { (remember Value 0) (remember Value 0) (forEach Group "GridDirection" // if:(is Mover (who at:(to))) // this appears to be the default, and it ceases to work when the boolean is included. (remember Value (count Sites in:(sites))) ) }) next:(set Var "TopValue" (max (values Remembered)) (then (forget Value (max (values Remembered)) (then (set Score Mover (* (var "TopValue") (max (values Remembered))) (then (forget Value All) ) ) ) ) ) ) ) ) (define "PlacementSites" (and (no Pieces Mover in:(sites Around (to) "GridDirection")) (not (no Pieces Next in:(sites Around (to) "GridDirection"))) ) ) //----------------------------------------------- // Main routine (game "Hexifact" (players 2) (equipment { (board use:Vertex) (piece "Disc" Each) }) (rules (play (or { (move Add (piece (id "Disc" Mover)) (to (sites Empty) if:(or ("PlacementSites") (= -1 (counter)) )) (then (forEach Site (sites Occupied by:Mover) (set State at:(site) 0) ) ) ) (if (do (forEach Piece (move Hop (from if:(= 0 (state at:(from)))) "GridDirection" (between (range 1 Infinity) if:(is In (between) (sites Occupied by:Next))) (to if:(is In (to) (sites Empty))) (then (set State at:(last To) 1)) ) Mover ) ifAfterwards:(all Sites (sites Occupied by:Mover) if:(> 4 (count Pieces Mover in:(sites Around (site) "GridDirection"))) ) ) ) (move Pass) // without this there are obscure forced moves... } (then ("ScoreMover")) ) ) (end (if (all Passed) { (if (>= (score Mover) (score Next)) (result Mover Win) ) } (result Next Win) ) ) ) ) //------------------------------------------------- // Options (define "GridDirection" ) (option "Board" args:{ } { (item "Hex 3,4 - tactical AI" <(tri Limping 3)> "Order 3-4, Hex Grid")** (item "Hex 4 - tactical AI" <(tri Hexagon 4)> "Order 4, Hex Grid") (item "Hex 4,5* - tactical AI" <(tri Limping 4)> "Order 4-5, Hex Grid") (item "Hex 5" <(tri Hexagon 5)> "Order 5, Hex Grid") (item "Hex 5,6 - tactical AI" <(tri Limping 5)> "Order 5-6, Hex Grid") } ) (option "Jumping limits" args:{} { (item "Turn After Placing" <(no Pieces Mover in:(sites State 1))> "Jumping is only allowed if a player made a placement on the last turn")** (item "One Jump per Stone" "A given stone may only jump once before the next placement turn is taken.") } ) //--------------------------------------------- (metadata (info { (description "Hexifact is a Hex grid based place-or-jump game with a goal of maximizing the product of one's largest 2 groups. It is fairly opaque, and thus suited to small boards. Large boards will work, but the games will be long, and it will be unclear how the outcome was derived from the earlier positions. The reason for the opacity is that connection of groups must be accomplished through jumping opponent's pieces, which themselves are frequently changing position. To minimise this instability, no location on the board is allowed to have more than 3 adjacent friendly pieces. Also passing is allowed to avoid forced moves that de-optimise the scores. Also, the standard version only allows a jump if the player made a placement on the previous turn. This significantly reduced the game complexity compared to allowing each piece to move once before the next placement turn.") (rules "Goal:Score the product of the sizes of your two largest groups. Highest score wins. In case of a tie, the last to play wins. Groups are based on the orthogonal connections between adjacent pieces. Play: Boards starts empty. The darker color starts by placing anywhere. Thereafter, a turn is either a placement or a jump (but not both) according to the following rules. There are no captures. Passing is allowed. Placement: Pieces must be placed on an empty site that is BOTH: - next to an opponent's stone(s) and - away from one's own stones. Jumping: Jumping is only allowed when a placement was made on the mover's last turn (but see Options) A stone jumps in a straight line over any number of opponent's stones. Jump Restrictions: 1) The piece must land at an empty site that is directly after the last opponent's piece in the jump. 2) The stone may not pass over empty sites nor over sites occupied by friendly stones. 3) The stone may not connect more than 3 of a player's stones, nor cause another stone to be connected to more than 3. The game ends when both players pass. Available Options - Jumps: No individual piece may jump more than once before the mover takes a placement turn.") (id "1968") (version "1.3.12") (classification "experimental") (author "Dale W. Walton") (credit "Dale W. Walton") (date "06-04-2022") } ) (graphics { (player Colour P1 (colour 229 92 0)) (player Colour P2 (colour Cream)) (board Style Graph) (board StyleThickness InnerEdges .2) (board StyleThickness OuterEdges .2) (board StyleThickness InnerVertices .5) (show Edges Diagonal ) (piece Foreground "Disc" state:1 image:"square.svg" fillColour:(colour 0 0 0 50) scale:0.4) } ) (ai "Hexifact_ai" ) )