Skip to content

Commit 4548aae

Browse files
articuno12norvig
authored andcommitted
Updated docstring for ModelBasedReflexAgentProgram in agent.py (aimacode#391)
1 parent 9f1b1ee commit 4548aae

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

agents.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def program(percept):
144144

145145

146146
def ModelBasedReflexAgentProgram(rules, update_state, model):
147-
"""This agent takes action based on the percept and state. [Figure 2.8]"""
147+
"""This agent takes action based on the percept and state. [Figure 2.12]"""
148148
def program(percept):
149149
program.state = update_state(program.state, program.action, percept, model)
150150
rule = rule_match(program.state, rules)
@@ -443,7 +443,7 @@ def move_to(self, thing, destination):
443443
# obs.thing_added(thing)
444444

445445
def add_thing(self, thing, location=(1, 1), exclude_duplicate_class_items=False):
446-
"""Adds things to the world. If (exclude_duplicate_class_items) then the item won't be
446+
"""Adds things to the world. If (exclude_duplicate_class_items) then the item won't be
447447
added if the location has at least one item of the same class."""
448448
if (self.is_inbounds(location)):
449449
if (exclude_duplicate_class_items and
@@ -523,7 +523,7 @@ class Wall(Obstacle):
523523

524524
class GraphicEnvironment(XYEnvironment):
525525
def __init__(self, width=10, height=10, boundary=True, color={}, display=False):
526-
"""define all the usual XYEnvironment characteristics,
526+
"""define all the usual XYEnvironment characteristics,
527527
but initialise a BlockGrid for GUI too"""
528528
super().__init__(width, height)
529529
self.grid = BlockGrid(width, height, fill=(200,200,200))
@@ -534,14 +534,14 @@ def __init__(self, width=10, height=10, boundary=True, color={}, display=False):
534534
self.visible = False
535535
self.bounded = boundary
536536
self.colors = color
537-
537+
538538
#def list_things_at(self, location, tclass=Thing): # need to override because locations
539539
# """Return all things exactly at a given location."""
540540
# return [thing for thing in self.things
541541
# if thing.location == location and isinstance(thing, tclass)]
542-
542+
543543
def get_world(self):
544-
"""Returns all the items in the world in a format
544+
"""Returns all the items in the world in a format
545545
understandable by the ipythonblocks BlockGrid"""
546546
result = []
547547
x_start, y_start = (0, 0)
@@ -552,9 +552,9 @@ def get_world(self):
552552
row.append(self.list_things_at([x, y]))
553553
result.append(row)
554554
return result
555-
555+
556556
"""def run(self, steps=1000, delay=1):
557-
"" "Run the Environment for given number of time steps,
557+
"" "Run the Environment for given number of time steps,
558558
but update the GUI too." ""
559559
for step in range(steps):
560560
sleep(delay)
@@ -569,33 +569,33 @@ def get_world(self):
569569
self.reveal()
570570
"""
571571
def run(self, steps=1000, delay=1):
572-
"""Run the Environment for given number of time steps,
572+
"""Run the Environment for given number of time steps,
573573
but update the GUI too."""
574574
for step in range(steps):
575575
self.update(delay)
576576
if self.is_done():
577577
break
578578
self.step()
579579
self.update(delay)
580-
580+
581581
def update(self, delay=1):
582582
sleep(delay)
583583
if self.visible:
584584
self.conceal()
585585
self.reveal()
586586
else:
587587
self.reveal()
588-
588+
589589
def reveal(self):
590-
"""display the BlockGrid for this world - the last thing to be added
590+
"""display the BlockGrid for this world - the last thing to be added
591591
at a location defines the location color"""
592592
#print("Grid={}".format(self.grid))
593593
self.draw_world()
594594
#if not self.visible == True:
595595
# self.grid.show()
596596
self.grid.show()
597597
self.visible == True
598-
598+
599599
def draw_world(self):
600600
self.grid[:] = (200, 200, 200)
601601
world = self.get_world()
@@ -606,14 +606,14 @@ def draw_world(self):
606606
self.grid[y, x] = self.colors[world[x][y][-1].__class__.__name__]
607607
#print('location: ({}, {}) got color: {}'
608608
#.format(y, x, self.colors[world[x][y][-1].__class__.__name__]))
609-
609+
610610
def conceal(self):
611611
"""hide the BlockGrid for this world"""
612612
self.visible = False
613613
display(HTML(''))
614-
615-
616-
614+
615+
616+
617617

618618

619619

0 commit comments

Comments
 (0)