★ wanayoo — archive 1999 http://www.gnu.org/software/robots/examples.htmlNouvelle recherche | Portail wanayoo
GNU Robots

EXAMPLES

Here, a GNU robot can use (robot-look "baddie") to spot the bug at A4. However, using (robot-feel "baddie") will return a false value. Note that (robot-smell "baddie") will return a true value, because the GNU robot is detecting the bug at B1.
  1 2 3 4
A
B
C
D

If we turn the robot using (robot-turn 1) so our GNU robot faces South, then the robot can use (robot-feel "baddie") to detect the bug at B1. The GNU robot can also use (robot-look "baddie"), which will also return a true value.
  1 2 3 4
A
B
C
D

We can kill the bug at B1 by using (robot-zap), and then move into that position using (robot-move 1). Now we can use (robot-look "prize") to detect the prize at D1. Using (robot-feel "prize") will return a false value, because the prize is too far away.
  1 2 3 4
A
B
C
D

Let's move our GNU robot one space more using (robot-move 1) and then turn so we are facing East, using (robot-turn -1). Now, we can't spot the prize at C3 using (robot-look "prize") because there is a wall in our way at C2. However, we can feel for the wall using (robot-feel "wall").
  1 2 3 4
A
B
C
D

Now, let's to grab the prize at D1, and position our robot in D1 facing East. You would write this:

  (robot-turn 1)
  (robot-grab)
  (robot-move 1)
  (robot-turn -1)
  1 2 3 4
A
B
C
D

Finally, let's grab the remaining prize at C3, and position our robot at C3 facing North. You would write this:

  (robot-move 2)
  (robot-turn -1)
  (robot-grab)
  (robot-move 1)
  1 2 3 4
A
B
C
D

[BACK]