Skip to content

Commit

Permalink
added comment about use of super
Browse files Browse the repository at this point in the history
tried to explain why they are using super in the __init__
  • Loading branch information
giladgressel authored Sep 2, 2016
1 parent 86cf11e commit fbd4ebc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions projects/smartcab/smartcab/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ class LearningAgent(Agent):
"""An agent that learns to drive in the smartcab world."""

def __init__(self, env):

#question - Why are they using super() here? and what does it mean?

super(LearningAgent, self).__init__(env) # sets self.env = env, state = None, next_waypoint = None, and a default color

#super is a way inherit the parent class of the Learningagent. In this case, that's Agent, which already has an env set,
#so by calling super, we inherit the env from the agent superclass, this insures that we all agents are running in the same env

self.color = 'red' # override color
self.planner = RoutePlanner(self.env, self) # simple route planner to get next_waypoint
# TODO: Initialize any additional variables here
Expand Down

0 comments on commit fbd4ebc

Please sign in to comment.