Skip to content

Commit

Permalink
Merge branch 'master' of github.com:matrx-software/matrx
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjalling Haije committed Jul 20, 2021
2 parents f526a55 + 379af7d commit fa0e9f7
Show file tree
Hide file tree
Showing 33 changed files with 1,974 additions and 318 deletions.
8 changes: 6 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
from matrx import cases

if __name__ == "__main__":
cases.run_vis_test()
# cases.run_vis_test()
# cases.run_vis_test2()
# cases.run_test()
# cases.run_simple_case()
# cases.run_test_navigators()
# cases.run_bw4t()
cases.run_bw4t()
# cases.run_logger_test()
# cases.run_arg_test()
# cases.run_test_human_agent()
2 changes: 1 addition & 1 deletion matrx/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
__url__ = 'https://matrx-software.com'
__doc_url__ = 'http://docs.matrx-software.com/en/latest/'
__source_url__ = 'https://github.com/matrx-software/matrx'
__version__ = '2.0.8'
__version__ = '2.1.0'
__author__ = 'MATRX Team at TNO.nl'
__author_email__ = '[email protected]'
__license__ = 'MIT License'
Expand Down
16 changes: 13 additions & 3 deletions matrx/actions/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, duration_in_ticks=0):
# number of ticks the action takes to complete
self.duration_in_ticks = duration_in_ticks

def mutate(self, grid_world, agent_id, **kwargs):
def mutate(self, grid_world, agent_id, world_state, **kwargs):
""" Method that mutates the world.
This method is allowed to mutate a :class:`matrx.grid_world.GridWorld`
Expand All @@ -44,11 +44,16 @@ def mutate(self, grid_world, agent_id, **kwargs):
Parameters
----------
grid_world
grid_world : GridWorld
The GridWorld instance that should be mutated according to the
Action's intended purpose.
agent_id : string
The unique identifier of the agent performing this action.
world_state : State
The State object representing the entire world. Can be used to
simplify search of objects and properties when performing an
action. Note that this is the State of the entire world, not
that of the agent performing the action.
**kwargs
The set of keyword arguments provided by the agent that decided
upon this action. When overriding this method and setting required
Expand Down Expand Up @@ -98,7 +103,7 @@ def mutate(self, grid_world, agent_id, **kwargs):
"""
return None

def is_possible(self, grid_world, agent_id, **kwargs):
def is_possible(self, grid_world, agent_id, world_state, **kwargs):
""" Checks if the Action is possible.
This method analyses a :class:`matrx.grid_world.GridWorld` instance
Expand All @@ -112,6 +117,11 @@ def is_possible(self, grid_world, agent_id, **kwargs):
is possible.
agent_id : string
The unique identifier of the agent performing this action.
world_state : State
The State object representing the entire world. Can be used to
simplify search of objects and properties when checking if an
action can be performed. Note that this is the State of the
entire world, not that of the agent performing the action.
kwargs : dictionary
The set of keyword arguments provided by the Agent that decided
upon this action. When overriding this method and setting required
Expand Down
54 changes: 33 additions & 21 deletions matrx/actions/door_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class OpenDoorAction(Action):
def __init__(self, duration_in_ticks=0):
super().__init__(duration_in_ticks)

def mutate(self, grid_world, agent_id, **kwargs):
def mutate(self, grid_world, agent_id, world_state, **kwargs):
""" Opens a door in the world.
Mutates the `door_status` of an
Expand All @@ -50,11 +50,14 @@ def mutate(self, grid_world, agent_id, **kwargs):
agent_id : str
The string representing the unique identifier that represents the
agent performing this action.
object_id : st
Optional. Default: ``None``
world_state : State
The State object representing the entire world. Can be used to
simplify search of objects and properties when performing an
action. Note that this is the State of the entire world, not
that of the agent performing the action.
object_id : str (Optional. Default: None)
The string representing the unique identifier of the door that
should be opened.
should be opened. If none is given, the closest door is selected.
door_range : int
Optional. Default: ``np.inf``
Expand Down Expand Up @@ -89,7 +92,7 @@ def mutate(self, grid_world, agent_id, **kwargs):
result = OpenDoorActionResult(OpenDoorActionResult.RESULT_SUCCESS, True)
return result

def is_possible(self, grid_world, agent_id, **kwargs):
def is_possible(self, grid_world, agent_id, world_state, **kwargs):
""" Check if the OpenDoorAction is possible.
Parameters
Expand All @@ -100,11 +103,14 @@ def is_possible(self, grid_world, agent_id, **kwargs):
agent_id : str
The string representing the unique identifier that represents the
agent performing this action.
object_id : str
Optional. Default: ``None``
world_state : State
The State object representing the entire world. Can be used to
simplify search of objects and properties when checking if an
action can be performed. Note that this is the State of the
entire world, not that of the agent performing the action.
object_id : str (Optional. Default: None)
The string representing the unique identifier of the door that
should be opened.
should be opened. If none is given, the closest door is selected.
door_range : int
Optional. Default: ``np.inf``
Expand Down Expand Up @@ -157,7 +163,7 @@ class CloseDoorAction(Action):
def __init__(self, duration_in_ticks=0):
super().__init__(duration_in_ticks)

def mutate(self, grid_world, agent_id, **kwargs):
def mutate(self, grid_world, agent_id, world_state, **kwargs):
""" Closes a door in the world.
Mutates the `door_status` of an
Expand All @@ -175,11 +181,14 @@ def mutate(self, grid_world, agent_id, **kwargs):
agent_id : str
The string representing the unique identifier that represents the
agent performing this action.
object_id : st
Optional. Default: ``None``
world_state : State
The State object representing the entire world. Can be used to
simplify search of objects and properties when performing an
action. Note that this is the State of the entire world, not
that of the agent performing the action.
object_id : str (Optional. Default: None)
The string representing the unique identifier of the door that
should be closed.
should be opened. If none is given, the closest door is selected.
door_range : int
Optional. Default: ``np.inf``
Expand Down Expand Up @@ -211,7 +220,7 @@ def mutate(self, grid_world, agent_id, **kwargs):
result = CloseDoorActionResult(CloseDoorActionResult.RESULT_SUCCESS, True)
return result

def is_possible(self, grid_world, agent_id, **kwargs):
def is_possible(self, grid_world, agent_id, world_state, **kwargs):
"""Check if the CloseDoorAction is possible.
Parameters
Expand All @@ -222,11 +231,14 @@ def is_possible(self, grid_world, agent_id, **kwargs):
agent_id : str
The string representing the unique identifier that represents the
agent performing this action.
object_id : str
Optional. Default: ``None``
world_state : State
The State object representing the entire world. Can be used to
simplify search of objects and properties when checking if an
action can be performed. Note that this is the State of the
entire world, not that of the agent performing the action.
object_id : str (Optional. Default: None)
The string representing the unique identifier of the door that
should be closed.
should be opened. If none is given, the closest door is selected.
door_range : int
Optional. Default: ``np.inf``
Expand Down Expand Up @@ -381,7 +393,7 @@ def _is_possible_door_open_close(grid_world, agent_id, action_result, object_id=
objects_in_range = grid_world.get_objects_in_range(loc_agent, object_type=Door, sense_range=door_range)

# there is no Door in range, so not possible to open any door
if len(objects_in_range) is 0:
if len(objects_in_range) == 0:
return action_result(action_result.NO_DOORS_IN_RANGE, False)

# if we did not get a specific door to open, we simply return success as it is possible to open an arbitrary door
Expand Down
14 changes: 12 additions & 2 deletions matrx/actions/move_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def __init__(self, duration_in_ticks=0):
self.dx = 0
self.dy = 0

def is_possible(self, grid_world, agent_id, **kwargs):
def is_possible(self, grid_world, agent_id, world_state, **kwargs):
""" Checks if the move is possible.
Checks for the following:
Expand All @@ -263,6 +263,11 @@ def is_possible(self, grid_world, agent_id, **kwargs):
agent_id : str
The unique identifier for the agent whose location should be
changed.
world_state : State
The State object representing the entire world. Can be used to
simplify search of objects and properties when checking if an
action can be performed. Note that this is the State of the
entire world, not that of the agent performing the action.
**kwargs : dict
Not used.
Expand All @@ -278,7 +283,7 @@ def is_possible(self, grid_world, agent_id, **kwargs):
result = _is_possible_movement(grid_world, agent_id=agent_id, dx=self.dx, dy=self.dy)
return result

def mutate(self, grid_world, agent_id, **kwargs):
def mutate(self, grid_world, agent_id, world_state, **kwargs):
""" Mutates an agent's location
Changes an agent's location property based on the attributes `dx` and
Expand All @@ -289,6 +294,11 @@ def mutate(self, grid_world, agent_id, **kwargs):
grid_world : GridWorld
The :class:`matrx.grid_world.GridWorld` instance in which the
agent resides whose location should be updated.
world_state : State
The State object representing the entire world. Can be used to
simplify search of objects and properties when performing an
action. Note that this is the State of the entire world, not
that of the agent performing the action.
agent_id : str
The unique identifier for the agent whose location should be
changed.
Expand Down
Loading

0 comments on commit fa0e9f7

Please sign in to comment.