1
+ '''
2
+ Created on Feb 16, 2014
3
+
4
+ @author: Jon
5
+
6
+
7
+ pseudocode of a hybrid agent program for the wumpus world.
8
+ It uses a propositional knowledge base to infer the state
9
+ of the world, and a combination of problem-solving search
10
+ and domain-specific code to decide what actions to take.
11
+
12
+ function HYBRID-WUMPUS-AGENT(percept) returns an action
13
+ inputs: percept, a list, [stench,breeze,glitter,bump,scream]
14
+ persistent: KB, a knowledge base, initially the atemporal "wumpus physics"
15
+ t, a counter, initially 0, indicating time
16
+ plan, an action sequence, initially empty
17
+
18
+ TELL(KB, MAKE-PERCEPT-SENTENCE(percept, t))
19
+ TELL the KB the temporal "physics" sentences for time t
20
+ safe <- {[x,y] : ASK(KB, OK_xy^t)=true}
21
+
22
+ if ASK(KB, Glitter^t) = true then
23
+ plan <- [Grab] + PLAN-ROUTE(current,{[1,1]},safe)+[Climb]
24
+ if plan is empty then
25
+ unvisited <- {[x,y] : ASK(KB,L_x,y^t') = false for all t'<=t}
26
+ plan <- PLAN-ROUTE(current,unvisited^safe,safe)
27
+ if plan is empty and ASK(KB,HaveArrow^t) = true then
28
+ possible_wumpus <- {[s,y] : ASK(KB,-W_x,y)=false}
29
+ plan <- PLAN-SHOT(current,possible_wumpus,safe)
30
+ if plan is empty then // no choice but to take a risk
31
+ not_unsafe <- {[x,y] : ASK(KB,-OK_x,y^t)=false}
32
+ plan <- PLAN-ROUTE(current,unvisited^not_unsafe,safe)
33
+ if plan is empty then
34
+ plan <- PLAN-ROUTE(current,{[1,1]},safe) + [Climb]
35
+ action <- POP(plan)
36
+ TELL(KB,MAKE-ACTION-SENTENCE(action,t))
37
+ t <- t + 1
38
+ return action
39
+
40
+ function PLAN-ROUTE(current,goals,allowed) returns an action sequence
41
+ input: current, the agent's current position
42
+ goals, a set of squares; try to plan a route to one of them
43
+ allowed, a set of squares that can form part of the route
44
+
45
+ problem <- ROUTE-PROBLEM(current,goals,allowed)
46
+ return A*-GRAPH-SEARCH(problem)
47
+
48
+ '''
49
+ from prover9 import Prover9
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+ if __name__ == '__main__' :
59
+ pass
60
+
0 commit comments