Skip to main content

A continual reinforcement learning benchmark

Project description

foragax

Foragax is a lightweight, JAX-first grid-world environment suite for continual / procedural experiments. It provides a small collection of environment variants (weather, multi-biome, etc.), a registry factory for easy construction, and simple example scripts for plotting and visualization.

This version is a Gymnax environment implemented in JAX. The original implementation of Forager is implemented in Numba is available at andnp/forager. In addition to the original features, this implementation includes: biomes, visualization, and a weather environment.

Key ideas:

  • Functional, JAX-friendly API (explicit PRNG keys, immutable env state objects).
  • Multiple observation modalities: Object and RGB, as well as aperture based or full-world observations.
  • Customizable biomes
  • Customizable object placement, respawning, and rewards.
  • Visualization via RGB rendering and plotting.

Quickstart

We recommend installing with pip from https://pypi.org/project/continual-foragax/.

pip install continual-foragax

We support Python 3.8 through Python 3.13.

The codebase expects JAX and other numeric dependencies. If you don't have JAX installed, see the JAX install instructions for your platform; the project uv.lock pins compatible versions.

Minimal example (from examples)

Use the registry factory to create an environment and run it with JAX-style RNG keys and an explicit environment state.

from foragax.registry import make
import jax

# create env (observation_type is one of: 'object', 'rgb', 'world')
env = make(
		"ForagaxWeather-v1",
		aperture_size=5,
		observation_type="object",
)

# environment parameters and RNG
env_params = env.default_params
key = jax.random.key(0)
key, key_reset = jax.random.split(key)

# reset returns (obs, env_state)
_, env_state = env.reset(key_reset, env_params)

# sampling an action and stepping (functional-style)
key, key_act, key_step = jax.random.split(key, 3)
action = env.action_space(env_params).sample(key_act)
_, next_env_state, reward, done, info = env.step(key_step, env_state, action, env_params)

# rendering supports multiple modes: 'world' and 'aperture'
frame = env.render(env_state, env_params, render_mode="aperture")

See examples/plot.py and examples/visualize.py for runnable scripts that produce a sample plot and saved videos using Gym/Gymnasium helpers.

Registry and included environments

Use foragax.registry.make to construct environments by id. Example environment ids include:

  • ForagaxTwoBiomeSmall-v1 / -v2 — hand-crafted small multi-biome layouts
  • ForagaxWeather-v1 — small weather-driven two-biome environment used by examples

The make factory accepts the following notable kwargs:

  • observation_type: one of "object", "rgb", or "world".
  • aperture_size: integer or tuple controlling the agent's local observation aperture.
  • file_index: used to pick weather locations.

Custom objects and extensions

The codebase includes an object system for placing items into biomes and controlling behaviour (rewards, respawn / regen behavior, blocking/collectable flags). See foragax.objects for the canonical object definitions and helpers like create_weather_objects used by the registry.

If you want to add new object classes, follow the examples in foragax.objects and add the class into registry configs or construct environments programmatically.

Design notes

  • JAX-first: RNG keys and immutable env state are passed explicitly so environments can be stepped inside JIT/pmapped loops if desired.
  • Small, composable environment variants are provided through the registry (easy to add more).

Examples

  • examples/plot.py — runs a short random policy in ForagaxWeather-v1 and produces a temperature vs reward plot (saves to plots/sample_plot.png).
  • examples/visualize.py — runs environments at multiple aperture sizes and saves short videos under videos/ using save_video.

Development

Run unit tests via pytest.

Acknowledgments

We acknowledge the data providers in the ECA&D project. Klein Tank, A.M.G. and Coauthors, 2002. Daily dataset of 20th-century surface air temperature and precipitation series for the European Climate Assessment. Int. J. of Climatol., 22, 1441-1453.

Data and metadata available at https://www.ecad.eu

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

continual_foragax-0.42.1.tar.gz (7.7 MB view details)

Uploaded Source

Built Distribution

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

continual_foragax-0.42.1-py3-none-any.whl (8.2 MB view details)

Uploaded Python 3

File details

Details for the file continual_foragax-0.42.1.tar.gz.

File metadata

  • Download URL: continual_foragax-0.42.1.tar.gz
  • Upload date:
  • Size: 7.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for continual_foragax-0.42.1.tar.gz
Algorithm Hash digest
SHA256 ce0312d73114c2d5c1475e8c5f23bfb0bbe84d9af3b4907f466938f91d793efb
MD5 73cb3385033dd229666f4b2aec793679
BLAKE2b-256 e9105cb4f6a47bfad292af997d552e2cca8289096ce791400025e195bca171c2

See more details on using hashes here.

File details

Details for the file continual_foragax-0.42.1-py3-none-any.whl.

File metadata

  • Download URL: continual_foragax-0.42.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for continual_foragax-0.42.1-py3-none-any.whl
Algorithm Hash digest
SHA256 175c1be817b89dcb89d8c4aa5a0c8d43fa4661bf908cbab119701b46f1fb08ff
MD5 1254bf1611a4fe62ef692a0f39438c58
BLAKE2b-256 1747af2828a206c377d0a4cb930e1c443c830f2760bece4fc004de48ab4dd808

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