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 | Value | Description |
|---|---|---|
| division | 1 or 0 (or True and False, respectively) | 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 rindex. |
| rindex | 0…digits-1 or None |
Rindex (Right-to-left or reverse index) of the digit to overwrite (if division=1, it should be None). |
Example:
action = {"division": 1, "digit": 3, "rindex": None} # attempt division by 3
action = {"division": 0, "digit": 7, "rindex": 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 |
|---|---|---|
| dynamic_number | np.int8 array (digits,) | The current number as an array of digits. |
| available_digits_per_rindex | 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. It has one player by default. |
| 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_rindex"]) # 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_rindex 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
Project details
Release history Release notifications | RSS feed
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 divide21env-0.2.0.tar.gz.
File metadata
- Download URL: divide21env-0.2.0.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8b4344f202b68797a3d141a2c6a1674b7ec8ba5172c12d9161365be25e09949
|
|
| MD5 |
4cae422faf4a3f58a2a7760f32a8f49d
|
|
| BLAKE2b-256 |
61e36ec482ea9f159bd1fa9f470a35f6f260548786c763ed1b26816cbd8d2cda
|
File details
Details for the file divide21env-0.2.0-py3-none-any.whl.
File metadata
- Download URL: divide21env-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb10110df34edfe03e8ba117c33c314a16071c4e155bd9848761a5563a768b8f
|
|
| MD5 |
c3eec36d7c0e901a71fd88b527a3251e
|
|
| BLAKE2b-256 |
d6cf99b8f52750b5953e2825d031ea1d776b7cf66bcafe5a8b6a49f4558b9c9c
|