|
| 1 | +# HYBRID-WUMPUS-AGENT |
| 2 | + |
| 3 | +## AIMA3e |
| 4 | +__function__ HYBRID-WUMPUS-AGENT(_percept_) __returns__ an _action_ |
| 5 | + __inputs__: _percept_, a list, \[_stench_, _breeze_, _glitter_, _bump_, _scream_\] |
| 6 | + __persistent__: _KB_, a knowledge base, initially the atemporal "wumpus physics" |
| 7 | +      _t_, a counter, initially 0, indicating time |
| 8 | +      _plan_, an action sequence, initially empty |
| 9 | + |
| 10 | + TELL(_KB_, MAKE-PERCEPT-SENTENCE(_percept_, _t_)) |
| 11 | + TELL the _KB_ the temporal "physics" sentences for time _t_ |
| 12 | + _safe_ ← {\[_x_, _y_\] : ASK(_KB_, _OK_<sup>_t_</sup><sub>_x_,_y_</sub>) = _true_} |
| 13 | + __if__ ASK(_KB_, _Glitter_<sup>_t_</sup>) = _true_ __then__ |
| 14 | +   _plan_ ← \[_Grab_\] + PLAN-ROUTE(_current_, {\[1,1\]}, _safe_) + \[_Climb_\] |
| 15 | + __if__ _plan_ is empty __then__ |
| 16 | +   _unvisited_ ← {\[_x_, _y_\] : ASK(_KB_, _L_<sup>_t'_</sup><sub>_x_,_y_</sub>) = _false_ for all _t'_ ≤ _t_} |
| 17 | +   _plan_ ← PLAN-ROUTE(_current_, _unvisited_ ∩ _safe_, _safe_) |
| 18 | + __if__ _plan_ is empty and ASK(_KB_, _HaveArrow_<sup>_t_</sup>) = _true_ __then__ |
| 19 | +   _possible\_wumpus_ ← {\[_x_, _y_\] : ASK(_KB_, ¬_W_<sub>_x_,_y_</sub>) = _false_} |
| 20 | +   _plan_ ← PLAN-SHOT(_current_, _possible\_wumpus_, _safe_) |
| 21 | + __if__ _plan_ is empty __then__ //no choice but to take a risk |
| 22 | +   _not\_unsafe_ ← {\[_x_, _y_\] : ASK(_KB_, ¬_OK_<sup>_t_</sup><sub>_x_,_y_</sub>) = _false_} |
| 23 | +   _plan_ ← PLAN-ROUTE(_current_, _unvisited_ ∩ _not\_unsafe_, _safe_) |
| 24 | + __if__ _plan_ is empty __then__ |
| 25 | +   _plan_ ← PLAN-ROUTE(_current_, {\[1,1\]}, _safe_) + \[_Climb_\] |
| 26 | + _action_ ← POP(_plan_) |
| 27 | + TELL(_KB_, MAKE-ACTION-SENTENCE(_action_, _t_)) |
| 28 | + _t_ ← _t_ + 1 |
| 29 | + __return__ _action_ |
| 30 | + |
| 31 | +--- |
| 32 | +__function__ PLAN-ROUTE(_current_, _goals_, _allowed_) __returns__ an action sequence |
| 33 | + __inputs__: _current_, the agent's current position |
| 34 | +     _goals_, a set of squares; try to plan a route to one of them |
| 35 | +     _allowed_, a set of squares that can form part of the route |
| 36 | + |
| 37 | + _problem_ ← ROUTE-PROBLEM(_current_, _goals_, _allowed_) |
| 38 | + __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