This is a C++ implementation of a Pong game with AI using Q-learning. The game allows you to play against an AI opponent with adjustable difficulty levels. The game is built using the SFML library for graphics and input handling.
Before installing and running the game, ensure you have the following installed on your system:
- C++ Compiler: A compiler that supports C++17 or later (e.g.,
g++,clang). - CMake: Version 3.10 or later.
- SFML Library: Version 2.5 or later.
- Homebrew: A package manager for macOS.
- Windows Subsystem for Linux (WSL): Ensure WSL is installed and configured.
- Ubuntu: Recommended WSL distribution.
-
Clone the Repository:
git clone https://github.com/Cool-Coder174/Qpong.git cd pong-ai-game -
Run the Dependency Installation Script: Execute the provided
install_dependencies.shscript to install SFML and other dependencies:./install_dependencies.sh
-
Build the Project: Use CMake to configure and build the project:
mkdir build cd build cmake .. make -
Run the Game: After building, the executable will be located in the
builddirectory. Run it using:./PongGame
-
Clone the Repository:
git clone https://github.com/Cool-Coder174/Qpong.git cd pong-ai-game -
Run the Dependency Installation Script: Execute the
install_dependencies.shscript to install SFML and other dependencies:./install_dependencies.sh
-
Build the Project: Use CMake to configure and build the project:
mkdir build cd build cmake .. make -
Run the Game: After building, the executable will be located in the
builddirectory. Run it using:./PongGame
Once the game is built, you can run it by executing the PongGame binary. The game will open in a new window.
- Player Paddle:
- Move Up:
W - Move Down:
S
- Move Up:
- Pause/Resume:
Escape
- Prevent the ball from passing your paddle.
- Score points by making the ball pass the AI paddle.
- The game ends when either the player or the AI reaches a score of 0.
You can adjust the AI difficulty in the Options Menu:
- Navigate to the Options menu from the main menu.
- Select the Difficulty option to cycle through:
- Easy: Low exploration and slower learning.
- Medium: Balanced difficulty.
- Hard: High exploration and faster learning.
-
SFML Not Found:
- Ensure SFML is installed in standard system paths or specify its location in the
CMakeLists.txtfile:set(SFML_DIR "/path/to/SFML")
- Ensure SFML is installed in standard system paths or specify its location in the
-
Font Not Found:
- Ensure the
arial.ttffont file is in the same directory as the executable or in a system font directory.
- Ensure the
-
Permission Denied:
- Ensure the
install_dependencies.shscript has execute permissions:chmod +x install_dependencies.sh
- Ensure the
-
Game Crashes on Startup:
- Verify that all dependencies are installed correctly.
- Check the console output for error messages.
Enjoy playing Pong AI! If you encounter any issues, feel free to open an issue on the repository.