Skip to content

A multi-agent version of the Craftax-Classic environment

License

Notifications You must be signed in to change notification settings

DylanASHillier/Multi-Agent-Craftax

 
 

Repository files navigation

Muti-Agent Craftax

This is a multi-agent version of the Craftax-Classic environment from https://github.com/MichaelTMatthews/Craftax

Installation

Clone this repository using git and use pip install . to install this package. To extend this environment, you can create an editable installation using pip install -e ..

Usage

Here's an example of how to use this environmnent

import jax
import jax.numpy as jnp

from craftax.craftax_classic.envs.craftax_symbolic_env import CraftaxClassicSymbolicEnv
from craftax.craftax_classic.constants import Action

rng = jax.random.PRNGKey(42)  # generate a random number from a seed
env = CraftaxClassicSymbolicEnv()  # create environment instance
env_params = env.default_params
# you can set the number of players like so
env.static_env_params = env.static_env_params.replace(num_players=4)

# reset the environment. Obs has shape (n, num_obs). You can get num_obs through env.observation_space(env_params).shape[0]
# This gives one observation per player, for n players
rng, _rng = jax.random.split(rng)
obs, env_state = env.reset(_rng, env_params)

# Let's pick some actions for the players (there are 17 different actions
action = jnp.array([Action.UP.value, Action.DOWN.value, Action.DO.value, Action.SLEEP.value])

# Step the environment
rng, _rng = jax.random.split(rng)
obs, env_state, reward, done, info = env.step(_rng, env_state, action, env_params)

About

A multi-agent version of the Craftax-Classic environment

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%