In Issue 5 of GO Marcus Topham introduced Roamer's programmable sensor.
In this article he looks further at this powerful feature.
Using more than one sense instruction inside a program
In a GO Program, every instruction entered after a Sense Instruction
is subject to its influence. If a second Sense Instruction is entered,
it replaces the previous one. Roamer always responds to the most recent
Sense Instruction executed. The GO Program can have as many Sense
Instructions as memory will allow.
Roamers love ice cream. The evil Baron von Bugbyte (brother of
the Bad Baroness) has stolen the recipe for the Roamers' favourite
ice cream and locked it in his castle vault. Unless the Roamer government
pays him 1 zillion groats, he will destroy the recipe. Spybot, MI5,
has 24 hours to recover the secret or ice cream riots are likely to
start.
MI5 is standing at the entrance passage to the castle hall. At
the far end of the hall he can see another passageway and next to
that, the vault. Halfway down the hall a large, wooden door leads
to the dungeon, where the Baroness is showing the Baron her latest
kidnap victim - Prince Roamer. MI5 creeps towards the vault. If the
von Bugbytes return to the hall the creaking sound of the dungeon
door opening will warn the intrepid spybot to escape immediately through
the nearest passage.
Design and make a Roamer spybot. Fit this with a sound sensor. Replicate
the Dining Hall. Program the Roamer to travel through the Hall, get
the recipe from the vault and exit through the nearest door. If MI5
hears a noise he must escape through the nearest exit. The noise can
be made by clapping or whistling.
If MI5 is journeying toward the dungeon door when
the Baron returns, the quickest escape route is back the way he
came.
If MI5 is journeying away from the dungeon door when the Baron
returns, the quickest escape route is through the door next to
the vault.
GO Program
Sense Instruction for journey from the entrance passage to the
dungeon door. Respond to a High to Low signal by executing Sense
Procedure 1.
Journey, from entrance to dungeon door.
Sense Instruction for journey from the dungeon door to the vault.
Respond to High to Low signal by executing Sense Procedure 2.
Procedure for moving Roamer from the dungeon, to the vault and
out of the hall.
Procedures
Journey, from the dungeon door to the vault.
Time to get the recipe out of the vault.
Leave the hall.
Sense Procedures
Escape back through the entrance passage.
Escape through the passage next to the vault.
Sense procedure inside a sense procedure
While Roamer is executing a Sense Procedure, it ignores any further
inputs. If, however, the Sense Procedure contains a Sense Instruction,
Roamer will recognise the Input specified in the new Instruction. This
enables Roamer to have multiple responses to its environment.
In the eighteenth century Cornwall, in South West England, was
famous for its smugglers. Ships would sail to secret coves and await
signals from accomplices on shore to tell them it was safe to come
and land their contraband.
Make Roamer into a smugglers' ship. Fit it with a light sensor. Use
a strong flash light to signal the ship: one flash to say, "It's dangerous,
sail away"; and two flashes to say, "It's safe, come ashore".
This program makes the ship sail to the cove and wait
for a signal. If only one light flash is made the ship will turn round
and sail away. However, if this first flash is followed quickly by
a second flash, the ship will not have time to start to turn around
before it is asked to execute the Sense Procedure 2 (sail into the
cove).
GO Program
Ship sails to the cove. Since a Sense Instruction has not been executed,
this forward motion cannot be affected by an input.
Sense Instruction: respond to a High to Low signal (a light flash)
by executing Sense Procedure 1.
Wait for a signal.
Sense Procedures
Definition of Sense Procedure 1: set another Sense Instruction,
respond to a High to Low signal (a light flash) by executing Sense
Procedure 2.
Turn the ship around and sail away.
Definition of Sense Procedure 2: sail into the cove.
WARNING
A Sense Procedure should not be used as a normal Procedure. If the
Roamer is carrying out a procedure which is interrupted and called
at the same time, it will get confused and stop what it's doing. It
will then need reprogramming.
GO Program
Sense Instruction.
Execute Sense Procedure 1 as part of the GO Program. While executing
'Sense' Procedure 1 recognise a High to Low signal and respond by
executing Sense Procedure 1.