This project extends a python game (Twixt) I wrote previously by adding network play to it. I implmented this to learn how simple networking works with python
Twixt is played on a board comprising a 24×24 square grid of holes (minus 4 corner holes). The game has two types of playing pieces, pegs, which fit into the holes, and links, which fit into the top of the peg pieces and are used to connect to peg pieces. In the 3M edition, players are Red and Black; different sets may use different colors. The topmost and bottommost rows of holes belong to the lighter color; the leftmost and rightmost rows to the darker color.
- The players take turns placing pegs of their respective colors on the board, one peg per turn.
- The player with the lighter color makes the first move.
- A player may not place a peg on their opponent's border rows.
- After placing a peg, a player may link one or more pairs of pegs on the board of their color. The links can only connect two pegs a knight's move away from each other, and cannot cross another link; they block other links, most importantly those of the opponent. As part of the player's move, they may remove their own links (but not those of the opponent) in order to rearrange the sequence of links on the board.
- The object is to make a continuous chain of linked pegs connecting the player's border rows. If neither player can achieve this, the game is a draw.
This network implementation uses client/server, over TCP port 9999. The format of the message is two integer values, x and y coordinates for a succesful mouse click
- VS Code and Python 3.9 were used to code and build.
- The original game uses RayLib for drawing, and uses an OOP Director/Scene Manager/Actor/Script model.
- Network implementation uses the sockets library.
{Make a list of things that you need to fix, improve, and add in the future.}
- Refactor handle network mouse action. It doesn't need to be a separate action, and has redundant code with the regular action.
- The networking is brittle, and would hang if no response happens.