Reactive Agents: Masma - Lab 2
Reactive Agents: Masma - Lab 2
Reactive Agents
action. A behaviour (c, a ) will fire when the environment is in state s ∈ S iff
see(s ) ∈ c . Let Beh = {(c, a ) | c ⊆ P and a} be the set of all such rules.
- Associated with an agent’s set of behaviour rules R ∈ Beh is a binary inhibition
relation on the set of behaviours: π ⊆ R × R . This relation is assumed to be a
total ordering on R (i.e., it is transitive, irreflexive, and antisymmetric). We write
b1πb2 if (b1 , b2 ) ∈ π and read this as "b1 inhibits b2", that is, b1 is lower in the
hierarchy than b2, and will hence get priority over b2. The action function is then
defined as follows:
1
Masma – Lab 2
- Action selection begins by first computing the set fired of all behaviours that fire
(5). Then, each behaviour (c, a ) that fires is checked, to determine whether there
is some other higher priority behaviour that fires. If not, then the action part of the
behaviour, a, is returned as the selected action (8). If no behaviour fires, then the
distinguished action null will be returned, indicating that no action has been
chosen.
The overall time complexity of the subsumption action function is no worse than
( )
O n 2 where n is the larger of the number of behaviours or number of percepts. Thus, even
with the naive algorithm above, decision making is tractable. In practice, the decision making
logic can be encoded into hardware, giving constant decision time. For modern hardware,
this means that an agent can be guaranteed to select an action within nano-seconds. This
computational simplicity is the strength of the subsumption architecture.
Example:
Consider an environment containing a set of explorer agents and their home base. Multiple
resources are scattered throughout the environment. The explorer agents are tasked with
finding the resources and bringing them back to the home base.
The explorer agents are reactive, meaning that they don't have a complete representation of
the environment, thus their decisions are based on what they encounter locally (for example,
if they encounter an obstacle they will avoid it, if they encounter a resource they will pick it
up etc.).
2
Masma – Lab 2
Resource
Explorer agent
carrying resource
Home base
Explorer agent
searching
The rules of the explorer agents are expressed as reactive actions, as follows:
R1 – R2 – R3 – R4 – R5
For implementation details, see the example provided along with this document.
Problem
In the previous example, the resources are randomly and uniformly placed throughout the
environment. A great number of randomly-spawning agents with the above-described
behavior is rather suitable for gathering such resources. However, in practice, the resources
are usually clustered (multiple samples are located in the same region) as shown below:
3
Masma – Lab 2
- Whenever an agent finds a resource and returns to base, it will reinforce the path
taken (it will add 2 to the weight of each grid cell it encounters on its way back to
the base)
- R6: If carrying samples and not at the base then increase path weight by 2 and
travel toward base.
- R7: If detect path with weight > 0 decrease path weight by 1 and travel away from
base.
4
Masma – Lab 2
Whenever an agent finds a resource in a certain location, it reinforces the path from the
location to the base, since there may be other resources clustered in the immediate
neighborhood of that location. Whenever a non-carrying agent encountes a reinforced path it
tends to follow it in hope that it may find a resource cluster. At the same time, the importance
of that path decreases as more and more searching agents travel along it.
The following image illustrates the weights of each path. The darker the shade of red of a
grid cell, the greater the chance that travelling on it will lead to more resources.
Tasks:
1. Study the example application provided with the documentation.
2. Modify the application so that the resources are clustered (grouped together) and not
evenly spread throughout the entire grid.
4. Measure the performance in terms of the total number of moves by all agents until all
resources are collected, and compare the results in the following cases:
- Agents are not collaborative and the resources are uniformly distributed (the
default in our example)
- Agents are not collaborative and the resources are grouped together (for
instance, the are only generated in the upper-left quadrant of the grid)