@@ -329,7 +329,7 @@ class Direction():
329
329
To change directions:
330
330
d = d + "right" or d = d + Direction.R #Both do the same thing
331
331
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.'''
333
333
334
334
R = "right"
335
335
L = "left"
@@ -428,8 +428,8 @@ def default_location(self, thing):
428
428
return (random .choice (self .width ), random .choice (self .height ))
429
429
430
430
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. '''
433
433
thing .bump = self .some_things_at (destination , Obstacle )
434
434
if not thing .bump :
435
435
thing .location = destination
@@ -451,7 +451,7 @@ def move_to(self, thing, destination):
451
451
def add_thing (self , thing , location = (1 , 1 ), exclude_duplicate_class_items = False ):
452
452
'''Adds things to the world.
453
453
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. '''
455
455
if (self .is_inbounds (location )):
456
456
if (exclude_duplicate_class_items and
457
457
any (isinstance (t , thing .__class__ ) for t in self .list_things_at (location ))):
@@ -526,7 +526,7 @@ class Wall(Obstacle):
526
526
# Continuous environment
527
527
528
528
class ContinuousWorld (Environment ):
529
- """ Model for Continuous World. """
529
+ """ Model for Continuous World."""
530
530
def __init__ (self , width = 10 , height = 10 ):
531
531
super (ContinuousWorld , self ).__init__ ()
532
532
self .width = width
@@ -538,7 +538,7 @@ def add_obstacle(self, coordinates):
538
538
539
539
class PolygonObstacle (Obstacle ):
540
540
def __init__ (self , coordinates ):
541
- """ Coordinates is a list of tuples. """
541
+ """ Coordinates is a list of tuples."""
542
542
super (PolygonObstacle , self ).__init__ ()
543
543
self .coordinates = coordinates
544
544
@@ -715,7 +715,7 @@ def init_world(self, program):
715
715
self .add_thing (Explorer (program ), (1 , 1 ), True )
716
716
717
717
def get_world (self , show_walls = True ):
718
- '''returns the items in the world'''
718
+ '''Returns the items in the world'''
719
719
result = []
720
720
x_start , y_start = (0 , 0 ) if show_walls else (1 , 1 )
721
721
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):
765
765
return result
766
766
767
767
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. '''
770
770
771
771
if isinstance (agent , Explorer ) and self .in_danger (agent ):
772
772
return
@@ -818,7 +818,7 @@ def in_danger(self, agent):
818
818
819
819
def is_done (self ):
820
820
'''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). '''
822
822
explorer = [agent for agent in self .agents if isinstance (agent , Explorer ) ]
823
823
if len (explorer ):
824
824
if explorer [0 ].alive :
0 commit comments