Skip to content

Commit

Permalink
Updated the missions. I had to fix the rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
drkostas committed Dec 12, 2022
1 parent a4f18f0 commit c80a9bc
Show file tree
Hide file tree
Showing 161 changed files with 4,397 additions and 5,546 deletions.
103 changes: 37 additions & 66 deletions demo_no_RL.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -18,7 +18,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand All @@ -42,7 +42,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 12,
"metadata": {},
"outputs": [
{
Expand All @@ -52,7 +52,16 @@
"Generating new seed ...\n",
"Loading environment ...\n",
"Resetting environment ...\n",
"Environment Loaded!\n"
"Environment Loaded!\n",
"Possible actions and action space actions for current env:\n",
"Action: 0 -> move 1\n",
"Action: 1 -> move -1\n",
"Action: 2 -> strafe 1\n",
"Action: 3 -> strafe -1\n",
"Action: 4 -> turn 1\n",
"Action: 5 -> turn -1\n",
"Sampling an action..\n",
"2 -> strafe 1\n"
]
}
],
Expand All @@ -75,8 +84,8 @@
"env = MalmoMazeEnv(\n",
" mazeseed=maze_seed,\n",
" xml=env_config[\"xml\"],\n",
" width=env_config[\"width\"],\n",
" height=env_config[\"height\"],\n",
" width=900,#env_config[\"width\"],\n",
" height=800,#env_config[\"height\"],\n",
" millisec_per_tick=env_config['millisec_per_tick'],\n",
" mission_timeout_ms=env_config['mission_timeout_ms'],\n",
" step_reward=env_config['step_reward'],\n",
Expand All @@ -89,88 +98,50 @@
"print(\"Resetting environment ...\")\n",
"_ = env.reset()\n",
"print(\"Environment Loaded!\")\n",
"obs, reward, done, info = env.step(5)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Possible actions and action space actions for current env:\n",
"Action: 0 -> move 1\n",
"Action: 1 -> move -1\n",
"Action: 2 -> strafe 1\n",
"Action: 3 -> strafe -1\n",
"Action: 4 -> turn 1\n",
"Action: 5 -> turn -1\n"
]
}
],
"source": [
"\n",
"print(\"Possible actions and action space actions for current env:\")\n",
"for action in range(6):\n",
" print(f\"Action: {action} -> {env.action_space[action]}\")"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Sample an action\n",
"5 -> turn -1\n"
]
}
],
"source": [
"print(\"Sample an action\")\n",
" print(f\"Action: {action} -> {env.action_space[action]}\")\n",
"print(\"Sampling an action..\")\n",
"action = env.action_space.sample()\n",
"print(f'{action} -> {env.action_space[action]}')"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
"# Take an action and get the observation, reward, done, and info\n",
"obs, reward, done, info = env.step(0)"
]
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Reward: -1.0\n",
"Done: False\n",
"Info: WorldState (running): 235 obs, 1 rewards, 1363 frames since last state.\n",
"Info.observations: len=1 type=<class 'malmo.MalmoPython.TimestampedString'>\n",
"Observation: type=<class 'numpy.ndarray'>, shape=(84, 84, 3)\n"
"Reward: -1\n",
"Done: True\n",
"Info: WorldState (ended): 0 obs, 0 rewards, 0 frames since last state.\n"
]
},
{
"ename": "IndexError",
"evalue": "Index out of range",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-11-4727b39f0106>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Done: \"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Info: \"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0minfo\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m print(f\"Info.observations: len={len(info.observations)} \"\\\n\u001b[0m\u001b[1;32m 7\u001b[0m f\"type={type(info.observations[0])}\")\n\u001b[1;32m 8\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"Observation: type={type(obs)}, shape={obs.shape}\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mIndexError\u001b[0m: Index out of range"
]
}
],
"source": [
"# Take an action and get the observation, reward, done, and info\n",
"obs, reward, done, info = env.step(0)\n",
"print(\"Reward: \", reward)\n",
"print(\"Done: \", done)\n",
"print(\"Info: \", info)\n",
"print(f\"Info.observations: len={len(info.observations)} \"\\\n",
" f\"type={type(info.observations[0])}\")\n",
"print(f\"Observation: type={type(obs)}, shape={obs.shape}\")\n"
"print(f\"Observation: type={type(obs)}, shape={obs.shape}\")"
]
},
{
Expand Down Expand Up @@ -269,7 +240,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.15 (default, Dec 9 2022, 19:43:09) \n[GCC Apple LLVM 14.0.0 (clang-1400.0.29.202)]"
"version": "3.6.15"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
63 changes: 28 additions & 35 deletions missions/mazes/maze0.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Mission xmlns="http://ProjectMalmo.microsoft.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<About>
<Summary>Survive the farm fire!</Summary>
</About>

<ModSettings>
<MsPerTick>{PLACEHOLDER_MSPERTICK}</MsPerTick>
</ModSettings>

<ServerSection>
<ServerInitialConditions>
<Time>
Expand All @@ -20,34 +16,32 @@
<AllowSpawning>true</AllowSpawning>
</ServerInitialConditions>
<ServerHandlers>

<FlatWorldGenerator generatorString="3;7,220*1,5*3,2;3;,biome_1"/>
<DrawingDecorator>
<DrawCuboid x1="0" y1="226" z1="0" x2="6" y2="246" z2="6" type="netherrack"/>
<DrawCuboid x1="1" y1="227" z1="1" x2="5" y2="246" z2="5" type="air"/>
<DrawCuboid x1="1" y1="227" z1="1" x2="5" y2="227" z2="5" type="sea_lantern"/>
<DrawCuboid x1="1" y1="227" z1="1" x2="1" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="2" y1="227" z1="1" x2="2" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="1" x2="3" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="4" y1="227" z1="1" x2="4" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="1" x2="5" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="2" x2="3" y2="227" z2="2" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="2" x2="5" y2="227" z2="2" type="carpet"/>
<DrawCuboid x1="1" y1="227" z1="3" x2="1" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="2" y1="227" z1="3" x2="2" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="3" x2="3" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="4" y1="227" z1="3" x2="4" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="3" x2="5" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="1" y1="227" z1="4" x2="1" y2="227" z2="4" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="4" x2="3" y2="227" z2="4" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="4" x2="5" y2="227" z2="4" type="carpet"/>
<DrawCuboid x1="1" y1="227" z1="5" x2="1" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="2" y1="227" z1="5" x2="2" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="5" x2="3" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="4" y1="227" z1="5" x2="4" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="5" x2="5" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="3" x2="5" y2="229" z2="3" type="emerald_block"/>

<DrawCuboid x1="1" y1="227" z1="1" x2="5" y2="246" z2="5" type="air"/>
<DrawCuboid x1="1" y1="227" z1="1" x2="5" y2="227" z2="5" type="sea_lantern"/>
<DrawCuboid x1="1" y1="227" z1="1" x2="1" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="2" y1="227" z1="1" x2="2" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="1" x2="3" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="4" y1="227" z1="1" x2="4" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="1" x2="5" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="2" x2="3" y2="227" z2="2" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="2" x2="5" y2="227" z2="2" type="carpet"/>
<DrawCuboid x1="1" y1="227" z1="3" x2="1" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="2" y1="227" z1="3" x2="2" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="3" x2="3" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="4" y1="227" z1="3" x2="4" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="3" x2="5" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="1" y1="227" z1="4" x2="1" y2="227" z2="4" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="4" x2="3" y2="227" z2="4" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="4" x2="5" y2="227" z2="4" type="carpet"/>
<DrawCuboid x1="1" y1="227" z1="5" x2="1" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="2" y1="227" z1="5" x2="2" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="5" x2="3" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="4" y1="227" z1="5" x2="4" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="5" x2="5" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="3" x2="5" y2="229" z2="3" type="emerald_block"/>
<DrawCuboid x1="1" y1="227" z1="1" x2="1" y2="227" z2="1" type="fire"/>
<DrawCuboid x1="0" y1="227" z1="6" x2="6" y2="246" z2="6" type="beacon"/>
<DrawCuboid x1="0" y1="227" z1="0" x2="6" y2="246" z2="0" type="beacon"/>
Expand All @@ -59,7 +53,6 @@
<ServerQuitFromTimeUp timeLimitMs="{PLACEHOLDER_MISSION_TIMEOUT_MS}"/>
</ServerHandlers>
</ServerSection>

<AgentSection mode="Survival">
<Name>Survivor</Name>
<AgentStart>
Expand All @@ -85,12 +78,12 @@
</Grid>
</ObservationFromGrid>
<RewardForTouchingBlockType>
<Block reward="{PLACEHOLDER_LOSE_REWARD}"type="emerald_block"/>
<Block reward="-50.0" type="fire"/>
<Block reward="{PLACEHOLDER_WIN_REWARD}" type="emerald_block"/>
<Block reward="{PLACEHOLDER_STEP_REWARD}" type="fire"/>

</RewardForTouchingBlockType>
<RewardForSendingCommand reward="-1"/>
<RewardForMissionEnd rewardForDeath="-10.0">
<RewardForMissionEnd rewardForDeath="{PLACEHOLDER_LOSE_REWARD}">
<Reward description="found_goal" reward="{PLACEHOLDER_WIN_REWARD}"/>
<Reward description="out_of_time" reward="{PLACEHOLDER_LOSE_REWARD}"/>
</RewardForMissionEnd>
Expand All @@ -99,4 +92,4 @@
</AgentQuitFromTouchingBlockType>
</AgentHandlers>
</AgentSection>
</Mission>
</Mission>
63 changes: 28 additions & 35 deletions missions/mazes/maze1.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Mission xmlns="http://ProjectMalmo.microsoft.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<About>
<Summary>Survive the farm fire!</Summary>
</About>

<ModSettings>
<MsPerTick>{PLACEHOLDER_MSPERTICK}</MsPerTick>
</ModSettings>

<ServerSection>
<ServerInitialConditions>
<Time>
Expand All @@ -20,34 +16,32 @@
<AllowSpawning>true</AllowSpawning>
</ServerInitialConditions>
<ServerHandlers>

<FlatWorldGenerator generatorString="3;7,220*1,5*3,2;3;,biome_1"/>
<DrawingDecorator>
<DrawCuboid x1="0" y1="226" z1="0" x2="6" y2="246" z2="6" type="netherrack"/>
<DrawCuboid x1="1" y1="227" z1="1" x2="5" y2="246" z2="5" type="air"/>
<DrawCuboid x1="1" y1="227" z1="1" x2="5" y2="227" z2="5" type="sea_lantern"/>
<DrawCuboid x1="1" y1="227" z1="1" x2="1" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="2" y1="227" z1="1" x2="2" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="1" x2="3" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="4" y1="227" z1="1" x2="4" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="1" x2="5" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="1" y1="227" z1="2" x2="1" y2="227" z2="2" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="2" x2="3" y2="227" z2="2" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="2" x2="5" y2="227" z2="2" type="carpet"/>
<DrawCuboid x1="1" y1="227" z1="3" x2="1" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="2" y1="227" z1="3" x2="2" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="3" x2="3" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="4" y1="227" z1="3" x2="4" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="3" x2="5" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="4" x2="3" y2="227" z2="4" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="4" x2="5" y2="227" z2="4" type="carpet"/>
<DrawCuboid x1="1" y1="227" z1="5" x2="1" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="2" y1="227" z1="5" x2="2" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="5" x2="3" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="4" y1="227" z1="5" x2="4" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="5" x2="5" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="3" x2="5" y2="229" z2="3" type="emerald_block"/>

<DrawCuboid x1="1" y1="227" z1="1" x2="5" y2="246" z2="5" type="air"/>
<DrawCuboid x1="1" y1="227" z1="1" x2="5" y2="227" z2="5" type="sea_lantern"/>
<DrawCuboid x1="1" y1="227" z1="1" x2="1" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="2" y1="227" z1="1" x2="2" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="1" x2="3" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="4" y1="227" z1="1" x2="4" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="1" x2="5" y2="227" z2="1" type="carpet"/>
<DrawCuboid x1="1" y1="227" z1="2" x2="1" y2="227" z2="2" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="2" x2="3" y2="227" z2="2" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="2" x2="5" y2="227" z2="2" type="carpet"/>
<DrawCuboid x1="1" y1="227" z1="3" x2="1" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="2" y1="227" z1="3" x2="2" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="3" x2="3" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="4" y1="227" z1="3" x2="4" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="3" x2="5" y2="227" z2="3" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="4" x2="3" y2="227" z2="4" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="4" x2="5" y2="227" z2="4" type="carpet"/>
<DrawCuboid x1="1" y1="227" z1="5" x2="1" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="2" y1="227" z1="5" x2="2" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="3" y1="227" z1="5" x2="3" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="4" y1="227" z1="5" x2="4" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="5" x2="5" y2="227" z2="5" type="carpet"/>
<DrawCuboid x1="5" y1="227" z1="3" x2="5" y2="229" z2="3" type="emerald_block"/>
<DrawCuboid x1="1" y1="227" z1="1" x2="1" y2="227" z2="1" type="fire"/>
<DrawCuboid x1="0" y1="227" z1="6" x2="6" y2="246" z2="6" type="beacon"/>
<DrawCuboid x1="0" y1="227" z1="0" x2="6" y2="246" z2="0" type="beacon"/>
Expand All @@ -59,7 +53,6 @@
<ServerQuitFromTimeUp timeLimitMs="{PLACEHOLDER_MISSION_TIMEOUT_MS}"/>
</ServerHandlers>
</ServerSection>

<AgentSection mode="Survival">
<Name>Survivor</Name>
<AgentStart>
Expand All @@ -85,12 +78,12 @@
</Grid>
</ObservationFromGrid>
<RewardForTouchingBlockType>
<Block reward="{PLACEHOLDER_LOSE_REWARD}"type="emerald_block"/>
<Block reward="-50.0" type="fire"/>
<Block reward="{PLACEHOLDER_WIN_REWARD}" type="emerald_block"/>
<Block reward="{PLACEHOLDER_STEP_REWARD}" type="fire"/>

</RewardForTouchingBlockType>
<RewardForSendingCommand reward="-1"/>
<RewardForMissionEnd rewardForDeath="-10.0">
<RewardForMissionEnd rewardForDeath="{PLACEHOLDER_LOSE_REWARD}">
<Reward description="found_goal" reward="{PLACEHOLDER_WIN_REWARD}"/>
<Reward description="out_of_time" reward="{PLACEHOLDER_LOSE_REWARD}"/>
</RewardForMissionEnd>
Expand All @@ -99,4 +92,4 @@
</AgentQuitFromTouchingBlockType>
</AgentHandlers>
</AgentSection>
</Mission>
</Mission>
Loading

0 comments on commit c80a9bc

Please sign in to comment.