agents cooperate:

### Obstacle Finder {#obstacle-finder .unnumbered}

+light(\_, X)\[source(percept)\] : goal(search) & on\_bar(X) & last\_color(white) &lt;- -+last\_color(black); ?bars\_passed(N); BarsPassed = N + 1; -+bars\_passed(BarsPassed). +light(\_, X)\[source(percept)\] : goal(search) & not on\_bar(X) & last\_color(black) &lt;- -+last\_color(white). +obstacle(\_, X)\[source(percept)\] : goal(search) & X &lt; 15 &lt;- -+goal(avoid); ?bars\_passed(N); .send(blindagent, tell, obstacle\_after(N)); !!avoid.

Basically, the agent has a counter incrementing each time it moves over a black bar. When an obstacle is observed near the agent, it tells the blind agent at which bar the obstacle was found. Then it begins to pursue the goal `!avoid`.

### Blind Agent {#blind-agent .unnumbered}

+light(\_, X)\[source(percept)\] : goal(search) & on\_bar(X) & last\_color(white) &lt;- -+last\_color(black); ?bars\_passed(N); BarsPassed = N + 1; -+bars\_passed(BarsPassed). +light(\_, X)\[source(percept)\] : goal(search) & not on\_bar(X) & last\_color(black) &lt;- -+last\_color(white). +bars\_passed(N) : obstacle\_after(N) & goal(search) &lt;- -+goal(avoid); !!avoid.

The agent uses the same approach to count the number of bars passed, since it also has a light sensor. It pursues the goal `!avoid`, whenever it perceives that it is near the obstacle (i.e. has passed the same number of bars as the obstacle finder).

The program could also be extended to include the case where the blind agent does not know how to avoid 