Core game engine for the Kaboom card game.
Project description
Kaboom Engine
The project implements the full game logic including turns, reactions, powers, and endgame rules, designed to be used as a reusable simulation engine, AI environment, or UI backend.
Features
- Complete Kaboom game rules
- Deterministic turn engine
- Reaction resolution system
- Card power mechanics
- Kaboom endgame logic
- Deck reshuffle handling
- Fully enumerated action space
- Action-based engine architecture
- Event-based results
- Fully tested core logic
The engine is designed so it can be used for:
- CLI or graphical game clients
- AI agents
- game simulations
- multiplayer servers
- reinforcement learning environments
Installation
pip install kaboom-engine
OR clone the repository:
git clone https://github.com/Arnav-Ajay/kaboom-core.git
cd kaboom-core
Install locally:
pip install -e .
Basic Usage
from kaboom.game.engine import GameEngine
engine = GameEngine(game_id=0, num_players=4, hand_size=4)
state = engine.state
players = state.players
current_player = state.current_player()
# draw a card
engine.draw_card(current_player.id)
# discard
engine.discard_card(current_player.id)
Running Simulations
The engine exposes the complete legal action space of the current game state.
import random
from kaboom.game.engine import GameEngine
from kaboom.game.turn import apply_action
from kaboom.game.validators import get_valid_actions
engine = GameEngine(game_id=0, num_players=2, hand_size=4)
state = engine.state
while state.phase != GamePhase.GAME_OVER:
player = state.current_player()
# skip inactive players (kaboom caller)
if not player.active:
state.advance_turn()
continue
actions = get_valid_actions(state)
if not actions:
break
action = random.choice(actions)
apply_action(state, action)
Architecture
The engine follows a modular architecture based on action execution.
GameState
|
Action
| (Draw / Discard / Replace / UsePower / CallKaboom / Reaction Actions)
|
apply_action()
|
ActionResult
Action System
All player interactions are represented as Action objects.
Core actions include:
Draw
Discard
Replace
UsePower
CallKaboom
CloseReaction
ReactDiscardOwnCard
ReactDiscardOwnCards
ReactDiscardOtherCard
ReactDiscardOtherCards
The function:
get_valid_actions(state)
returns the full list of legal actions for the current state.
Project Structure
kaboom/
cards/
players/
powers/
game/
actions.py
game_state.py
phases.py
reaction.py
results.py
turn.py
validators.py
tests/
examples/
Key modules:
kaboom/cards → card definitions
kaboom/players → player state and memory
kaboom/powers → card power implementations
kaboom/game → engine logic, actions, validation
Testing
The engine includes a full pytest test suite.
Run tests:
pytest
Coverage includes:
- card scoring
- deck creation
- player management
- power mechanics
- turn actions
- reaction logic
- Kaboom endgame rules
- full game initialization
Future Improvements
Planned enhancements:
- CLI interface
- graphical UI
- AI player agents
- multiplayer networking
- replay and event logging
- Gym-compatible environment for reinforcement learning
License
This project is licensed under the MIT License.
Author
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kaboom_engine-0.2.0.tar.gz.
File metadata
- Download URL: kaboom_engine-0.2.0.tar.gz
- Upload date:
- Size: 23.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc4970fc1769b9b3f199d3caa68097b5d910b7db2486853fdb88fa0afa84cba5
|
|
| MD5 |
b5f05677b0fdb96bba1dde4b90bac9b8
|
|
| BLAKE2b-256 |
8ca9345a1b2ee32bb1850a4ba104102b70243720cab485b05726e32a95198e10
|
File details
Details for the file kaboom_engine-0.2.0-py3-none-any.whl.
File metadata
- Download URL: kaboom_engine-0.2.0-py3-none-any.whl
- Upload date:
- Size: 22.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7be4c397aa0d8c5d684d92036b8f205827175dd667d43e607bcf1d0a34957953
|
|
| MD5 |
7f74f514a23d9e230bcb3e3d4ed9a77c
|
|
| BLAKE2b-256 |
b36e4b40cec1243d560b696d471358cab531ce1d0532ab3bd8c1a5f299428ae6
|