/** * --Copyright notice-- * * Copyright (c) School of Geography, University of Leeds. * http://www.geog.leeds.ac.uk/ * This software is licensed under 'The Artistic License' which can be found at * the Open Source Initiative website at... * http://www.opensource.org/licenses/artistic-license.php * Please note that the optional Clause 8 does not apply to this code. * * The Standard Version source code, and associated documentation can be found at... * [online] http://mass.leeds.ac.uk/ * * * --End of Copyright notice-- * */ import java.util.*; import java.io.Serializable; import java.awt.*; import java.awt.event.*; /** * Protector agent demonstrates how to implement event-based agent behaviour. * The protector will do nothing by itself, but can be controlled by external listeners.
* Note that the spatial x, y, and neighbourhood details are inherited from 'Animal'.
* @version 1.0 * @author Andy Evans */ public class Protector extends Animal implements Serializable { /** * Constructor. Sets a random x and y based on current world size, but * otherwise defers to Animal. * @param worldIn environment for the model * @param agentsIn list of all the agents in the model * @param display component to display on */ public Protector (Environment worldIn, ArrayList agentsIn) { super(worldIn, agentsIn); x = (int)(Math.random() * world.getWidth()); y = (int)(Math.random() * world.getHeight()); } /** * Mutator for spatial x-coordinate. * @param x spatial x-coordinate. */ public void setX(int x) { this.x = x; } /** * Mutator for spatial y-coordinate. * @param y spatial y-coordinate. */ public void setY(int y) { this.y = y; } }