Oware

Oware is a two-player strategy game played with forty-eight identical game pieces, called “seeds”, and a board with twelve seed compartments, called “houses”, arranged into two rows of six, like the cells of an egg carton. The board represents a circular chain of twelve houses, where the neighboring ends of the rows are linked.

The board also has a “score house” at each end for storing seeds removed from play.

The players face opposite sides of the board, each controlling the houses of the row nearest to them and the score house to their right.

The game starts with four seeds in each house. After arbitrarily selecting who plays first, the players alternate moves. To move, a player “collects”, “sows”, and possibly “captures” seeds.

To collect, a player removes the full contents of a nonempty house in their row, rendering that “source house” empty.

To sow, a player drops one of the collected seeds into each house along a contiguous counterclockwise path around the board, starting with the house neighboring the source house. If the player has enough seeds to loop around the board, the source house is skipped, keeping it empty after sowing.

While sowing, if the final seed drops into an opponent’s house and the drop increases that house’s seed count to two or three, then the player captures all seeds in that house. The captured seeds are placed into the player’s score house, permanently removing them from play.

After capturing a house, the player inspects the previously sown house (the neighbor in the clockwise direction). If it's also an opponent’s house and it also contains exactly two or three seeds, then the player captures those seeds as well. That process is repeated until the player arrives at a house not belonging to the opponent or at a house not containing exactly two or three seeds.

However, after sowing and before capturing, the player verifies that capturing would leave at least one seed in the opponent’s row, enabling the opponent to make the successive move. If that is not the case, then the player forfeits capturing, leaving the sown seeds in place.

Similarly, before collecting, if the opponent’s row is completely empty, the player must make a move that leaves at least one seed in the opponent’s row. If no such move exists, then the player captures all seeds in their row, ending the game.

If a position repeats three times, and it is a position with at least one seed in both rows, and the same player moved into the position all three times (though not necessarily by making identical moves), then the game automatically ends due to lack of progress. In that situation, each player captures all seeds in their row.

A player wins by capturing twenty-five or more seeds. If both players end up with twenty-four seeds, then it’s a draw.

This implementation of Oware offers nineteen difficulty levels against an AI opponent. It indicates a win by rendering a circle under the victor’s score house, and a draw by rendering a semicircle under both score houses. Before those outcomes, it renders a rectangle beneath the score house of a player that can force a win, or rectangles beneath both players’ score houses if a player can force a draw.