Skip to main content

Gymnasium environment for the game Kuzonga

Project description

KuzongaEnv

A custom Gymnasium-compatible environment for the Kuzonga game.

Environment Details

Action Space

The environment uses a dictionary action space with three components:

Key Value Description
v 1 or 0 (or True and False, respectively) Whether to attempt division (1) or change a digit (0).
g 0–9 If v=1, the divisor; if v=0, the new digit to set at r.
r 0…digits-1 or None Rindex (Right-to-left or reverse index) of the digit to overwrite (if v=1, it should be None).

Example:

action = {"v": 1, "g": 3, "r": None}  # attempt division by 3
action = {"v": 0, "g": 7, "r": 1}  # set the second digit (from the right) to 7

Observation Space

The environment uses a dictionary observation space with the following keys:

Key Type Description
s np.int8 array (digits,) The original number as an array of digits.
d np.int8 array (digits,) The current number as an array of digits.
a np.int64 array (digits*10,) Binary mask of which digits can be set at each position. Flattened from shape (digits, 10).
p np.int64 array (num_players*3,) Each player’s [i, c, m], where i is the ID, c is the score and m tells if it is the player's turn (m=1) or not (m=0). Flattened array of all players. It has one player by default.
t int ID of the player whose turn it is.

Example:

obs, info = env.reset()
print(obs["s"])   # [1, 7]
print(obs["d"])   # [4, 7]
print(obs["a"])   # array([1,1,0,...])
print(obs["p"])   # array([0,0,1,1,0,0])  # two players
print(obs["t"])   # 0

Quick Notes

The a mask ensures illegal moves (e.g., setting a leading zero or creating number 0/1) are prevented.

Rewards and penalties are automatically updated in the environment during step().

The environment fully supports multiple players, and tracks turns via t and m.

The options parameter in reset() allows resetting the environment to a specific given state/obs, by setting it with the format: options = {'obs': <state/obs dict>}

The info variable value from methods reset() and step() has the fields:

  • obs_decoded, which has the plain values of the resulting state/observation. So it can be retrieved as info['obs_decoded'].
  • all_actions, which is a list of all the actions in the current state. So it can be retrieved as info['all_actions'].
  • concluded, which is True if the state is a finished state (winning game conditions have been met), and False otherwise. So it can be retrieved as info['concluded'].

Usage Example

import gymnasium as gym
import kuzongaenv

env = gym.make("Kuzonga-v0")
obs, info = env.reset()
action = env.action_space.sample()
obs, reward, terminated, truncated, info = env.step(action)

print(f"Observation: {obs}")
print(f"Reward: {reward}, Terminated: {terminated}")

Installation

pip install -e .

Cite This Project

If you use Kuzonga in your research, projects, or publications, please cite it as:

Jacinto Jeje Matamba Quimua (2025). KuzongaEnv: Gym Environment for Reinforcement Learning Experiments. GitHub repository: https://github.com/jaci-hub/kuzongaenv

BibTeX

@misc{kuzongaenv2025,
  author       = {Jacinto Jeje Matamba Quimua},
  title        = {KuzongaEnv: Gym Environment for Reinforcement Learning Experiments},
  year         = 2025,
  howpublished = {\url{https://github.com/jaci-hub/kuzongaenv}},
}

Play Kuzonga Online

Kuzonga game

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

kuzongaenv-0.3.3.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kuzongaenv-0.3.3-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file kuzongaenv-0.3.3.tar.gz.

File metadata

  • Download URL: kuzongaenv-0.3.3.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for kuzongaenv-0.3.3.tar.gz
Algorithm Hash digest
SHA256 bfce52d13f25c2f7011ac63c936d9ffd03f50069f407053b00c7cd424debd556
MD5 8507318b3c082e33b18c71ed75fd7815
BLAKE2b-256 31f6a772cfadb2373b43284099fc64ce91b42536b473d64a7d5a697c3bb34cfb

See more details on using hashes here.

File details

Details for the file kuzongaenv-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: kuzongaenv-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for kuzongaenv-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9b3cffff2b23d0df820be2467e9fcba19b5f38ad5a696dfb8d317c62f4ec43f0
MD5 f4e0c1954951bd2419643bb16c462e29
BLAKE2b-256 c5dc76d86974bbabadcff6b27ced8d5e920e234e67a1ac5ac7b3305f45a989d6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page