This simple agent is adapted to worlds defined by the following properties:
All interior tiles are clear and some of them have items.
All border tiles are walls.
There are no enemies.
The agent starts in the southwest corner, facing east, and if there is a home in the world, it is there, and nowhere else.
The cost to turn is significant compared to the cost to move.
It begins with:
if Item
then
Result
:=
Grab
;
That is the simple reflex to grab items. It will be present in virtually all agents designed for Asimulator. With this reflex in place, all that is left to do for Einar to grab all available items is to make sure it visits all available tiles. To get a good score, Einar should of course do this efficiently and not wander around randomly. Einar does the work in several stages:
In this stage Einar walks straight to the east until it bumps into the east wall. Then he knows how wide the world is and turns left so he faces north.
This is similar to Go_East, but here Einar walks straight into the north wall. Like in the Go_East stage, he turns left after the bump.
This is the main stage where the majority of the world is visited (unless the
map is very small). Like the name tells, Einar walks in a spiral. He needs 5
state variables
(Current_Direction
, Great_X
,
Great_Y
, Small_X
and
Small_Y
) to do the spiral. (To handle border/corner cases
such as worlds with a single reachable row/column/tile, he also keeps track of
his location (a coordinate pair).
Excercise. Verify for yourself that the spiral works with those 5 state variables.
In this stage Einar walks home and turns himself off. Remember that the home, if any, is always in the southwest corner in this class of worlds. Depending on the direction Einar has after the spiral, he walks to the south wall and follows it westwards, or he walks to the west wall and follows it southwards.
Would you like to make a comment or contribute an update to this page?
Send feedback to the KDE Docs Team