Skip to content

Commit 9041168

Browse files
authored
Merge pull request #13 from anurag-rai/hwumpus
Add Hybrid-Wumpus-Agent markdown
2 parents 3418365 + 9bc3cfb commit 9041168

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ The file [aima3e-algorithms.pdf](https://github.com/aimacode/pseudocode/blob/mas
170170
<td align="center"></td>
171171
<td><a href="md/WalkSAT.md">WALKSAT</a></td>
172172
</tr>
173+
<tr>
174+
<td align="center">&bull;</td>
175+
<td align="center"></td>
176+
<td><a href="md/Hybrid-Wumpus-Agent.md">HYBRID-WUMPUS-AGENT</a></td>
177+
</tr>
173178
<tr>
174179
<td align="center">&bull;</td>
175180
<td align="center"></td>

md/Hybrid-Wumpus-Agent.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# HYBRID-WUMPUS-AGENT
2+
3+
## AIMA3e
4+
__function__ HYBRID-WUMPUS-AGENT(_percept_) __returns__ an _action_
5+
&emsp;__inputs__: _percept_, a list, \[_stench_, _breeze_, _glitter_, _bump_, _scream_\]
6+
&emsp;__persistent__: _KB_, a knowledge base, initially the atemporal "wumpus physics"
7+
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;_t_, a counter, initially 0, indicating time
8+
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;_plan_, an action sequence, initially empty
9+
10+
&emsp;TELL(_KB_, MAKE-PERCEPT-SENTENCE(_percept_, _t_))
11+
&emsp;TELL the _KB_ the temporal "physics" sentences for time _t_
12+
&emsp;_safe_ &larr; {\[_x_, _y_\] : ASK(_KB_, _OK_<sup>_t_</sup><sub>_x_,_y_</sub>) = _true_}
13+
&emsp;__if__ ASK(_KB_, _Glitter_<sup>_t_</sup>) = _true_ __then__
14+
&emsp;&emsp;&emsp;_plan_ &larr; \[_Grab_\] + PLAN-ROUTE(_current_, {\[1,1\]}, _safe_) + \[_Climb_\]
15+
&emsp;__if__ _plan_ is empty __then__
16+
&emsp;&emsp;&emsp;_unvisited_ &larr; {\[_x_, _y_\] : ASK(_KB_, _L_<sup>_t'_</sup><sub>_x_,_y_</sub>) = _false_ for all _t'_ &le; _t_}
17+
&emsp;&emsp;&emsp;_plan_ &larr; PLAN-ROUTE(_current_, _unvisited_ &cap; _safe_, _safe_)
18+
&emsp;__if__ _plan_ is empty and ASK(_KB_, _HaveArrow_<sup>_t_</sup>) = _true_ __then__
19+
&emsp;&emsp;&emsp;_possible\_wumpus_ &larr; {\[_x_, _y_\] : ASK(_KB_, &not;_W_<sub>_x_,_y_</sub>) = _false_}
20+
&emsp;&emsp;&emsp;_plan_ &larr; PLAN-SHOT(_current_, _possible\_wumpus_, _safe_)
21+
&emsp;__if__ _plan_ is empty __then__ //no choice but to take a risk
22+
&emsp;&emsp;&emsp;_not\_unsafe_ &larr; {\[_x_, _y_\] : ASK(_KB_, &not;_OK_<sup>_t_</sup><sub>_x_,_y_</sub>) = _false_}
23+
&emsp;&emsp;&emsp;_plan_ &larr; PLAN-ROUTE(_current_, _unvisited_ &cap; _not\_unsafe_, _safe_)
24+
&emsp;__if__ _plan_ is empty __then__
25+
&emsp;&emsp;&emsp;_plan_ &larr; PLAN-ROUTE(_current_, {\[1,1\]}, _safe_) + \[_Climb_\]
26+
&emsp;_action_ &larr; POP(_plan_)
27+
&emsp;TELL(_KB_, MAKE-ACTION-SENTENCE(_action_, _t_))
28+
&emsp;_t_ &larr; _t_ + 1
29+
&emsp;__return__ _action_
30+
31+
---
32+
__function__ PLAN-ROUTE(_current_, _goals_, _allowed_) __returns__ an action sequence
33+
&emsp;__inputs__: _current_, the agent's current position
34+
&emsp;&emsp;&emsp;&emsp;&emsp;_goals_, a set of squares; try to plan a route to one of them
35+
&emsp;&emsp;&emsp;&emsp;&emsp;_allowed_, a set of squares that can form part of the route
36+
37+
&emsp;_problem_ &larr; ROUTE-PROBLEM(_current_, _goals_, _allowed_)
38+
&emsp;__return__ A\*\-GRAPH-SEARCH(_problem_)
39+
40+
__Figure__ ?? A hybrid agent program for the wumpus world. It uses a propositional knowledge base to infer the state of the world, and a combination of problem-solving search and domain-specific code to decide what actions to take.

0 commit comments

Comments
 (0)