Skip to main content

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

Metadata

Release files for gymnasium-orchard 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gymnasium-orchard 1.0.0
File Size Uploaded
gymnasium_orchard-1.0.0.tar.gz 213.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gymnasium-orchard 1.0.0
File Interpreter ABI Platform
gymnasium_orchard-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 222.0 kB

Release files / gymnasium_orchard-1.0.0.tar.gz

Download URL gymnasium_orchard-1.0.0.tar.gz
Size 213.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f70719dfec4913bd6c40d0cb910a9a3423a66ecc2030c1e1f1eb3ecdcf14c0b9
BLAKE2b-256 checksum
How to use checksums
fccf0bc9babd1574e526708bf75e84074884b7f9730da213cd4e8f52d2cc40a7
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / gymnasium_orchard-1.0.0-py3-none-any.whl

Download URL gymnasium_orchard-1.0.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
340c0ae015ab4e1bf03714d0654fac5702b4201da46f558a1c226d0917ce411e
BLAKE2b-256 checksum
How to use checksums
fd437572e4753b3c610bb7b606a541a1aabcc9d71f46a18a08b87f511af5bdd9
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page