Practical 1 Solutions


Program solutions

The solutions to the programming exercises can be found in the practicals/jack_jde/solutions/practical1 subdirectory. There is a separate directory for each of the exercises.


Answers to questions

Exercise 2

  1. The paintPart method would return immediately. It would not wait for the event to be processed. As the program contains a System.exit(0), it would exit before any painting was observed.
  2. The agent would be blocked. JACK will produce an error message and prevent this.

Exercise 3

  1. Prominence, i.e. the plan declared first.

Exercise 5

  1. PaintSpecifiedCurrentColour.

Exercise 7

  1. The plan fails after the first coat of paint. The second coat would not be applied because the event is not reposted. The #set behavior Recover repost is the default behaviour for a BDIGoalEvent.
  2. The main thing to notice is that print statements in the main thread that follow submitPaintRequests can be executed before the events sent by submitPaintRequests are processed. The JACK processing is in another thread.

Exercise 8

  1. Observation of behaviour that is similar to that explained in exercise 7, with additional trace information caused by the Finished event. In addition to the trace statements, messages should have been observed on the interaction diagram.

Exercise 9

  1. It takes so long to paint a part that the next request is sent (and received) before the painting process is finished. This means you do not always achieve the desired/expected output.
  2. The solution could make use of a semaphore. This is explored further in exercise 11.