conda create -n lux-s3 python==3.11 -y
conda activate lux-s3
# luxai-s3
pip install -e Lux-Design-S3/src
pip install pettingzoo supersuit
pip install -U "jax[cuda12]"
pip install pygame
# Tianshou (天授)
pip install tianshou
# Notebook
pip install jupyterlabfrom luxai_s3.wrappers import LuxAIS3PettingZooEnv
env = LuxAIS3PettingZooEnv.env(render_mode="human")
env.reset(seed=42)
for agent in env.agent_iter():
observation, reward, termination, truncation, info = env.last()
if termination or truncation:
action = None
else:
action = env.action_space(agent).sample() # this is where you would insert your policy
env.step(action)
env.close()from luxai_s3.wrappers import LuxAIS3PettingZooEnv
parallel_env = LuxAIS3PettingZooEnv.parallel_env(render_mode="human")
observations, infos = parallel_env.reset(seed=42)
while parallel_env.agents:
# this is where you would insert your policy
actions = {agent: parallel_env.action_space(agent).sample() for agent in parallel_env.agents}
observations, rewards, terminations, truncations, infos = parallel_env.step(actions)
parallel_env.close()See more usage in playground notebook.
python code/train_tianshou.py