diff --git a/src/hcraft/examples/__init__.py b/src/hcraft/examples/__init__.py index d272fc4b..21351cf7 100644 --- a/src/hcraft/examples/__init__.py +++ b/src/hcraft/examples/__init__.py @@ -1,31 +1,62 @@ """#HierarchyCraft environement examples. -Here is the table of available HierarchyCraft environments examples. +Here is the list of available HierarchyCraft environments examples. If you built one of your own, send us a pull request so we can add it to the list! +##Minecraft inspired + +See `hcraft.examples.minecraft` for more details. +[CLI keyword: `minecraft`] + +| Gym name | Task description | +|:---------------------------------|:-----------------------------------------------------------------------| +| MineHcraft-NoReward-v1 | No task (Sandbox) | +| MineHcraft-Stone-v1 | Get the cobblestone item mining it with a wooden pickaxe | +| MineHcraft-Iron-v1 | Get the iron-ingot item smelting raw ore gathered with a stone pickage | +| MineHcraft-Diamond-v1 | Get the diamond item mining it with an iron pickaxe | +| MineHcraft-EnchantingTable-v1 | Craft the enchanting table from a book, obsidian and diamonds | +| MineHcraft-Dragon-v1 | Get the ender-dragon-head by killing it in the ender | +| MineHcraft-[name]-v1 | Get one of the Item of given `name` where Item is in env.world.items | +| MineHcraft-v1 | Get all items at least once | + + +##Minigrid inspired + +[CLI keyword: `minicraft`] + +| Gym name | Documentation reference | +|:---------------------------------|:------------------------------------------------| +| MiniHCraftEmpty-v1 | `hcraft.examples.minicraft.empty` | +| MiniHCraftFourRooms-v1 | `hcraft.examples.minicraft.fourrooms` | +| MiniHCraftMultiRoom-v1 | `hcraft.examples.minicraft.multiroom` | +| MiniHCraftCrossing-v1 | `hcraft.examples.minicraft.crossing` | +| MiniHCraftKeyCorridor-v1 | `hcraft.examples.minicraft.keycorridor` | +| MiniHCraftDoorKey-v1 | `hcraft.examples.minicraft.doorkey` | +| MiniHCraftUnlock-v1 | `hcraft.examples.minicraft.unlock` | +| MiniHCraftUnlockPickup-v1 | `hcraft.examples.minicraft.unlockpickup` | +| MiniHCraftBlockedUnlockPickup-v1 | `hcraft.examples.minicraft.unlockpickupblocked` | + +##Parametrised toy structures | Gym name | CLI name | Reference | |:---------------------------------|:------------------|:------------------------------------------------| -| MineHcraft-v1 | `minecraft` | `hcraft.examples.minecraft` | -| MiniHCraftEmpty-v1 | `minicraft` | `hcraft.examples.minicraft.empty` | -| MiniHCraftFourRooms-v1 | `minicraft` | `hcraft.examples.minicraft.fourrooms` | -| MiniHCraftMultiRoom-v1 | `minicraft` | `hcraft.examples.minicraft.multiroom` | -| MiniHCraftCrossing-v1 | `minicraft` | `hcraft.examples.minicraft.crossing` | -| MiniHCraftKeyCorridor-v1 | `minicraft` | `hcraft.examples.minicraft.keycorridor` | -| MiniHCraftDoorKey-v1 | `minicraft` | `hcraft.examples.minicraft.doorkey` | -| MiniHCraftUnlock-v1 | `minicraft` | `hcraft.examples.minicraft.unlock` | -| MiniHCraftUnlockPickup-v1 | `minicraft` | `hcraft.examples.minicraft.unlockpickup` | -| MiniHCraftBlockedUnlockPickup-v1 | `minicraft` | `hcraft.examples.minicraft.unlockpickupblocked` | | TowerHcraft-v1 | `tower` | `hcraft.examples.tower` | | RecursiveHcraft-v1 | `recursive` | `hcraft.examples.recursive` | | LightRecursiveHcraft-v1 | `light-recursive` | `hcraft.examples.light_recursive` | -| Treasure-v1 | `treasure` | `hcraft.examples.treasure` | + +##Stochastic parametrised toy structures +| Gym name | CLI name | Reference | +|:---------------------------------|:------------------|:------------------------------------------------| | RandomHcraft-v1 | `random` | `hcraft.examples.random_simple` | +##Other examples +| Gym name | CLI name | Reference | +|:---------------------------------|:------------------|:------------------------------------------------| +| Treasure-v1 | `treasure` | `hcraft.examples.treasure` | + """ - import hcraft.examples.minecraft as minecraft import hcraft.examples.minicraft as minicraft import hcraft.examples.random_simple as random_simple diff --git a/tests/examples/minecraft/test_gym_make.py b/tests/examples/minecraft/test_gym_make.py index d529cfe2..6c95b118 100644 --- a/tests/examples/minecraft/test_gym_make.py +++ b/tests/examples/minecraft/test_gym_make.py @@ -1,4 +1,4 @@ -from typing import List, Type, TypeVar +from typing import TYPE_CHECKING, List, Type, TypeVar import pytest import pytest_check as check @@ -6,44 +6,47 @@ from hcraft.examples.minecraft.env import MineHcraftEnv from hcraft.task import GetItemTask, GoToZoneTask, PlaceItemTask, Task -gym = pytest.importorskip("gym") +if TYPE_CHECKING: + import gym + +gym_module: "gym" = pytest.importorskip("gym") def test_no_reward_gym_make(): - env: MineHcraftEnv = gym.make("MineHcraft-NoReward-v1") + env: MineHcraftEnv = gym_module.make("MineHcraft-NoReward-v1") check.equal(env.purpose.tasks, []) def test_stone_gym_make(): - env: MineHcraftEnv = gym.make("MineHcraft-Stone-v1") + env: MineHcraftEnv = gym_module.make("MineHcraft-Stone-v1") check.equal(len(env.purpose.tasks), 1) task = env.purpose.tasks[0] check.equal(task.name, "Get cobblestone") def test_iron_gym_make(): - env: MineHcraftEnv = gym.make("MineHcraft-Iron-v1") + env: MineHcraftEnv = gym_module.make("MineHcraft-Iron-v1") check.equal(len(env.purpose.tasks), 1) task = env.purpose.tasks[0] check.equal(task.name, "Get iron_ingot") def test_diamond_gym_make(): - env: MineHcraftEnv = gym.make("MineHcraft-Diamond-v1") + env: MineHcraftEnv = gym_module.make("MineHcraft-Diamond-v1") check.equal(len(env.purpose.tasks), 1) task = env.purpose.tasks[0] check.equal(task.name, "Get diamond") def test_enchanting_table_gym_make(): - env: MineHcraftEnv = gym.make("MineHcraft-EnchantingTable-v1") + env: MineHcraftEnv = gym_module.make("MineHcraft-EnchantingTable-v1") check.equal(len(env.purpose.tasks), 1) task = env.purpose.tasks[0] check.equal(task.name, "Get enchanting_table") def test_all_items_gym_make(): - env: MineHcraftEnv = gym.make("MineHcraft-v1") + env: MineHcraftEnv = gym_module.make("MineHcraft-v1") TaskOfType = TypeVar("TaskOfType") @@ -76,7 +79,7 @@ def _task_names_of_type( def test_dragon_gym_make(): - env: MineHcraftEnv = gym.make("MineHcraft-Dragon-v1") + env: MineHcraftEnv = gym_module.make("MineHcraft-Dragon-v1") env.reset() expected_tasknames = { "Go to meadow",