Chess-like Board Game Engine + Anarchy Chess Engine
Winter 2023 - Present
Status: This project is still in progress, though it is nearly done!
All of the Board Game Engine logic is already implemented, and the Anarchy Chess Engine already has all of the standard rules of Chess implemented along with many of the Anarchy Chess special moves. All that's left to do is add the remaining special moves and compile and release this as a C++ library.
Resources
All code for this project is publically available to read here!
This repository also includes a broad overview of each of the Chess-like Board Game Engine's modules in the README.md file, which should illustrate the thought process behind the engine and showcase its capabilities.
What is this Chess-like Board Game Engine?
The first part of this project, the Chess-like Board Game Engine, is a game engine that controls the backend for any "Chess-like" board game.
In this context, a "Chess-like" board game is a board game that:
Is turn-based
Is played on a board with discrete tiles
Uses pieces that inhabit the board with a maximum of one piece per tile
Only offers a finite number of spaces for each piece to move on a given turn
Note that these are the only limitations to this engine, so more complex board game mechanics are supported, such as:
Infinite boards
Boards that are non-rectangular or include disconnected parts
More than 2 players
Allowing multiple players to control the same piece
Allowing pieces to have complex behaviors that determine their possible moves on a given turn
What is an Anarchy Chess Engine?
For those unfamiliar, Anarchy Chess is a subreddit for Chess memes. Last year, it became famous for creating many made-up Chess rules that everyone on the subreddit pretends are real. All of these moves are "special moves" for preexisting pieces, meaning they are conditional moves that pieces can only make in limited circumstances and which can potentially cause unusual effects on the state of the board. For example, En Passant is a special move in regular Chess, as it allows a pawn in some circumstances to capture a piece on a space that the pawn does not occupy. A list of some of the most popular of these moves can be found on the Anarchy Chess Wiki.
This Anarchy Chess Engine demonstrates the capabilities of the Chess-like Board Game Engine by using the powerful tools of the engine to implement all of the logic of Chess along with many of these special moves. Once this engine is complete, it will include all of the special moves listed on the Anarchy Chess Wiki along with some more that are relatively popular.
What technical skills does this project showcase?
The aim of this project is to showcase proper C++ software design practices whenever possible. When working on this project, I took care to create everything in the most "correct" way I know.
Some programming practices I focused on include:
Separation between interface and implementation
Function declarations are in ".h" files while definitions are in ".cpp" files
All function declarations in ".h" files are accompanied by comments explaining what the function does and what it returns
Test-driven development
For each module, I began by writing out the interface in the ".h" file, then I wrote the tests for each function in a separate testing file (using the Doctest library), then I finally implemented each of the functions in the ".cpp" files.
Proper style
Maintained consistent style
Commented code
Standardized build process (CMake)
Some design practices I focused on include:
Modular design with minimal overlap between modules
Polymorphic design to allow easily expanding behaviors
For example, each move that a piece can make is accompanied by a list of Actions to perform before the move and another list of Actions to perform after the move. An Action is an abstract class, so inheriting this class and implementing its functions can allow engine users to define any types of behaviors they wish!
Adding abstractions to hide the complex backend of the engine
Avoiding bad coding practices, including:
Repeated code
Magic numbers
Super long functions
Some C++ features this project showcases include:
Classes
private member variables, public functions
Inheritance
Virtual functions
Abstract classes
STL data structures
std::pair
std::vector
std::unordered_map
std::set
Memory management
Regular Pointers
References
Smart Pointers (std::shared_ptr)
Macros
#define to create global constant values