All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sim.app.pacman.Clyde Maven / Gradle / Ivy

Go to download

MASON is a fast discrete-event multiagent simulation library core in Java, designed to be the foundation for large custom-purpose Java simulations, and also to provide more than enough functionality for many lightweight simulation needs. MASON contains both a model library and an optional suite of visualization tools in 2D and 3D.

The newest version!
/*
  Copyright 2009  by Sean Luke and Vittorio Zipparo
  Licensed under the Academic Free License version 3.0
  See the file "LICENSE" for more information
*/

package sim.app.pacman;
import sim.engine.*;
import sim.field.continuous.*;
import sim.util.*;
import ec.util.*;

/** Clyde is the orange ghost.  He starts in the box and initially waiting.
    His target (see Ghost.java) is the Pac himself, just like Blinky.  However
    If Clyde is within 8 tiles of the Pac, he changes his target to be the
    bottom left corner of the screen (Clyde's "scatter target").
*/

public class Clyde extends Blinky
    {
    private static final long serialVersionUID = 1;

    public static final int DIST = 8;
        
    public Double2D getStartLocation() { return new Double2D(14.5, 16); }

    public Double2D scatterTarget;  // only Clyde uses (and sets) this for now

    public Clyde(PacMan pacman) 
        {
        super(pacman);
        waiting = INITIAL_WAITING_PERIOD;
        this.scatterTarget = new Double2D(0, 32);  // bottom left
        }
        
    public Double2D getTarget()
        {
        if (pacman.agents.tds(new Double2D(location), new Double2D(pacman.pacClosestTo(location).location)) > DIST * DIST)
            return super.getTarget();
        else return scatterTarget;
        }
    }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy