Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Refactoring super function call in agents.py #321 #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 7, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,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
Expand Down Expand Up @@ -452,7 +452,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)"""
Expand All @@ -471,11 +471,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)

Expand Down Expand Up @@ -525,7 +525,7 @@ 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

Expand All @@ -536,8 +536,8 @@ def add_obstacle(self, coordinates):
class PolygonObstacle(Obstacle):

def __init__(self, coordinates):
"""Coordinates is a list of tuples."""
super(PolygonObstacle, self).__init__()
""" Coordinates is a list of tuples."""
super().__init__()
self.coordinates = coordinates

# ______________________________________________________________________________
Expand All @@ -556,7 +556,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):
Expand All @@ -579,7 +579,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
Expand All @@ -593,7 +593,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'])}

Expand Down Expand Up @@ -677,7 +677,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):
Expand Down