/* * file name: SocialAgent.java * author: YOUR NAME HERE * date: * purpose: An Agent that keeps moving until it is part of a group. * * CS231 Project 3 - Agent-Based Simulation */ import java.awt.Color; import java.awt.Graphics; public class SocialAgent extends Agent { // Do NOT declare x, y, radius or moved here. SocialAgent inherits them. // Declaring a field with the same name would create a SECOND, separate // variable that "hides" the inherited one - a very confusing bug. // ====================================================================== // TASK 3 - Constructor and draw() // ====================================================================== /** * Creates a SocialAgent. The parent constructor does the real work. */ public SocialAgent(double x0, double y0, int radius) { super(x0, y0, radius); // must be the first line: builds the Agent part of this object } /** * Draws a small circle at the Agent's position: * dark blue (0, 0, 255) if it did not move during its last update, * light blue (125, 125, 255) if it did. */ public void draw(Graphics g) { // TODO (Task 3): copy the draw code from the Project 3 page. // Notice that it reads the inherited field moved directly. } // ====================================================================== // TASK 6 - updateState() // ====================================================================== /** * A SocialAgent wants company. * * Ask the Landscape for the agents within this agent's radius of its own * position. That list INCLUDES this agent itself. * * fewer than 4 agents in the list -> call moveRandomly(scape) and set moved to true * otherwise -> stay put and set moved to false */ public void updateState(Landscape scape) { // TODO (Task 6) } }