Practical 1 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.
- 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.
- The agent would be blocked. JACK will produce an error message and prevent this.
- Prominence, i.e. the plan declared first.
- 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.
- 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.
- 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.
- 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.
- The solution could make use of a semaphore. This is explored further in exercise 11.