Skip to main content

A Sudoku environment for Reinforcement Learning research

Project description

[!warning] Under active development...Expect frequent code changes....

pip install gymnasium_sudoku
import gymnasium_sudoku
import gymnasium as gym

env = gym.make("sudoku-v0",render_mode="human",horizon=150,render_delay=0.01,eval_mode=True)
env.reset() 
steps = 100

for n in range(steps):
    env.step(env.action_space.sample())
    env.render() 

And for training mode:

env = gym.make("sudoku-v0",horizon=150,eval_mode=False) # no rendering during  training  

Observation space : The state returned after each .reset() or .step() is a raw sudoku board shape [9,9].This observation can be converted into an image.

Action space: The action space is shaped [x,y,z],representing : x = row position of the cell, y = column position of the cell and value that should go into that cell.When vectorizing, the current version of the environment do not handle action reshaping, so for n environments, the action's shape should be : [[x0...xn],[y0...yn],[z0...zn]]

By default, eval_mode is set to False, this is good for training since after each reset() call,the Sudoku board will be changed to add more diversity to the training data and try to prevent memorization, so that the policy learns a more general distribution...At least that is the intuition.

During testing, eval_mode should be set to True to test the generalization capabilities of a trained policy or to test the environment with a random policy.This is important; otherwise,when testing a trained policy,it will be tested on states seen during training which would measure memorization rather than generalization.This makes it an invalid test of the policy's true capabilities.

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

gymnasium_sudoku-0.2.2.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

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

gymnasium_sudoku-0.2.2-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file gymnasium_sudoku-0.2.2.tar.gz.

File metadata

  • Download URL: gymnasium_sudoku-0.2.2.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for gymnasium_sudoku-0.2.2.tar.gz
Algorithm Hash digest
SHA256 267d4db4e8a2474b73e37a4869d4e9d8c889ed62fe6da83ee73bec3938fd2620
MD5 5d9c90da84a3f6ae016d485c4743df28
BLAKE2b-256 689c380343eeebbae8d5ee56c24eb55aae9614f6639f2787fa33ba6f0a988d98

See more details on using hashes here.

File details

Details for the file gymnasium_sudoku-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for gymnasium_sudoku-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c92ee8dadc567bd42ff1544ac67e54f174000cd00f46ed6bf3c45e1db0fd6c41
MD5 48a0ca6b58b3c0c9355e18d3bd4e2c83
BLAKE2b-256 92ebf0ee2c15ed2412abf8ec9bdc2bbed3ef66c9e69497b334b52855bee12b35

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