sim.app.pacman.Inky Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mason Show documentation
Show all versions of mason Show documentation
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.*;
/** Inky is the cyan ghost. He starts in the box and initially waiting.
His target (see Ghost.java) is complex: it's on the opposite side
of Pinky's target than the location of Blinky. So if Pinky's target is
the vector p, and Blinky is at b, then Inky's target is p + (p - b).
*/
public class Inky extends Pinky
{
private static final long serialVersionUID = 1;
Blinky blinky;
public Double2D getStartLocation() { return new Double2D(13.5, 16); }
public Inky(PacMan pacman, Blinky blinky)
{
super(pacman);
this.blinky = blinky;
}
public Double2D getTarget()
{
Double2D target = super.getTarget();
MutableDouble2D blinkyLoc = blinky.location;
Continuous2D agents = pacman.agents;
return new Double2D(agents.stx(2 * blinkyLoc.x - target.x), agents.sty(2 * blinkyLoc.y - target.y));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy