@@ -329,7 +329,7 @@ class Direction():
329329 To change directions:
330330 d = d + "right" or d = d + Direction.R #Both do the same thing
331331 Note that the argument to __add__ must be a string and not a Direction object.
332- Also, it (the argument) can only be right or left. '''
332+ Also, it (the argument) can only be right or left.'''
333333
334334 R = "right"
335335 L = "left"
@@ -428,8 +428,8 @@ def default_location(self, thing):
428428 return (random .choice (self .width ), random .choice (self .height ))
429429
430430 def move_to (self , thing , destination ):
431- '''Move a thing to a new location. Returns True on success or False if there is an Obstacle
432- If thing is grabbing anything, they move with him '''
431+ '''Move a thing to a new location. Returns True on success or False if there is an Obstacle.
432+ If thing is holding anything, they move with him. '''
433433 thing .bump = self .some_things_at (destination , Obstacle )
434434 if not thing .bump :
435435 thing .location = destination
@@ -451,7 +451,7 @@ def move_to(self, thing, destination):
451451 def add_thing (self , thing , location = (1 , 1 ), exclude_duplicate_class_items = False ):
452452 '''Adds things to the world.
453453 If (exclude_duplicate_class_items) then the item won't be added if the location
454- has at least one item of the same class'''
454+ has at least one item of the same class. '''
455455 if (self .is_inbounds (location )):
456456 if (exclude_duplicate_class_items and
457457 any (isinstance (t , thing .__class__ ) for t in self .list_things_at (location ))):
@@ -526,7 +526,7 @@ class Wall(Obstacle):
526526# Continuous environment
527527
528528class ContinuousWorld (Environment ):
529- """ Model for Continuous World. """
529+ """ Model for Continuous World."""
530530 def __init__ (self , width = 10 , height = 10 ):
531531 super (ContinuousWorld , self ).__init__ ()
532532 self .width = width
@@ -538,7 +538,7 @@ def add_obstacle(self, coordinates):
538538
539539class PolygonObstacle (Obstacle ):
540540 def __init__ (self , coordinates ):
541- """ Coordinates is a list of tuples. """
541+ """ Coordinates is a list of tuples."""
542542 super (PolygonObstacle , self ).__init__ ()
543543 self .coordinates = coordinates
544544
@@ -715,7 +715,7 @@ def init_world(self, program):
715715 self .add_thing (Explorer (program ), (1 , 1 ), True )
716716
717717 def get_world (self , show_walls = True ):
718- '''returns the items in the world'''
718+ '''Returns the items in the world'''
719719 result = []
720720 x_start , y_start = (0 , 0 ) if show_walls else (1 , 1 )
721721 x_end , y_end = (self .width , self .height ) if show_walls else (self .width - 1 , self .height - 1 )
@@ -765,8 +765,8 @@ def percept(self, agent):
765765 return result
766766
767767 def execute_action (self , agent , action ):
768- '''Modify the state of the environment based on the agent's actions
769- Performance score taken directly out of the book'''
768+ '''Modify the state of the environment based on the agent's actions.
769+ Performance score taken directly out of the book. '''
770770
771771 if isinstance (agent , Explorer ) and self .in_danger (agent ):
772772 return
@@ -818,7 +818,7 @@ def in_danger(self, agent):
818818
819819 def is_done (self ):
820820 '''The game is over when the Explorer is killed
821- or if he climbs out of the cave only at (1,1)'''
821+ or if he climbs out of the cave only at (1,1). '''
822822 explorer = [agent for agent in self .agents if isinstance (agent , Explorer ) ]
823823 if len (explorer ):
824824 if explorer [0 ].alive :
0 commit comments