Skip to content

Commit 1ff5ae8

Browse files
SnShinenorvig
authored andcommitted
modifies Fig. to Figure all over the repository (aimacode#223)
* modifies Fig. to Figure all over the repository * fixed a small type in logic.py
1 parent a62a3a9 commit 1ff5ae8

File tree

11 files changed

+73
-73
lines changed

11 files changed

+73
-73
lines changed

agents.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def TableDrivenAgentProgram(table):
118118
"""This agent selects an action based on the percept sequence.
119119
It is practical only for tiny domains.
120120
To customize it, provide as table a dictionary of all
121-
{percept_sequence:action} pairs. [Fig. 2.7]"""
121+
{percept_sequence:action} pairs. [Figure 2.7]"""
122122
percepts = []
123123

124124
def program(percept):
@@ -136,7 +136,7 @@ def RandomAgentProgram(actions):
136136

137137

138138
def SimpleReflexAgentProgram(rules, interpret_input):
139-
"This agent takes action based solely on the percept. [Fig. 2.10]"
139+
"This agent takes action based solely on the percept. [Figure 2.10]"
140140
def program(percept):
141141
state = interpret_input(percept)
142142
rule = rule_match(state, rules)
@@ -146,7 +146,7 @@ def program(percept):
146146

147147

148148
def ModelBasedReflexAgentProgram(rules, update_state):
149-
"This agent takes action based on the percept and state. [Fig. 2.12]"
149+
"This agent takes action based on the percept and state. [Figure 2.12]"
150150
def program(percept):
151151
program.state = update_state(program.state, program.action, percept)
152152
rule = rule_match(program.state, rules)
@@ -173,7 +173,7 @@ def RandomVacuumAgent():
173173

174174

175175
def TableDrivenVacuumAgent():
176-
"[Fig. 2.3]"
176+
"[Figure 2.3]"
177177
table = {((loc_A, 'Clean'),): 'Right',
178178
((loc_A, 'Dirty'),): 'Suck',
179179
((loc_B, 'Clean'),): 'Left',
@@ -189,7 +189,7 @@ def TableDrivenVacuumAgent():
189189

190190

191191
def ReflexVacuumAgent():
192-
"A reflex agent for the two-state vacuum environment. [Fig. 2.8]"
192+
"A reflex agent for the two-state vacuum environment. [Figure 2.8]"
193193
def program(percept):
194194
location, status = percept
195195
if status == 'Dirty':

csp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def conflicted_vars(self, current):
157157

158158

159159
def AC3(csp, queue=None, removals=None):
160-
"""[Fig. 6.3]"""
160+
"""[Figure 6.3]"""
161161
if queue is None:
162162
queue = [(Xi, Xk) for Xi in csp.variables for Xk in csp.neighbors[Xi]]
163163
csp.support_pruning()
@@ -251,7 +251,7 @@ def backtracking_search(csp,
251251
select_unassigned_variable=first_unassigned_variable,
252252
order_domain_values=unordered_domain_values,
253253
inference=no_inference):
254-
"""[Fig. 6.5]
254+
"""[Figure 6.5]
255255
"""
256256

257257
def backtrack(assignment):
@@ -306,7 +306,7 @@ def min_conflicts_value(csp, var, current):
306306

307307

308308
def tree_csp_solver(csp):
309-
"[Fig. 6.11]"
309+
"[Figure 6.11]"
310310
assignment = {}
311311
root = csp.variables[0]
312312
X, parent = topological_sort(csp.variables, root)

games.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def minimax_decision(state, game):
1717
"""Given a state in a game, calculate the best move by searching
18-
forward all the way to the terminal states. [Fig. 5.3]"""
18+
forward all the way to the terminal states. [Figure 5.3]"""
1919

2020
player = game.to_move(state)
2121

@@ -44,7 +44,7 @@ def min_value(state):
4444

4545
def alphabeta_full_search(state, game):
4646
"""Search game to determine best action; use alpha-beta pruning.
47-
As in [Fig. 5.7], this version searches all the way to the leaves."""
47+
As in [Figure 5.7], this version searches all the way to the leaves."""
4848

4949
player = game.to_move(state)
5050

@@ -207,7 +207,7 @@ def __repr__(self):
207207

208208

209209
class Fig52Game(Game):
210-
"""The game represented in [Fig. 5.2]. Serves as a simple test case."""
210+
"""The game represented in [Figure 5.2]. Serves as a simple test case."""
211211

212212
succs = dict(A=dict(a1='B', a2='C', a3='D'),
213213
B=dict(b1='B1', b2='B2', b3='B3'),
@@ -334,12 +334,12 @@ def __init__(self, varname, player_1='human', player_2='random', id=None, width=
334334
self.players = (player_1, player_2)
335335
self.draw_board()
336336
self.font("Ariel 30px")
337-
337+
338338
def mouse_click(self, x, y):
339339
player = self.players[self.turn]
340340
if self.ttt.terminal_test(self.state):
341341
return
342-
342+
343343
if player == 'human':
344344
x, y = int(3*x/self.width) + 1, int(3*y/self.height) + 1
345345
if (x, y) not in self.ttt.actions(self.state):
@@ -379,7 +379,7 @@ def draw_board(self):
379379
self.text_n("Player {}'s move({})".format(self.turn+1, self.players[self.turn]), 0.1, 0.1)
380380

381381
self.update()
382-
382+
383383
def draw_x(self, position):
384384
self.stroke(0, 255, 0)
385385
x, y = [i-1 for i in position]

learning.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def __repr__(self):
328328

329329

330330
def DecisionTreeLearner(dataset):
331-
"[Fig. 18.5]"
331+
"[Figure 18.5]"
332332

333333
target, values = dataset.target, dataset.values
334334

@@ -398,7 +398,7 @@ def information_content(values):
398398

399399

400400
def DecisionListLearner(dataset):
401-
"""[Fig. 18.11]"""
401+
"""[Figure 18.11]"""
402402

403403
def decision_list_learning(examples):
404404
if not examples:
@@ -511,7 +511,7 @@ def network(input_units, hidden_layer_sizes, output_units):
511511

512512

513513
def BackPropagationLearner(dataset, net, learning_rate, epoches):
514-
"[Fig. 18.23] The back-propagation algorithm for multilayer network"
514+
"[Figure 18.23] The back-propagation algorithm for multilayer network"
515515
# Initialise weights
516516
for layer in net:
517517
for node in layer:
@@ -668,7 +668,7 @@ def predict(example):
668668

669669

670670
def AdaBoost(L, K):
671-
"""[Fig. 18.34]"""
671+
"""[Figure 18.34]"""
672672
def train(dataset):
673673
examples, target = dataset.examples, dataset.target
674674
N = len(examples)
@@ -868,11 +868,11 @@ def score(learner, size):
868868
attrnames="sepal-len sepal-width petal-len petal-width class")
869869

870870
# ______________________________________________________________________________
871-
# The Restaurant example from Fig. 18.2
871+
# The Restaurant example from [Figure 18.2]
872872

873873

874874
def RestaurantDataSet(examples=None):
875-
"Build a DataSet of Restaurant waiting examples. [Fig. 18.3]"
875+
"Build a DataSet of Restaurant waiting examples. [Figure 18.3]"
876876
return DataSet(name='restaurant', target='Wait', examples=examples,
877877
attrnames='Alternate Bar Fri/Sat Hungry Patrons Price ' +
878878
'Raining Reservation Type WaitEstimate Wait')

logic.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def retract(self, sentence):
111111

112112

113113
def KB_AgentProgram(KB):
114-
"""A generic logical knowledge-based agent program. [Fig. 7.1]"""
114+
"""A generic logical knowledge-based agent program. [Figure 7.1]"""
115115
steps = itertools.count()
116116

117117
def program(percept):
@@ -191,7 +191,7 @@ def parse_definite_clause(s):
191191

192192
def tt_entails(kb, alpha):
193193
"""Does kb entail the sentence alpha? Use truth tables. For propositional
194-
kb's and sentences. [Fig. 7.10]. Note that the 'kb' should be an
194+
kb's and sentences. [Figure 7.10]. Note that the 'kb' should be an
195195
Expr which is a conjunction of clauses.
196196
>>> tt_entails(expr('P & Q'), expr('Q'))
197197
True
@@ -434,7 +434,7 @@ def disjuncts(s):
434434

435435

436436
def pl_resolution(KB, alpha):
437-
"Propositional-logic resolution: say if alpha follows from KB. [Fig. 7.12]"
437+
"Propositional-logic resolution: say if alpha follows from KB. [Figure 7.12]"
438438
clauses = KB.clauses + conjuncts(to_cnf(~alpha))
439439
new = set()
440440
while True:
@@ -493,7 +493,7 @@ def clauses_with_premise(self, p):
493493

494494
def pl_fc_entails(KB, q):
495495
"""Use forward chaining to see if a PropDefiniteKB entails symbol q.
496-
[Fig. 7.15]
496+
[Figure 7.15]
497497
>>> pl_fc_entails(horn_clauses_KB, expr('Q'))
498498
True
499499
"""
@@ -527,7 +527,7 @@ def pl_fc_entails(KB, q):
527527
horn_clauses_KB.tell(expr(s))
528528

529529
# ______________________________________________________________________________
530-
# DPLL-Satisfiable [Fig. 7.17]
530+
# DPLL-Satisfiable [Figure 7.17]
531531

532532

533533
def dpll_satisfiable(s):
@@ -633,7 +633,7 @@ def inspect_literal(literal):
633633
return literal, True
634634

635635
# ______________________________________________________________________________
636-
# Walk-SAT [Fig. 7.18]
636+
# Walk-SAT [Figure 7.18]
637637

638638

639639
def WalkSAT(clauses, p=0.5, max_flips=10000):
@@ -670,7 +670,7 @@ def sat_count(sym):
670670

671671
class HybridWumpusAgent(agents.Agent):
672672

673-
"An agent for the wumpus world that does logical inference. [Fig. 7.20]"""
673+
"An agent for the wumpus world that does logical inference. [Figure 7.20]"""
674674

675675
def __init__(self):
676676
unimplemented()
@@ -684,7 +684,7 @@ def plan_route(current, goals, allowed):
684684

685685
def SAT_plan(init, transition, goal, t_max, SAT_solver=dpll_satisfiable):
686686
"""Converts a planning problem to Satisfaction problem by translating it to a cnf sentence.
687-
[Fig. 7.22]"""
687+
[Figure 7.22]"""
688688

689689
#Functions used by SAT_plan
690690
def translate_to_SAT(init, transition, goal, time):
@@ -767,7 +767,7 @@ def extract_solution(model):
767767
def unify(x, y, s):
768768
"""Unify expressions x,y with substitution s; return a substitution that
769769
would make x,y equal, or None if x,y can not unify. x and y can be
770-
variables (e.g. Expr('x')), constants, lists, or Exprs. [Fig. 9.1]"""
770+
variables (e.g. Expr('x')), constants, lists, or Exprs. [Figure 9.1]"""
771771
if s is None:
772772
return None
773773
elif x == y:
@@ -933,7 +933,7 @@ def fetch_rules_for_goal(self, goal):
933933

934934

935935
def fol_bc_ask(KB, query):
936-
"""A simple backward-chaining algorithm for first-order logic. [Fig. 9.6]
936+
"""A simple backward-chaining algorithm for first-order logic. [Figure 9.6]
937937
KB should be an instance of FolKB, and query an atomic sentence. """
938938
return fol_bc_or(KB, query, {})
939939

mdp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def to_arrows(self, policy):
109109

110110

111111
def value_iteration(mdp, epsilon=0.001):
112-
"Solving an MDP by value iteration. [Fig. 17.4]"
112+
"Solving an MDP by value iteration. [Figure 17.4]"
113113
U1 = dict([(s, 0) for s in mdp.states])
114114
R, T, gamma = mdp.R, mdp.T, mdp.gamma
115115
while True:
@@ -140,7 +140,7 @@ def expected_utility(a, s, U, mdp):
140140

141141

142142
def policy_iteration(mdp):
143-
"Solve an MDP by policy iteration [Fig. 17.7]"
143+
"Solve an MDP by policy iteration [Figure 17.7]"
144144
U = dict([(s, 0) for s in mdp.states])
145145
pi = dict([(s, random.choice(mdp.actions(s))) for s in mdp.states])
146146
while True:

nlp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ def __repr__(self):
5353
return '<Grammar %s>' % self.name
5454

5555
E0 = Grammar('E0',
56-
Rules( # Grammar for E_0 [Fig. 22.4]
56+
Rules( # Grammar for E_0 [Figure 22.4]
5757
S='NP VP | S Conjunction S',
5858
NP='Pronoun | Name | Noun | Article Noun | Digit Digit | NP PP | NP RelClause', # noqa
5959
VP='Verb | VP NP | VP Adjective | VP PP | VP Adverb',
6060
PP='Preposition NP',
6161
RelClause='That VP'),
6262

63-
Lexicon( # Lexicon for E_0 [Fig. 22.3]
63+
Lexicon( # Lexicon for E_0 [Figure 22.3]
6464
Noun="stench | breeze | glitter | nothing | wumpus | pit | pits | gold | east", # noqa
6565
Verb="is | see | smell | shoot | fell | stinks | go | grab | carry | kill | turn | feel", # noqa
6666
Adjective="right | left | east | south | back | smelly",
@@ -116,7 +116,7 @@ def rewrite(tokens, into):
116116

117117
class Chart:
118118

119-
"""Class for parsing sentences using a chart data structure. [Fig 22.7]
119+
"""Class for parsing sentences using a chart data structure. [Figure 22.7]
120120
>>> chart = Chart(E0);
121121
>>> len(chart.parses('the stench is in 2 2'))
122122
1

0 commit comments

Comments
 (0)