Skip to main content

Gymnasium environments for the Orchard cooperative dice game

Project description

gymnasium-orchard

Gymnasium environments for the cooperative dice game Orchard (First Orchard).

Background and analysis: Recommend.Games blog

Installation

pip install gymnasium-orchard

To also use the bulk simulation and analysis tools (OrchardGame.run_games, OrchardGame.analyse_games):

pip install "gymnasium-orchard[analysis]"

Usage

import gymnasium as gym
import orchard  # registers the environments

env = gym.make("Orchard-round")
obs, info = env.reset(seed=42)

terminated = False
while not terminated:
    action = env.action_space.sample()  # or your policy
    obs, reward, terminated, truncated, info = env.step(action)

Environments

Orchard-round

One step() = one die roll. The agent provides an action every step; it is only applied when the basket face is rolled.

Orchard-decision

One step() = one basket decision. The environment advances automatically through fruit-tree and raven rolls, pausing only when a basket is rolled or the game ends. Cleaner for tabular RL methods.

Observation space

Both environments use the same observation space:

Key Space Description
fruits Box(int8, shape=(num_trees,)) Fruits remaining on each tree
raven Discrete(raven_steps + 1) Raven's distance from the orchard

Action space

Discrete(num_trees) — which tree to pick from on a basket roll. Ignored on all other rolls; falls back to the tree with the most fruit if the chosen tree is empty.

Reward

Sparse: +1 on win (all fruit picked), -1 on loss (raven reaches the orchard), 0 otherwise.

Info dict

Both environments include an action_mask in info on every step:

info["action_mask"]  # np.int8 array, 1 = tree has fruit, 0 = empty

Orchard-round additionally includes the die result:

info["die"]             # int, face rolled
info["basket"]          # bool, whether it was a basket roll
info["action_applied"]  # bool, whether the action was used

Orchard-decision includes the rolls that were skipped:

info["auto_rolls"]  # list[int], die values of non-basket rolls since last step

Configuration

Pass an OrchardGameConfig to customise the game:

from orchard.game import OrchardGameConfig

config = OrchardGameConfig(
    num_trees=4,
    fruits_per_tree=10,
    fruits_per_basket_roll=2,
    raven_steps=9,
)
env = gym.make("Orchard-round", config=config)

Licence

MIT

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_orchard-1.0.0.tar.gz (213.4 kB view details)

Uploaded Source

Built Distribution

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

gymnasium_orchard-1.0.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file gymnasium_orchard-1.0.0.tar.gz.

File metadata

  • Download URL: gymnasium_orchard-1.0.0.tar.gz
  • Upload date:
  • Size: 213.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gymnasium_orchard-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f70719dfec4913bd6c40d0cb910a9a3423a66ecc2030c1e1f1eb3ecdcf14c0b9
MD5 8a34cae0923c275290e2ee720d95a650
BLAKE2b-256 fccf0bc9babd1574e526708bf75e84074884b7f9730da213cd4e8f52d2cc40a7

See more details on using hashes here.

File details

Details for the file gymnasium_orchard-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: gymnasium_orchard-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gymnasium_orchard-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 340c0ae015ab4e1bf03714d0654fac5702b4201da46f558a1c226d0917ce411e
MD5 8f6bedf58c034af1ab99cc69f579aa7b
BLAKE2b-256 fd437572e4753b3c610bb7b606a541a1aabcc9d71f46a18a08b87f511af5bdd9

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