TO GRASP the nitty-gritty of this program, I’m going to refer you to “Knowledge In Action” by Raymond Reiter, from which this example is taken (minus the graphics). I’ve not altered the Golog portion
of the code with the exception of adding an
The Golog Elevator
SOME ADDITIONAL suggested queries to play with:
do(open_doors : close_doors, s0, S).Sequence with no execution.
do(control, s0, S), holds(currentFloor(N), S).Check what floor the elevator is on at completion.
do(down(1), s0, S), execute(S).Execute primitive actions
primitive_action(A), poss(A, s0), do(A, s0, S), execute(S).Find a possible action and execute it.
do(up(2) # down(2), s0, S), execute(S).Non-deterministic choice of up or down to floor 2.
do(control, s0, S), execute(S).Run the main control loop.
The Elevator Program
To start playing, start by altering the initial situation (s0): Look for the predicates
on(X, s0), these you can add, remove and change. Also
currentFloor(X, s0), you can change this one too.
From there how about we make the elevator safe?
do(up(7), s0, S).should fail, the top floor is number 6. Try adding a constraint to
do(down(0), s0, S).should also fail, the bottom floor is number 1.
do(open_doors: down(1) # up(6), s0, S).should fail! You’ll need a new fluent for doors and new conditions.
do(open_doors : down(1), s0, do(down(1), do(close_doors, do(open_doors, s0)))).Would be nice, an
ifin the right
proccan achieve this.
More demo than explanation, but I hope you’ll enjoy playing with a little bit of Golog and consider investigating this fascinating language further.
Until next time, happy gologing. Paul