A C++ implementation of the classic Connect Four game with a client-server architecture and multiple bot players.
- WebSocket-based client-server architecture
- Multiple bot implementations:
- Random Luka Bot: Makes completely random moves
- Random Janez Bot: Prioritizes center column with fallback to random moves
- SQLite database for player statistics and ELO ratings
- Interactive gameplay through console interface
- C++20 compatible compiler
- WebSocket++ library (included in the repository)
- JsonCpp library (included in the repository)
- SQLite3 (included in the repository)
- CMake (version 3.10 or higher)
- Clone the repository:
git clone https://github.com/yourusername/connect-four.git
cd connect-four
- Create a build directory and navigate to it:
mkdir build
cd build
- Generate build files with CMake:
cmake ..
Additionally, you can specify BOOST_ROOT to point to your Boost installation directory.
cmake -DBOOST_ROOT=/path/to/boost ..
- Build the project:
cmake --build .
- Start the server:
./server
- In separate terminal windows, run clients or bots:
./client <server_uri> (e.g., ws://localhost:9002) # For human player
./random_luka <server_uri> (e.g., ws://localhost:9002) # For Random Luka bot
./random_janez <server_uri> (e.g., ws://localhost:9002) # For Random Janez bot
server.cpp/h
: Server implementationclient.cpp
: Human player client implementationbot.cpp/h
: Base bot class implementationrandom_luka.cpp
: Random move bot implementationrandom_janez.cpp/h
: Center-prioritizing bot implementationConnectFourGame.cpp/h
: Game logic implementationDatabaseManager.cpp/h
: SQLite database management
The project uses Doxygen for documentation. To generate the documentation:
- Install Doxygen
- Run:
doxygen Doxyfile
- Open
docs/html/index.html
in your web browser
MIT License
Copyright (c) 2024 Valentin Kragelj
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.