From c62aa75f7a453790ba42faad9ac560ee04d272b7 Mon Sep 17 00:00:00 2001 From: nicomon24 Date: Sat, 3 Aug 2019 12:39:30 +0200 Subject: [PATCH 1/2] Added flatworld envs (dense) --- minerl/env/__init__.py | 101 +++++++++++------- minerl/env/missions/navigationDenseFlat.xml | 78 ++++++++++++++ .../navigationDenseFlatDeterministic.xml | 78 ++++++++++++++ 3 files changed, 219 insertions(+), 38 deletions(-) create mode 100644 minerl/env/missions/navigationDenseFlat.xml create mode 100644 minerl/env/missions/navigationDenseFlatDeterministic.xml diff --git a/minerl/env/__init__.py b/minerl/env/__init__.py index dfb6cee4f..04385ccd9 100644 --- a/minerl/env/__init__.py +++ b/minerl/env/__init__.py @@ -1,15 +1,15 @@ # ------------------------------------------------------------------------------------------------ # Copyright (c) 2018 Microsoft Corporation -# +# # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and # associated documentation files (the "Software"), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, merge, publish, distribute, # sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included in all copies or # substantial portions of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT # NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, @@ -27,7 +27,7 @@ import numpy as np - + register( id='MineRLTreechop-v0', entry_point='minerl.env:MineRLEnv', @@ -37,32 +37,32 @@ 'pov': spaces.Box(low=0, high=255, shape=(64, 64, 3), dtype=np.uint8), }), 'action_space': spaces.Dict(spaces={ - "forward": spaces.Discrete(2), - "back": spaces.Discrete(2), - "left": spaces.Discrete(2), - "right": spaces.Discrete(2), - "jump": spaces.Discrete(2), - "sneak": spaces.Discrete(2), - "sprint": spaces.Discrete(2), + "forward": spaces.Discrete(2), + "back": spaces.Discrete(2), + "left": spaces.Discrete(2), + "right": spaces.Discrete(2), + "jump": spaces.Discrete(2), + "sneak": spaces.Discrete(2), + "sprint": spaces.Discrete(2), "attack": spaces.Discrete(2), "camera": spaces.Box(low=-180, high=180, shape=(2,), dtype=np.float32), }), 'docstr': """ .. image:: ../assets/treechop1.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/treechop2.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/treechop3.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/treechop4.mp4.gif :scale: 100 % - :alt: + :alt: In treechop, the agent must collect 64 `minercaft:log`. This replicates a common scenario in Minecraft, as logs are necessary to craft a large amount of items in the game, and are a key resource in Minecraft. The agent begins in a forest biome (near many trees) with an iron axe for cutting trees. The agent is given +1 reward for obtaining each unit of wood, and the episode terminates once the agent obtains 64 units.\n""" @@ -80,26 +80,26 @@ def make_navigate_text(top, dense): navigate_text = """ .. image:: ../assets/navigate{}1.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/navigate{}2.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/navigate{}3.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/navigate{}4.mp4.gif :scale: 100 % - :alt: + :alt: In this task, the agent must move to a goal location denoted by a diamond block. This represents a basic primitive used in many tasks throughout Minecraft. In addition to standard observations, the agent has access to a “compass” observation, which points near the goal location, 64 meters from the start location. The goal has a small random horizontal offset from the compass location and may be slightly below surface level. On the goal location is a unique block, so the agent must find the final goal by searching based on local visual features. The agent is given a sparse reward (+100 upon reaching the goal, at which point the episode terminates). """ if dense: navigate_text += "**This variant of the environment is dense reward-shaped where the agent is given a reward every tick for how much closer (or negative reward for farther) the agent gets to the target.**\n" - else: + else: navigate_text += "**This variant of the environment is sparse.**\n" if top is "normal": @@ -156,6 +156,31 @@ def make_navigate_text(top, dense): ) +register( + id='MineRLNavigateDenseFlatDeterministic-v0', + entry_point='minerl.env:MineRLEnv', + kwargs={ + 'xml': os.path.join(missions_dir, 'navigationDenseFlatDeterministic.xml'), + 'observation_space': navigate_observation_space, + 'action_space': navigate_action_space, + 'docstr': make_navigate_text('normal', True) + }, + max_episode_steps=2000, +) + +register( + id='MineRLNavigateDenseFlat-v0', + entry_point='minerl.env:MineRLEnv', + kwargs={ + 'xml': os.path.join(missions_dir, 'navigationDenseFlat.xml'), + 'observation_space': navigate_observation_space, + 'action_space': navigate_action_space, + 'docstr': make_navigate_text('normal', True) + }, + max_episode_steps=2000, +) + + register( id='MineRLNavigateExtreme-v0', entry_point='minerl.env:MineRLEnv', @@ -163,7 +188,7 @@ def make_navigate_text(top, dense): 'xml': os.path.join(missions_dir, 'navigationExtreme.xml'), 'observation_space': navigate_observation_space, 'action_space': navigate_action_space, - 'docstr': make_navigate_text('extreme', False) + 'docstr': make_navigate_text('extreme', False) }, max_episode_steps=6000, ) @@ -175,7 +200,7 @@ def make_navigate_text(top, dense): 'xml': os.path.join(missions_dir, 'navigationExtremeDense.xml'), 'observation_space': navigate_observation_space, 'action_space': navigate_action_space, - 'docstr': make_navigate_text('extreme', True) + 'docstr': make_navigate_text('extreme', True) }, max_episode_steps=6000, ) @@ -244,19 +269,19 @@ def make_navigate_text(top, dense): 'docstr': """ .. image:: ../assets/orion1.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/orion2.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/orion3.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/orion4.mp4.gif :scale: 100 % - :alt: + :alt: In this environment the agent is required to obtain an iron pickaxe. The agent begins in a random starting location, on a random survival map, without any items, matching the normal starting conditions for human players in Minecraft. The agent is given access to a selected view of its inventory and GUI free crafting, smelting, and inventory management actions. @@ -293,19 +318,19 @@ def make_navigate_text(top, dense): 'docstr': """ .. image:: ../assets/orion1.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/orion2.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/orion3.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/orion4.mp4.gif :scale: 100 % - :alt: + :alt: In this environment the agent is required to obtain an iron pickaxe. The agent begins in a random starting location, on a random survival map, without any items, matching the normal starting conditions for human players in Minecraft. The agent is given access to a selected view of its inventory and GUI free crafting, smelting, and inventory management actions. @@ -345,19 +370,19 @@ def make_navigate_text(top, dense): 'docstr': """ .. image:: ../assets/odia1.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/odia2.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/odia3.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/odia4.mp4.gif :scale: 100 % - :alt: + :alt: .. caution:: **This is the evaluation environment of the MineRL Competition!** Specifically, you are allowed @@ -402,19 +427,19 @@ def make_navigate_text(top, dense): 'docstr': """ .. image:: ../assets/odia1.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/odia2.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/odia3.mp4.gif :scale: 100 % - :alt: + :alt: .. image:: ../assets/odia4.mp4.gif :scale: 100 % - :alt: + :alt: In this environment the agent is required to obtain a diamond. The agent begins in a random starting location on a random survival map without any items, matching the normal starting conditions for human players in Minecraft. The agent is given access to a selected summary of its inventory and GUI free diff --git a/minerl/env/missions/navigationDenseFlat.xml b/minerl/env/missions/navigationDenseFlat.xml new file mode 100644 index 000000000..8936ba932 --- /dev/null +++ b/minerl/env/missions/navigationDenseFlat.xml @@ -0,0 +1,78 @@ + + + + $(ENV_NAME) + + + + 50 + + + + + + clear + false + + + + + + 64 + 64 + 8 + 0 + diamond_block + surface + + 0 + 8 + true + + + + + + + + MineRLAgent + + + + + + + + 64 + 64 + + + + + + + + moveMouse + inventory + + + + + + + + + + + + + + + + + + + diff --git a/minerl/env/missions/navigationDenseFlatDeterministic.xml b/minerl/env/missions/navigationDenseFlatDeterministic.xml new file mode 100644 index 000000000..d8ca1ab6b --- /dev/null +++ b/minerl/env/missions/navigationDenseFlatDeterministic.xml @@ -0,0 +1,78 @@ + + + + $(ENV_NAME) + + + + 50 + + + + + + clear + false + + + + + + 64 + 64 + 8 + 0 + diamond_block + surface + + 0 + 8 + false + + + + + + + + MineRLAgent + + + + + + + + 64 + 64 + + + + + + + + moveMouse + inventory + + + + + + + + + + + + + + + + + + + From 8707d25602f98f136c9d238d3366c302815dea3f Mon Sep 17 00:00:00 2001 From: nicomon24 Date: Fri, 27 Sep 2019 11:36:02 +0200 Subject: [PATCH 2/2] Modified docstring for flat environments --- minerl/env/__init__.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/minerl/env/__init__.py b/minerl/env/__init__.py index 4b4fcfcbc..380c9963b 100644 --- a/minerl/env/__init__.py +++ b/minerl/env/__init__.py @@ -76,8 +76,8 @@ # NAVIGATE # ####################### -def make_navigate_text(top, dense): - navigate_text = """ +def make_navigate_text(top, dense, deterministic=False, include_gifs=True): + gif_text = """ .. image:: ../assets/navigate{}1.mp4.gif :scale: 100 % :alt: @@ -94,9 +94,15 @@ def make_navigate_text(top, dense): :scale: 100 % :alt: -In this task, the agent must move to a goal location denoted by a diamond block. This represents a basic primitive used in many tasks throughout Minecraft. In addition to standard observations, the agent has access to a “compass” observation, which points near the goal location, 64 meters from the start location. The goal has a small random horizontal offset from the compass location and may be slightly below surface level. On the goal location is a unique block, so the agent must find the final goal by searching based on local visual features. + """ + navigate_text = gif_text if include_gifs else "" # Check if GIFs are included in the docstring + navigate_text += """ +In this task, the agent must move to a goal location denoted by a diamond block. This represents a basic primitive used in many tasks throughout Minecraft. In addition to standard observations, the agent has access to a “compass” observation, which points near the goal location, 64 meters from the start location. """ + if not deterministic: + navigate_text += """The goal has a small random horizontal offset from the compass location and may be slightly below surface level. On the goal location is a unique block, so the agent must find the final goal by searching based on local visual features. """ + navigate_text += """ +The agent is given a sparse reward (+100 upon reaching the goal, at which point the episode terminates).""" -The agent is given a sparse reward (+100 upon reaching the goal, at which point the episode terminates). """ if dense: navigate_text += "**This variant of the environment is dense reward-shaped where the agent is given a reward every tick for how much closer (or negative reward for farther) the agent gets to the target.**\n" else: @@ -105,6 +111,8 @@ def make_navigate_text(top, dense): if top is "normal": navigate_text += "\nIn this environment, the agent spawns on a random survival map.\n" navigate_text = navigate_text.format(*["" for _ in range(4)]) + elif top is "flat": + navigate_text += "\nIn this environment, the agent spawns on a flat world survival map.\n" else: navigate_text += "\nIn this environment, the agent spawns in an extreme hills biome.\n" navigate_text = navigate_text.format(*["extreme" for _ in range(4)]) @@ -163,7 +171,7 @@ def make_navigate_text(top, dense): 'xml': os.path.join(missions_dir, 'navigationDenseFlatDeterministic.xml'), 'observation_space': navigate_observation_space, 'action_space': navigate_action_space, - 'docstr': make_navigate_text('normal', True) + 'docstr': make_navigate_text('flat', True, deterministic=True, include_gifs=False) }, max_episode_steps=2000, ) @@ -175,7 +183,7 @@ def make_navigate_text(top, dense): 'xml': os.path.join(missions_dir, 'navigationDenseFlat.xml'), 'observation_space': navigate_observation_space, 'action_space': navigate_action_space, - 'docstr': make_navigate_text('normal', True) + 'docstr': make_navigate_text('flat', True, deterministic=False, include_gifs=False) }, max_episode_steps=2000, )