From d213b348f8a4a2434c655331c9d00a43f819af46 Mon Sep 17 00:00:00 2001 From: articuno12 Date: Mon, 6 Mar 2017 12:06:12 +0530 Subject: [PATCH] Update agents.py --- agents.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/agents.py b/agents.py index 650dfe97b..3e3d32a4d 100644 --- a/agents.py +++ b/agents.py @@ -384,7 +384,7 @@ class XYEnvironment(Environment): that are held.""" def __init__(self, width=10, height=10): - super(XYEnvironment, self).__init__() + super().__init__() self.width = width self.height = height @@ -456,7 +456,7 @@ def add_thing(self, thing, location=(1, 1), exclude_duplicate_class_items=False) if (exclude_duplicate_class_items and any(isinstance(t, thing.__class__) for t in self.list_things_at(location))): return - super(XYEnvironment, self).add_thing(thing, location) + super().add_thing(thing, location) def is_inbounds(self, location): '''Checks to make sure that the location is inbounds (within walls if we have walls)''' @@ -475,11 +475,11 @@ def delete_thing(self, thing): '''Deletes thing, and everything it is holding (if thing is an agent)''' if isinstance(thing, Agent): for obj in thing.holding: - super(XYEnvironment, self).delete_thing(obj) + super().delete_thing(obj) for obs in self.observers: obs.thing_deleted(obj) - super(XYEnvironment, self).delete_thing(thing) + super().delete_thing(thing) for obs in self.observers: obs.thing_deleted(thing) @@ -528,7 +528,7 @@ class Wall(Obstacle): class ContinuousWorld(Environment): """ Model for Continuous World.""" def __init__(self, width=10, height=10): - super(ContinuousWorld, self).__init__() + super().__init__() self.width = width self.height = height @@ -539,7 +539,7 @@ def add_obstacle(self, coordinates): class PolygonObstacle(Obstacle): def __init__(self, coordinates): """ Coordinates is a list of tuples.""" - super(PolygonObstacle, self).__init__() + super().__init__() self.coordinates = coordinates # ______________________________________________________________________________ @@ -558,7 +558,7 @@ class VacuumEnvironment(XYEnvironment): each turn taken.""" def __init__(self, width=10, height=10): - super(VacuumEnvironment, self).__init__(width, height) + super().__init__(width, height) self.add_walls() def thing_classes(self): @@ -581,7 +581,7 @@ def execute_action(self, agent, action): agent.performance += 100 self.delete_thing(dirt) else: - super(VacuumEnvironment, self).execute_action(agent, action) + super().execute_action(agent, action) if action != 'NoOp': agent.performance -= 1 @@ -595,7 +595,7 @@ class TrivialVacuumEnvironment(Environment): Environment.""" def __init__(self): - super(TrivialVacuumEnvironment, self).__init__() + super().__init__() self.status = {loc_A: random.choice(['Clean', 'Dirty']), loc_B: random.choice(['Clean', 'Dirty'])} @@ -680,7 +680,7 @@ class WumpusEnvironment(XYEnvironment): # Room should be 4x4 grid of rooms. The extra 2 for walls def __init__(self, agent_program, width=6, height=6): - super(WumpusEnvironment, self).__init__(width, height) + super().__init__(width, height) self.init_world(agent_program) def init_world(self, program):