Modified the R script to plot all agent outputs. Refactored and fixed some bugs in the agent code.