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

Skip to content

Commit 2473d8d

Browse files
committed
logic.py cleanup continued.
1 parent 7c57b54 commit 2473d8d

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

logic.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ def is_literal(s):
287287
>>> is_literal(expr('x')) # XXX I guess this is intended?
288288
True
289289
"""
290-
#XXX return is_symbol(s.op) or (s.op == '~' and is_literal(s.args[0]))
291290
return is_symbol(s.op) or (s.op == '~' and is_symbol(s.args[0].op))
292291

293292
def literals(s):
@@ -788,7 +787,7 @@ def WalkSAT(clauses, p=0.5, max_flips=10000):
788787
class PLWumpusAgent(agents.Agent):
789788
"An agent for the wumpus world that does logical inference. [Fig. 7.19]"""
790789
def __init__(self):
791-
KB = FOLKB() ## shouldn't this be a propositional KB? ***
790+
KB = FolKB() ## shouldn't this be a propositional KB? ***
792791
x, y, orientation = 1, 1, (1, 0)
793792
visited = set() ## squares already visited
794793
action = None
@@ -843,8 +842,7 @@ def unify(x, y, s):
843842
elif isinstance(x, str) or isinstance(y, str) or not x or not y:
844843
# orig. return if_(x == y, s, None) but we already know x != y
845844
return None
846-
elif issequence(x) and issequence(y) and len(x) == len(y):
847-
# Assert neither x nor y is []
845+
elif issequence(x) and issequence(y) and len(x) == len(y) and x:
848846
return unify(x[1:], y[1:], unify(x[0], y[0], s))
849847
else:
850848
return None
@@ -871,11 +869,10 @@ def occur_check(var, x, s):
871869
elif isinstance(x, Expr):
872870
return (occur_check(var, x.op, s) or
873871
occur_check(var, x.args, s))
874-
elif isinstance(x, list):
872+
elif isinstance(x, (list, tuple)):
875873
return any(occur_check(var, element, s)
876874
for element in x)
877875
else:
878-
assert isinstance(x, (str, int)), x
879876
return False
880877

881878
def extend(s, var, val):

0 commit comments

Comments
 (0)