# Help With COMP30024,Help With Java/Python Programming

Rules for the Game of Cachex
COMP30024 Artificial Intelligence
2022
Cachex is a two-player connection game of strategy, anticipation and sabotage. Establish efficient
territorial control by construction of geometric patterns while sabotaging the best laid plans of your
opponent. Defeat your opponent’s territorial intrusions and unite patterns to victory!
Overview
Cachex is a perfect-information two-player game played on an n × n rhombic, hexagonally tiled
board, based on the strategy game Hex. Two players (named Red and Blue) compete, with the
goal to form a connection between the opposing sides of the board corresponding to their respective
color.
Figure 1: Example board with winning connection for Blue.
1
Gameplay
• The game begins with an empty board and proceeds sequentially.
• By convention, Red starts. Throughout the game Red and Blue take turns placing stones on
empty hexagonal cells (hexes).
• The game ends when one player forms an unbroken chain of stones on adjacent hexes between
their respective sides; this player wins the game. The hexes at each of the four corners belong
to both players.
• Pairs of tokens may be removed from the game through a capture mechanism (Figures 3 and
4). If a 2 × 2 symmetric1 diamond of cells is formed consisting of two stones from Red and
Blue each, the player who completed the diamond removes their opponent’s stones from the
game. Note that:
– Either player may exploit the capture rule, and the capture rule applies for all possible
orientations of the diamond found on the gameboard.
– The capture mechanism only applies to a diamond formed by 2 Red and 2 Blue stones -
it does not apply if there are three of one color and one of the other.
– If multiple diamonds of valid type are formed by placement of a single stone on the
board, all of the opponent’s stones in the just-formed diamonds are removed from the
board.
– After a capture, the opposing party can immediately threaten a re-capture by placing a
piece on one of the recently-captured positions.
• To mitigate first-mover advantage, the swap rule applies (Figure 2). Once Red completes their
first move, Blue may choose to proceed as normal and lay down a blue stone, or steal Red’s
move for their own, reflecting the position of Red’s stone along the major axis of symmetry
(i.e. interchanging the row and column index) and changing the stone from red to blue. The
game proceeds as normal, with Red playing next. The swap rule incentivizes the first player
to play as fair a move as possible - if the first move is too strong, the second player is able to
. For fairness, starting with a hex in the center of the board is illegal.
Like Hex, assuming both players play to win, Cachex can never end in a draw3
. The only surefire
way to block your opponent’s construction of a winning unbroken connection is by making your
own unbroken connection. Hence defence is almost synonymous with offense in this game - however
note that the capture mechanism opens the possibility of sabotaging your opponent’s attempts to
construct a chain...
1This refers to the axes of symmetry of the diamond which connect opposing vertices.
2
If this confuses you, consider how to fairly divide a cake between two people. The first mover chooses the dividing
cut. The second mover chooses which slice to take.
3Barring pathological cases associated with the capture mechanism where both sides collude to draw. Here we
assume everyone wants to win.
© - University of Melbourne, 2022 2
Figure 2: Example application of the swap rule on a 5 × 5 board. First-mover Red places a stone
at d2, which gets stolen by Blue and reflected along the axis of symmetry to the blue token at b4.
It is forbidden to place the first stone in the centre.
→ →
Figure 3: Diamond capture mechanism, Version 1. Red places a stone in the leftmost hex, forming
a symmetric diamond. This removes Blue’s two tokens in the just-formed diamond from the board.
Note the rule also applies for Red and Blue interchanged from the colors in the figure.
A good way to gain familiarity for the game is through manual practice. An example gameboard
is attached at the end of this document. You can use pen/pencil, Go stones, or colored chocolate
confectionery as pieces.
Ending the Game
The game ends when one of the following conditions is met (if multiple are met, use the first in
this list). As draws are only possible with cooperative pathological play (e.g. repeated cycles of
captures), teams are mildly penalized for a draw.
1. One player successfully constructs an unbroken chain of stones placed in adjacent hexes connecting
opposite sides of their color. Declare that player the winner.
2. The same game configuration (with the same hexes occupied by the same players) occurs for
the seventh time since the start of the game (not necessarily in succession). Declare a draw.
© - University of Melbourne, 2022 3
→ →
Figure 4: Diamond capture mechanism, Version 2. Blue places a stone in the topmost hex, forming
a symmetric diamond. This removes Red’s two tokens in the just-formed diamond from the board.
Note the rule also applies for Red and Blue interchanged from the colors in the figure.
3. The players have had their 343rd turn without a winner being declared. Declare a draw (no
penalty in this case).
© - University of Melbourne, 2022 4
© - University of Melbourne, 2022 5