Welcome to the AI-Powered Board Game in C! This project is a terminal-based strategy game where you compete against a computer opponent on an 8x8 grid. The AI uses a sophisticated minimax algorithm with alpha-beta pruning to simulate challenging gameplay, ensuring a competitive experience every time you play.
- Single-player mode: Battle against an AI opponent with smart decision-making capabilities.
- 8x8 Board: Classic grid-based gameplay using ASCII characters:
O
for Player movesX
for Computer moves
- AI Strategy:
- Minimax algorithm with a configurable depth limit for move predictions.
- Alpha-beta pruning to optimize decision-making speed.
- Modular code: Organized with structs and functions for readability and maintainability.
Follow these steps to set up the game on your local machine:
- GCC compiler (or any C compiler of your choice)
- Terminal/Command Line Interface
git clone https://github.com/Tutusaus/4_en_Ratlla.git
cd .\4_en_Ratlla\
gcc main.c -o main
Once compiled, you can run the game by executing:
main.exe
- The game starts with an empty 8x8 board.
- Players take turns placing their marks (
O
for Player,X
for Computer) on the board. - The objective is to outsmart your opponent by strategically placing your marks.
- The AI uses an advanced algorithm to make decisions, providing a challenging opponent.
The game leverages a tree data structure to simulate possible game states:
- Each game state is represented by a
node
struct containing:- A 2D array for the board (
tauler[N][N]
) - A list of possible moves (children nodes)
- A heuristic value for evaluating the game state
- A 2D array for the board (
- The AI uses a minimax algorithm with alpha-beta pruning:
- Minimax evaluates all possible moves to determine the optimal one.
- Alpha-beta pruning reduces the number of nodes evaluated by the algorithm, making the AI faster and more efficient.
- You can adjust the AI difficulty by modifying the depth constant (
PROFUNDITAT
).
Here are some enhancements planned for future versions:
- Graphical User Interface (GUI): Develop a visual version using libraries like SDL or OpenGL.
- Difficulty Levels: Add adjustable difficulty settings for the AI.
- Multiplayer Support: Enable two-player mode.
- Save/Load Game: Implement functionality to save and resume games.
Contributions are welcome! If you would like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Open a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.