This is a text based C implementation of the twixt board game, as part of the CPro'25 course IIIT-H.
Referances given can be found here:
- Project Docs: https://www.notion.so/CPro-25-Project-2a110a71ff29805e81d7f7f95ea85a70
- Rules: https://youtu.be/dIyuVS3xRQ0?si=_qYFqihhfrxKRBRq
- Online player: https://twixtlive.com/Play.aspx
twixt-cli/
├── include/
│ ├── log.h
│ ├── macros.h
│ ├── moves.h // Game Logic protoypes
│ ├── state.h
│ └── utility.h // Rendering function prototypes, macros, and constants
├── LICENCE.md
├── makefile
├── obj/
│ ├── (...) // Object files
├── README.md
├── src/
│ ├── error.c // Display user messages (primarily errors)
│ ├── links.c // Handles Win condition and auxillaries
│ ├── log.c
│ ├── main.c // Handles game loop and input
│ ├── moves.c // Handles logic for each possible move
│ └── ui.c // Rendering layer: draws board, manages colors
├── twixt <-- Main Executable
└── twixt.log // Log file -- Autogenerated
The screen and colours are refreshed and reprinted using ANSI charector codes, the size of the board depends on the SIZE macro defined in include/macros.h
To compile and run, simply run make and ./twixt. It is compiled with gcc however to change the compiler change the CC flag in the makefile (and their repective flags), or just compile on your own
On Linux:
mkdir -p obj/
for f in src/*.c; do
gcc -Wall -Wextra -O1 -c "$f" -o "obj/$(basename "$f" .c).o"
done
gcc -O1 obj/*.o -o twixt
./twixt
To clean, you can run make clean
Please note the make file will not clear your twixt.log file.
To play the game, enter a Row number and a Column number or Column alphabet (regardless of case) to select your cell, when it is your color's turn.
You can:
- Place a peg:
p <number> <number|alphabet>orplace <number> <number|alphabet> - Remove a peg:
u <number> <number|alphabet>orunplace <number> <number|alphabet> - Link two pegs:
l <number> <number|alphabet> <number> <number|alphabet>orlink <number> <number|alphabet> <number> <number|alphabet> - Unlink two pegs:
x <number> <number|alphabet> <number> <number|alphabet>orunlink <number> <number|alphabet> <number> <number|alphabet> - Show all links:
v | viewlinks - Show manual:
h | help
You cannot place at the corners or you're opponent's column.
To quit, simply type "q", "exit or "quit" in the promt and enter.
There is also a twixt.log file (it is autogenerated), which keeps track of all your moves and outputs. to disable this, please set the macro in log.h to 0.
- Draw links
- Auto link
- Place board and commands side by side
- take input with
p A2orp 2Aorp 2 Aas well - Undo any change / only undo unplace and unlink -- since it is the longest
- Points system + scoreboard
- Overall colourise fonts
- Main menu
This project is licensed under the MIT License.