Customizing Your Own Task
February 13, 2025 ยท View on GitHub
To create a custom task, follow these steps:
- Set up a new task environment.
- Generate a configuration file for each task variant.
Creating a New Task Environment
-
Clone the Task Template
Copy thetask_buildfolder located underteamcraft/teamcraft/tasks/, renaming it in the formattask_xxx. -
Rename the Minecraft World Save Folder
Insidetask_xxx, rename the Minecraft world save folder (world_build) toworld_xxx. -
(Optional) Modify the Minecraft World
- Edit
world_xxxusing a local Minecraft instance (refer to env doc under Visualization for setup instructions). - Load
world_xxxas a game save. - Modifed the world using creative mode (Use command
/gamemode creative) - Save the world
- Edit
-
Modify the
build_env.pyFile- Rename the
BuildEnvclass following the formatxxxEnv. - Adjust any internal parameters using env doc as a reference.
- Modify the
calculate_rewardfunction:- For block-based rewards, refer to
BreakEnvandBuildEnv. - For inventory-based rewards, refer to
FarmEnvandSmeltEnv.
- For block-based rewards, refer to
- Update the
self.donecondition.
- Rename the
-
Update Import Statements
Modify the following__init__.pyfiles to import your environment class:teamcraft/teamcraft/tasks/task_xxx/__init__.pyteamcraft/teamcraft/tasks/__init__.pyteamcraft/teamcraft/__init__.py
Generating the Configuration File
- Follow the step by step instructions in
Customize Your Task.ipynb- Alternatively, you can also follow a complete python file,
config_gen.py, sarting from line 170, to generate the configuration file.
- Alternatively, you can also follow a complete python file,
- Replace the existing
.jsonfile undertask_xxx/configurewith the new configuration.
Run
Once completed, you can import and use your custom class with:
from teamcraft import xxxEnv
env = xxxEnv()
total_steps = 5
total_variants = 250
for seed in range(total_variants):
reset_info = env.reset(seed)
task_images = reset_info[0]
images, state, inventory, done, reward = reset_info[1]
for _ in range(total_steps):
actions = "your action here"
images, state, inventory, done, reward = env.step(actions)
env.close()