Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
sazio committed Jun 19, 2019
1 parent 8904451 commit 7b62bee
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 59 deletions.
Binary file modified Navigation tasks in a reinforcement learning framework.pdf
Binary file not shown.
121 changes: 102 additions & 19 deletions PlotFitness.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions maze.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
**Main file** - it runs the mission
Basically, after loading the world (.xml file) it starts with two concatenated while statements (formally the mission is a concatenated while statement).
The second one represents each run. In the end it calculates the score and it saves a .csv file (log file) by setting the score inside the algorithm.
We used time.sleep(2) in order to avoid issues related to items counting (stochastics fluctuations in time are significant and most of the times the set_score
Basically, after loading the world (*.xml* file) it starts with two concatenated while statements (formally the mission is a concatenated while statement).
The second one represents each run. In the end it calculates the score and it saves a *.csv* file (log file) by setting the selected algorithm's score.
We used *time.sleep(2)* in order to avoid issues related to items counting (stochastics fluctuations in time are significant and most of the times the set_score
function wouldn't work because of that, compromising the learning process)
"""
Expand Down
76 changes: 40 additions & 36 deletions mission.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# “Code is more often read than written.” --Guido Van Rossum
# author : Simone Azeglio

""" **********
mission.py
**********
======================================
"""

# “Code is more often read than written.” --Guido Van Rossum
# author : Simone Azeglio

import MalmoPython
import os
import sys
Expand All @@ -27,21 +27,23 @@ class mission:
Methods
-------
load(mission_file)
Load the world from XML file and create default Malmo objects
Load the world from *.xml* file and create default **Malmo** objects
start()
Set client pool , client info , reset the world for each new mission, set dimensions
of the video and agent's viewpoint. Attempt to start a mission for 10 times if there's any
issue occurring, when the mission starts it keeps counting the time.
Set client pool, client info , reset the world for each new mission, set dimensions
of the video-window and agent's viewpoint. Attempt to start a mission for 10 times if there's any
issue occurring (some stochastics errors - take a look at Malmo's official documentation:
https://github.com/microsoft/malmo ), when the mission starts it keeps counting the time.
is_running()
return True if mission is running
Check if the mission is currently running:
returns True if mission is running
get_observation()
loads floor grid, edge distances, current player position, and entity (e.g. diamond) position
Loads floor grid, edge distances, current player position, and entity (e.g. diamond) position
in order to let the agent know the distance to the diamond (odor-like representation).
It also counts collected items and exports the world view in a .json file.
Agent's observation is a 3x3 grid: he's in the center and he knows only 1 block in every
It also counts collected items and exports the world view in a *.json* file.
Agent's observation is a *3x3 grid*: he's in the center and he knows only 1 block in every
possible direction
send_command()
Expand All @@ -53,14 +55,14 @@ class mission:
It stops the time at the end of the mission (useful for score function based on time)
check_errors()
Check whether there are errors world_state. Those errors are typically related to Malmo Client
Check whether there are errors in the mission (check *world_state* Malmo's method). Those errors are typically related to Malmo Client
block_score()
The agent has to explore new blocks in order to get a better fitness, he gets a penalty by being in the same
The agent has to explore new blocks in order to get a better *fitness*, he gets a penalty by being in the same
block (no points for fitness)
time_score()
The agent gets one fitness point for each seconds he spend alive
The agent gets one fitness point for each seconds he spends alive
item_score()
The agent gets some more points for each item he picks up from the ground
Expand Down Expand Up @@ -261,28 +263,30 @@ class observation:

""" A class used to represent an observation of the world:
Attributes
----------
set_grid: str
Extracted from the .json World File by mission.get_observation()
The grid is the actual part of the world seen by the agent
set_edge_distances : str
Extracted from the .json World File by mission.get_observation()
Distances from the edges of the world (The world is limited)
set_cell : str
Extracted from the .json World File by mission.get_observation()
Cell is the agent location in the world (The agent has a GPS)
set_entity_locations : str
Extracted from the .json World File by mission.get_observation()
Locations of entities (e.g. Diamonds, Zombies)
Methods
-------
at_junction()
States whether a move is plausible or not : The agent can only walk over glowstone.
This is useful in order to limit the world with another material (e.g. Lava)
Attributes
----------
set_grid: str
Extracted from the *.json* World File by *mission.get_observation()*
The grid is the part of the world seen by the agent
set_edge_distances : str
Extracted from the *.json* World File by *mission.get_observation()*
Distances from the edges of the world (The world is limited)
set_cell : str
Extracted from the *.json* World File by *mission.get_observation()*
Cell is the agent location in the world (The agent has a GPS)
set_entity_locations : str
Extracted from the .json World File by mission.get_observation()
Locations of entities (e.g. Diamonds, Zombies)
Methods
-------
at_junction()
States whether a move is plausible or not : The agent can only walk over glowstone.
This is useful in order to limit the world with another material (e.g. Lava)
"""
def __init__(self, set_grid, set_edge_distances, set_cell, set_entity_locations):
Expand Down
2 changes: 1 addition & 1 deletion symbolicView.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"{\"floorAll\":[\"glowstone\",\"glowstone\",\"glowstone\",\"stone\",\"glowstone\",\"glowstone\",\"glowstone\",\"glowstone\",\"glowstone\"],\"distanceFromTop\":14.43087,\"distanceFromRight\":18.587631,\"distanceFromBottom\":17.269917,\"distanceFromLeft\":8.689074,\"entityCoordinates\":[{\"yaw\":-90.0,\"x\":8.5,\"y\":57.0,\"z\":-0.5,\"pitch\":0.0,\"id\":\"ee850806-f211-336a-8dc0-0593e9e5f12d\",\"motionX\":0.0,\"motionY\":-0.0784000015258789,\"motionZ\":0.0,\"life\":20.0,\"name\":\"SimoneBot\"}],\"cell\":\"(9,0)\",\"Hotbar_0_size\":1,\"Hotbar_0_item\":\"diamond\",\"Hotbar_1_size\":0,\"Hotbar_1_item\":\"air\",\"Hotbar_2_size\":0,\"Hotbar_2_item\":\"air\",\"Hotbar_3_size\":0,\"Hotbar_3_item\":\"air\",\"Hotbar_4_size\":0,\"Hotbar_4_item\":\"air\",\"Hotbar_5_size\":0,\"Hotbar_5_item\":\"air\",\"Hotbar_6_size\":0,\"Hotbar_6_item\":\"air\",\"Hotbar_7_size\":0,\"Hotbar_7_item\":\"air\",\"Hotbar_8_size\":0,\"Hotbar_8_item\":\"air\"}"
"{\"floorAll\":[\"glowstone\",\"glowstone\",\"stone\",\"glowstone\",\"glowstone\",\"stone\",\"glowstone\",\"glowstone\",\"stone\"],\"distanceFromTop\":15.435349,\"distanceFromRight\":22.660538,\"distanceFromBottom\":19.70406,\"distanceFromLeft\":5.2440443,\"entityCoordinates\":[{\"yaw\":-90.0,\"x\":4.5,\"y\":57.0,\"z\":-1.5,\"pitch\":0.0,\"id\":\"ee850806-f211-336a-8dc0-0593e9e5f12d\",\"motionX\":0.0,\"motionY\":-0.0784000015258789,\"motionZ\":0.0,\"life\":20.0,\"name\":\"SimoneBot\"},{\"yaw\":50.625,\"x\":6.7568359375,\"y\":57.0,\"z\":-2.5,\"pitch\":0.0,\"id\":\"b17069a2-5328-4f13-9e78-a8166c84b164\",\"motionX\":-2.8028471234421522E-46,\"motionY\":-0.0,\"motionZ\":0.0,\"quantity\":1,\"name\":\"diamond\"}],\"cell\":\"(5,-1)\",\"Hotbar_0_size\":0,\"Hotbar_0_item\":\"air\",\"Hotbar_1_size\":0,\"Hotbar_1_item\":\"air\",\"Hotbar_2_size\":0,\"Hotbar_2_item\":\"air\",\"Hotbar_3_size\":0,\"Hotbar_3_item\":\"air\",\"Hotbar_4_size\":0,\"Hotbar_4_item\":\"air\",\"Hotbar_5_size\":0,\"Hotbar_5_item\":\"air\",\"Hotbar_6_size\":0,\"Hotbar_6_item\":\"air\",\"Hotbar_7_size\":0,\"Hotbar_7_item\":\"air\",\"Hotbar_8_size\":0,\"Hotbar_8_item\":\"air\"}"

0 comments on commit 7b62bee

Please sign in to comment.