KEYS AND BOXES SOLUTION
Assume, without loss of generality, that the robot's initially-held
object is ?, where ? is one of the unknown items at the non-keys box.
(Comments are signalled by ";".)
- goto box1
- put down
; if box1 had only keys, then it now has keys + ? (Case A)
; if box1 had only ?, then it now has only ? (Case B)
- goto door
- pick up
; robot picks up red item
- goto table
- put down
; table only has one red item
- goto box1
- pick up
; Case A: if robot has picked ?, then box1 only has keys (Case A1)
;
if robot has picked key, then box1 has keys + ? (Case A2)
; Case B: robot has ?
- goto door
- put down
; Case A1: box1 has only keys, box2 has only ?, door has ?
; Case A2: box1 has keys + ?, box2 has only ?, door has key
; Case B: box1 has only ?, box 2 has only keys, door has ?
- goto box1
- pick up
; Case A1: robot has key
; Case A2: if robot picked ?, then box1 has only keys (Case A2.1)
;
if robot picked key, then box1 has keys + ? (Case A2.2)
; Case B: robot has ?
- goto door
- put down
; Case A1: door has key + ?
; Case A2.1: door has key + ?
; Case A2.2: door has 2 keys
; Case B: door has 2 ?
- goto box2
- pick up
; Case A1: robot has ?
; Case A2.1: robot has ?
; Case A2.2: robot has ?
; Case B: robot has key
- goto door
- put down
; Case A1: door has key + 2 ?
; Case A2.1: door has key + 2 ?
; Case A2.2: door has 2 keys + ?
; Case B: door has key + 2 ?
- goto table
- pick up
- goto outside
; since door has key in all 4 cases, robot can go outside with red object
Copyright © 1986, 2001 by
William J. Rapaport
(rapaport@cse.buffalo.edu)
file: AIQ/keys.soln.02nv01.html