Running Actions
The state? (time) of a microworld can only change through actions run by objects. There are two modes for running actions: forced action runs?, and goal-oriented action runs?.
Forced Action Runs
An action run? is forced? if it is specified with all necessary parameters as specified by the action definition.
<instance name> do <action name> <action paramter list>.
In an example microworld of maze.sol? the robot class has a move action defined, with one action variable of direction.
> action robot move direction consequece ...
Here is a sample forced action that can be performed by a robot object. Note that because action is run successfully the microworld has moved one unit of time ahead.
> time.
0
> roby position.
A1.
> roby do move up.
ok.
> time.
1
> roby position.
A2.
In any case, if an action run specified with wrong type of parameters, the command is considered as a violation?.
If action variables are class names, then only instances of such classes are considered valid parameters for such variables. Note that in the example above, direction is a class with 4 instances of up, down, right, and left. thus only one of these direction can be a valid parameter of robot move action.
Goal-Oriented Action Runs
Goal-oriented actions runs? are used to ask the machine to pick the suitable parameters for an action in order to satisfy? or get closer to a goal. Thus it only makes sense to run an action without specifying parameters when the action affects a defined goal for a particular class.
Going back to the robot move action example above, lets pretend the robot class has a find-goal goal that is defined as its position to be at the goal square. The robot could only reach this goal by a series of move actions. Thus by not specifying the parameters when running the move action, we're asking the machine to solve the world tree or use any heuristics defined to pick the right parameters that result in the goal being satisfied or getting closer to being satisfied.
<instance name> do <action name>.
Let's imagine the robot is in a position that the machine times out before being able to solve the entire tree to reach its goal, but uses a heuristics of minimizing its distance to the goal square to decide the right action to take. The object will only attempt a search and/or using heuristics if it has more that one valid action to take.
> roby do move.
looking 1 time unit ahead (2 possible worlds)
looking 2 time unit ahead (2 possible worlds)
looking 3 time unit ahead (4 possible worlds)
ok I hear the cpu fan... giving up!
consulting heuristics...
'roby did move right'
ok.