moveBox()

  1. Extend the previous homework. This time we want to enable the worker to push a box.
  2. Define a function char NextNextToWorker(Direction d), which will return the next next cell of the worker in the d direction. For example, in the following figure, NextToWorker(RIGHT) == 'B' and NextNextToWorker(RIGHT) == ' '.
  3. Define a function MoveBox(Direction d).
  4. As we have done in the previous homework, in your main loop, when the user press the UP key ('K'), and NextToWorker(UP) == ' ', call MoveWorker(d) to move the worker.
  5. If NextToWorker(UP) == 'B', but NextNextToWorker(UP) == ' ', call MoveBox(d) together with MoveWorker(d) to move the box and the worker concurrently.
  6. Handle DOWN, LEFT and RIGHT similarly.
  7. After each move, count the number of boxes which have arrived at the destinations. If all boxes have arrived, (you may optionally play a music and) move to the next level.