This was a group project for the Linux course during university. We worked in a pair, first
agreeing on the overall design, then splitting the project into tasks and collaborating via Git.
The concept was fairly simple - make a CLI program replicating the board game Pentago. The game
is played on a 6x6 board, with four 3x3 sub-boards. Two players are assigned a color of balls
each. Every turn, a player first places one ball on the board and then rotates one of the
sub-boards by 90° in any direction. A player wins if five of their balls line up in the
horizontal, vertical or diagonal direction.
To solve the task, we utilized many lesser known features of Bash, such as associative arrays.
Due to the data structures involved we had to be careful about the detailed behaviors the
different quoting and variable expansion styles Bash supports. To help us avoid mistakes, we
used ShellCheck as the linter for the code.
We also implemented automated tests for the win-condition-detection algorithm, which help us
find bugs that appeared with different edge-case board configurations. We managed to avoid
needing to declare multiple test boards by making the algorithm check the win condition for a
player denoted by a specific character, and placing more than two different player-charcter
kinds on the same board. The test board thus couldn't ever appear in a real game, however the
checking algorithm ignores all characters except the one it was instructed to check against so
this was not an issue.
We tried to avoid code duplication where possible, utilizing loops and functions, however this
project has demonstrated the limitations of Bash as a programming language, and some parts of
the codebase are quite repetitive to avoid introducing even more difficult to understand
abstractions. The project is also split into multiple files which are then loaded by the script
entrypoint to make it easier to find specific areas of code.
We were aware that Bash was not the ideal tool for such project, however it was one of the tools
we had at our disposal that were relevant to the course, and this project let us practice its
advanced usage.
The lecturer praised our work and said it was the best project submitted during the semester.