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

Skip to content

Commit ed96027

Browse files
committed
Trivial reformatting.
1 parent 0fbaeab commit ed96027

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

agents.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#______________________________________________________________________________
4141

4242

43-
class Object (object):
43+
class Object(object):
4444
"""This represents any physical object that can appear in an Environment.
4545
You subclass Object to get the objects you want. Each object can have a
4646
.__name__ slot (used for output only)."""
@@ -60,7 +60,7 @@ def display(self, canvas, x, y, width, height):
6060
"""Display an image of this Object on the canvas."""
6161
pass
6262

63-
class Agent (Object):
63+
class Agent(object):
6464
"""An Agent is a subclass of Object with one required slot,
6565
.program, which should hold a function that takes one argument, the
6666
percept, and returns an action. (What counts as a percept or action
@@ -102,7 +102,7 @@ def new_program(percept):
102102

103103
#______________________________________________________________________________
104104

105-
class TableDrivenAgent (Agent):
105+
class TableDrivenAgent(Agent):
106106
"""This agent selects an action based on the percept sequence.
107107
It is practical only for tiny domains.
108108
To customize it you provide a table to the constructor. [Fig. 2.7]"""
@@ -124,7 +124,7 @@ def program(percept):
124124
return program
125125

126126

127-
class RandomAgent (Agent):
127+
class RandomAgent(Agent):
128128
"An agent that chooses an action at random, ignoring all percepts."
129129

130130
def __init__(self, actions):
@@ -140,7 +140,7 @@ def make_agent_program(self):
140140

141141
loc_A, loc_B = (0, 0), (1, 0) # The two locations for the Vacuum world
142142

143-
class ReflexVacuumAgent (Agent):
143+
class ReflexVacuumAgent(Agent):
144144
"A reflex agent for the two-state vacuum environment. [Fig. 2.8]"
145145

146146
def __init__(self):
@@ -174,7 +174,7 @@ def TableDrivenVacuumAgent():
174174
return TableDrivenAgent(table)
175175

176176

177-
class ModelBasedVacuumAgent (Agent):
177+
class ModelBasedVacuumAgent(Agent):
178178
"An agent that keeps track of what locations are clean or dirty."
179179

180180
def __init__(self):
@@ -195,7 +195,7 @@ def program((location, status)):
195195
#______________________________________________________________________________
196196

197197

198-
class Environment (object):
198+
class Environment(object):
199199
"""Abstract class representing an Environment. 'Real' Environment classes
200200
inherit from this. Your Environment will typically need to implement:
201201
percept: Define the percept that an agent sees.
@@ -295,7 +295,7 @@ def trace_list (name, objlist):
295295
ol_list = [(obj, obj.location) for obj in objlist]
296296
print "%s: %s" % (name, ol_list)
297297

298-
class XYEnvironment (Environment):
298+
class XYEnvironment(Environment):
299299
"""This class is for environments on a 2D plane, with locations
300300
labelled by (x, y) points, either discrete or continuous.
301301
@@ -396,21 +396,21 @@ def turn_heading(self, heading, inc, headings=orientations):
396396
"Return the heading to the left (inc=+1) or right (inc=-1) in headings."
397397
return headings[(headings.index(heading) + inc) % len(headings)]
398398

399-
class Obstacle (Object):
399+
class Obstacle(object):
400400
"""Something that can cause a bump, preventing an agent from
401401
moving into the same square it's in."""
402402
pass
403403

404-
class Wall (Obstacle):
404+
class Wall(Obstacle):
405405
pass
406406

407407
#______________________________________________________________________________
408408
## Vacuum environment
409409

410-
class Dirt (Object):
410+
class Dirt(object):
411411
pass
412412

413-
class VacuumEnvironment (XYEnvironment):
413+
class VacuumEnvironment(XYEnvironment):
414414
"""The environment of [Ex. 2.12]. Agent perceives dirty or clean,
415415
and bump (into obstacle) or not; 2D discrete world of unknown size;
416416
performance measure is 100 for each dirt cleaned, and -1 for
@@ -445,7 +445,7 @@ def execute_action(self, agent, action):
445445
if action != 'NoOp':
446446
agent.performance -= 1
447447

448-
class TrivialVacuumEnvironment (Environment):
448+
class TrivialVacuumEnvironment(Environment):
449449

450450
"""This environment has two locations, A and B. Each can be Dirty
451451
or Clean. The agent perceives its location and the location's
@@ -485,7 +485,7 @@ def default_location(self, object):
485485

486486
#______________________________________________________________________________
487487

488-
class SimpleReflexAgent (Agent):
488+
class SimpleReflexAgent(Agent):
489489
"""This agent takes action based solely on the percept. [Fig. 2.13]"""
490490

491491
def __init__(self, rules, interpret_input):
@@ -503,7 +503,7 @@ def program(percept):
503503
return action
504504
return program
505505

506-
class ReflexAgentWithState (Agent):
506+
class ReflexAgentWithState(Agent):
507507
"""This agent takes action based on the percept and state. [Fig. 2.16]"""
508508

509509
def __init__(self, rules, update_state):
@@ -532,11 +532,11 @@ def rule_match(state, rules):
532532
#______________________________________________________________________________
533533
## The Wumpus World
534534

535-
class Gold (Object): pass
536-
class Pit (Object): pass
537-
class Arrow (Object): pass
538-
class Wumpus (Agent): pass
539-
class Explorer (Agent): pass
535+
class Gold(object): pass
536+
class Pit(object): pass
537+
class Arrow(object): pass
538+
class Wumpus(Agent): pass
539+
class Explorer(Agent): pass
540540

541541
class WumpusEnvironment(XYEnvironment):
542542

@@ -608,7 +608,7 @@ def testv(A): return test_agent(A, 4, copy.deepcopy(envs))
608608

609609
import Tkinter as tk
610610

611-
class EnvGUI (tk.Tk, object):
611+
class EnvGUI(tk.Tk, object):
612612

613613
def __init__(self, env, title = 'AIMA GUI', cellwidth=50, n=10):
614614

@@ -625,7 +625,7 @@ def __init__(self, env, title = 'AIMA GUI', cellwidth=50, n=10):
625625
w.pack(side="bottom", fill="x", padx="3", pady="3")
626626

627627

628-
class EnvToolbar (tk.Frame, object):
628+
class EnvToolbar(tk.Frame, object):
629629

630630
def __init__(self, parent, env, canvas):
631631
super(EnvToolbar, self).__init__(parent, relief='raised', bd=2)

csp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,13 @@ def display(self, assignment):
426426
n = len(self.vars)
427427
for val in range(n):
428428
for var in range(n):
429-
if assignment.get(var,'') == val: ch ='Q'
429+
if assignment.get(var,'') == val: ch = 'Q'
430430
elif (var+val) % 2 == 0: ch = '.'
431431
else: ch = '-'
432432
print ch,
433433
print ' ',
434434
for var in range(n):
435-
if assignment.get(var,'') == val: ch ='*'
435+
if assignment.get(var,'') == val: ch = '*'
436436
else: ch = ' '
437437
print str(self.nconflicts(var, val, assignment))+ch,
438438
print

search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#______________________________________________________________________________
1515

16-
class Problem (object):
16+
class Problem(object):
1717
"""The abstract class for a formal problem. You should subclass this and
1818
implement the method successor, and possibly __init__, goal_test, and
1919
path_cost. Then you will create instances of your subclass and solve them

0 commit comments

Comments
 (0)