Skip to main content

Gymnasium environment for the game Divide21

Project description

Divide21Env

A custom Gymnasium-compatible environment for the Divide21 game.

Environment Details

Action Space

The environment uses a dictionary action space with three components:

Key Type Description
division 0 or 1 Whether to attempt division (1) or change a digit (0).
digit 0–9 If division=1, the divisor; if division=0, the new digit to set at index.
index 0…digits-1 Index of the digit to overwrite (ignored if division=1).

Example:

action = {"division": 1, "digit": 3, "index": 0}  # attempt division by 3
action = {"division": 0, "digit": 7, "index": 1}  # set the second digit to 7

Observation Space

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

Key Type Description
dynamic_number np.int8 array (digits,) The current number as an array of digits.
available_digits_per_index np.int64 array (digits*10,) Binary mask of which digits can be set at each position. Flattened from shape (digits, 10).
players np.int64 array (num_players*3,) Each player’s [id, score, is_current_turn]. Flattened array of all players.
player_turn int ID of the player whose turn it is.

Example:

obs, info = env.reset()
print(obs["dynamic_number"])            # [4, 7]
print(obs["available_digits_per_index"])  # array([1,1,0,...])
print(obs["players"])                   # array([0,0,1,1,0,0])  # two players
print(obs["player_turn"])               # 0

Quick Notes

The available_digits_per_index 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 player_turn and is_current_turn.

Usage Example

import gymnasium as gym
import divide21env

env = gym.make("Divide21-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 Divide21 in your research, projects, or publications, please cite it as:

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

BibTeX

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

Play Divide21 Online

Divide21 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

divide21env-0.1.3.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

divide21env-0.1.3-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file divide21env-0.1.3.tar.gz.

File metadata

  • Download URL: divide21env-0.1.3.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for divide21env-0.1.3.tar.gz
Algorithm Hash digest
SHA256 566e85f1ce7eb2a01b1d725bb5337e695ae16670639899b737ed5134a74a9e4a
MD5 2885b1580001bfba0c562572b6287230
BLAKE2b-256 8c11b9963864594c20f613d6e2a1fbaa68cc0c97f2e648c714c1f430b5fbf272

See more details on using hashes here.

File details

Details for the file divide21env-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: divide21env-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for divide21env-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7f920c2c1ac4b41000af743148ffa9f732ef05515cf06f87e3ffac4c68b64b34
MD5 b6b46edf8f7ceb9314cad214ded48ded
BLAKE2b-256 6c057dc181a708932f74ccb8b7667a8f5cdceafcc1889d77874b880cc18aa375

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