The project is based on the official Pentago Online Website. It aims to replicate a variation of the online webapp by using the basic numpy package & self-made python functions.
Pentago is a variation of the board game Gomoku instead of GO. It is a 2-player game, consisting of a 6x6 grid with black & white pieces divded into four 3x3 quadrants.
The goal of the game is to be the first player to obtain a row of five or more pieces in any orientation (e.g Vertical, Horizonal, Diagonal) during their turn order.
The turn order plays an important role prior to developing the application. It can be summarised in the table below
| Turn Sequence | Action | Description |
|---|---|---|
| 1 | Placing a piece | The player places his piece on an unoccupied location on the 6x6 board. |
| 2 | Check for victory | Check if any player obtained a row of 5 pieces or more |
| 3 | Rotating a quadrant | The player rotates any quadrant towards a clockwise or anti-clockwise 90 degree direction. |
| 4 | Check for victory | Check if any player obtained a row of 5 pieces or more |
| 5 | Handover | The turn is handed over to the other player. |
The application is only interactable through the command line upon running the start_game.py file using a desired IDE. The user is granted two game-modes, PvP or PvE.
When deciding on the location for users to place their piece, we use a zero-indexed x-y coordinate system combined with a one-indexed rotation direction. The numerical rotation assignment is shown in the diagram below.
Note
For example, if a user would like to place a piece on the 1st row, 2nd column, then rotate the top-right quadrant in a clockwise direction, they will type the sequence of 0, 1, 1
Clicking PvE mode will initiate a game against the algorithm with two difficulties, easy & normal. The player always starts first with the number 1 piece and the computer is second with the number 2 piece.
The easy difficulty causes the computer to randomly pick an unoccupied location on the 6x6 grid. While the normal difficulty brute forces the best move within a two turns to lead to a victory while avoiding a victory for the player.
Important
A victory check is always executed once, after placing a piece, and another time after rotating the quadrant.
It is possible for a rotation to lead to the victory of the opposing player! As such, players must be careful in their choices
The same functions & logic is used as the PvE mode, with the exception that another player will designate the coordinates of the number 2 piece.
There are a few important checks required when a player places their pieces. If any of these fail, the user is prompted to reselect the location of the piece.
| Check Purpose | Methodology |
|---|---|
| Checks if the selected location is occupied by a piece | As empty spaces are designated as zeros, while player pieces are either 1 or 6, a check on the integer value is performed. It fails if the value is not equal to 0 |
| Checks if the coordinate is valid | The number selected by the user must be within the range of 0-5 for coordinates and 1-8 for rotation direction |