Interacting with the Simulated World Using Callback Instructions

Push includes a variety of instructions for performing computations on the native Push types, but does not provide instructions for interacting with the the simulated world or simulated agents. If you plan to evolve behaviors for simulated agents, you will need to provide instructions by which Push programs can read input data from the world ("sensors") and other output instructions by which the programs can modify the agent's behavior ("actuators").

Instructions are added to a PushInterpreter with the method add-instruction. The method is passed a name for the new instruction, the name of the "callback" method, and the breve instance that is to receive the method call. When the newly created instruction is called, the specified method will be called for the specified instance.

An input callback instruction ("sensor") will typically read values from the world from an agent's perspective and push the values onto a Push stack so that they can be used for computation. A "find-food" instruction, for example, may find the closest food object to an agent, and push onto the vector stack a vector toward the food object.

An output callback instruction ("actuator") will typically take values from the Push interpreter's stack and use those values to perform an action in the world. A "move-towards" instruction, for example, might read a vector value from the vector stack, and then use the breve method "set-velocity" to direct the agent towards the Push-computed location.