genMaczek is a strategic war card game where players take turns to outmaneuver and defeat their opponent by making tactical decisions. The game features both a human player and an AI opponent, each with their own deck of cards. The objective is to reduce the opponent's health to zero or have the highest health when all cards are used.
I undertook this experiment to learn about integrating Ollama and generative AI (genAI) with a game to create a valid AI opponent. The goal was to explore how AI can be used to make strategic decisions in a game environment.
The results were mixed. While the AI was able to make some valid moves, it was also slow and prone to hallucinations, making decisions that did not always align with the game rules or context.
- Turn-based gameplay: Players take turns to play cards from their hand.
- AI opponent: The game includes an AI opponent that makes strategic decisions based on the game state.
- Card effects: Cards can have various effects such as attacking, healing, generating resources, and more.
- Resource management: Players must manage their resources to play cards effectively.
- Dynamic UI: The game features a dynamic user interface built with PyQt5.
-
Clone the repository:
git clone https://github.com/yourusername/genmaczek-ai-card-game.git cd genmaczek-ai-card-game -
Install dependencies:
pip install PyQt5 requests
-
Run the server:
ollama serve -
Get model:
ollama pull granite3-dense ollama create granite3-dense -f Modelfile -
Run the game:
python3 main.py
- Start the game: Launch the game by running
python3 main.py. - Game setup: The game initializes with both players drawing their initial hands.
- Player's turn: The player can choose a card from their hand to play. Each card has a cost and an effect.
- AI's turn: The AI opponent will make its move based on the current game state.
- End turn: After playing a card, the turn ends, and the next player gets to play.
- Win condition: The game ends when one player's health reaches zero or all cards are used. The player with the higher health wins.
- Attack cards: Deal damage to the opponent.
- Defense cards: Increase the player's defense to absorb damage.
- Healing cards: Restore the player's health.
- Resource cards: Generate additional resources for the player.
- Special cards: Have unique effects such as skipping the opponent's turn.
The AI opponent uses a model to decide its moves based on the game state. It considers factors such as available resources, health, and the cards in hand to make strategic decisions.
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Powered by IBM Granite 3.0
- Developed by Krzysztof Krystian Jankowski
