EDU.gatech.cc.is.simulation
Class AttractorSim

java.lang.Object
  |
  +--EDU.gatech.cc.is.simulation.AttractorSim
Direct Known Subclasses:
AttractorFlagSim, AttractorPermSim, BinSim, GolfBallSim, SquiggleBallSim

public class AttractorSim
extends java.lang.Object
implements SimulatedObject

A simple attractor for simulation.

Copyright (c)2000 by Tucker Balch


Field Summary
protected  SimulatedObject[] all_objects
           
protected  java.awt.Color background
           
protected  double bottom
           
static boolean DEBUG
           
protected  boolean deposited
           
protected  java.awt.Color foreground
           
protected  double left
           
protected  boolean picked_up
           
protected  Vec2 position
           
protected  double RADIUS
           
protected  java.util.Random rando
           
protected  double right
           
protected  long seed
           
protected  double top
           
protected  int unique_id
           
protected  int visionclass
           
 
Constructor Summary
AttractorSim()
          Instantiate an AttractorSim object.
 
Method Summary
 boolean checkCollision(Circle2 c)
          determine if the object is intersecting with a specified circle.
 boolean checkCollision(Polygon2 p)
          determine if the object is intersecting with a specified polygon.
 void clearTrail()
          Clear the trail.
 void draw(java.awt.Graphics g, int w, int h, double t, double b, double l, double r)
          Draw the attractor.
 void draw(Vec2 pos, java.awt.Graphics g, int w, int h, double t, double b, double l, double r)
          Draw the object in a specific spot.
 void drawIcon(java.awt.Graphics g, int w, int h, double t, double b, double l, double r)
          Draw the attractor as an icon.
 void drawID(java.awt.Graphics g, int w, int h, double t, double b, double l, double r)
          Draw the attractor's ID.
 void drawState(java.awt.Graphics g, int w, int h, double t, double b, double l, double r)
          Draw the attractor's State.
 void drawTrail(java.awt.Graphics g, int w, int h, double t, double b, double l, double r)
          Draw the attractor's Trail.
 Vec2 getCenter(Vec2 from)
          Find the center point of the object from a particular location.
 Vec2 getClosestPoint(Vec2 from)
          Find the closest point on the object from a particular location.
 int getID()
          Return the id.
 Vec2 getPosition()
          Find the center point of the object in absolute coordinates.
 int getVisionClass()
          Return the vision class of the object.
 void init(double xp, double yp, double t, double r, java.awt.Color f, java.awt.Color b, int v, int i, long s)
          Initialize an AttractorSim object.
 boolean isObstacle()
          true if the object should be considered an obstacle, false otherwise.
 boolean isPickupable()
          true if the object can be picked up, false otherwise.
 boolean isPushable()
          true if the object is pushable false otherwise.
 void pickUp(SimulatedObject o)
          Try to pick up the object.
 void push(Vec2 d, Vec2 v)
          Try to push the object.
 void putDown(Vec2 p)
          Try to put down the object.
 void quit()
          Clean up.
 void receive(Message m)
          Receive a message.
 void setID(int i)
          Set the id of the object.
 void setTrailLength(int l)
          Set the length of the trail (in movement steps).
 void setVisionClass(int v)
          Change the way the object is perceived by vision hardware.
 void takeStep(long time_increment, SimulatedObject[] all_objs)
          Take a simulated step;
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

position

protected Vec2 position

foreground

protected java.awt.Color foreground

background

protected java.awt.Color background

all_objects

protected SimulatedObject[] all_objects

visionclass

protected int visionclass

unique_id

protected int unique_id

RADIUS

protected double RADIUS

top

protected double top

bottom

protected double bottom

left

protected double left

right

protected double right

deposited

protected boolean deposited

seed

protected long seed

rando

protected java.util.Random rando

DEBUG

public static final boolean DEBUG

picked_up

protected boolean picked_up
Constructor Detail

AttractorSim

public AttractorSim()
Instantiate an AttractorSim object. Be sure to also call Init with proper values.
See Also:
init(double, double, double, double, java.awt.Color, java.awt.Color, int, int, long)
Method Detail

init

public void init(double xp,
                 double yp,
                 double t,
                 double r,
                 java.awt.Color f,
                 java.awt.Color b,
                 int v,
                 int i,
                 long s)
Initialize an AttractorSim object. Called automatically by JavaBotSim.
Specified by:
init in interface SimulatedObject
Parameters:
xp - the x coordinate.
yp - the y coordinate.
t - ingored.
r - the radius.
f - the foreground color.
b - the background color.
v - the vision class.
i - the unique id.
s - random number seed.

takeStep

public void takeStep(long time_increment,
                     SimulatedObject[] all_objs)
Take a simulated step;
Specified by:
takeStep in interface SimulatedObject
Tags copied from interface: SimulatedObject
Parameters:
time_increment - how much time has elapsed since the last call.
all_objects - the other objects in the simulation.

isObstacle

public boolean isObstacle()
Description copied from interface: SimulatedObject
true if the object should be considered an obstacle, false otherwise.
Specified by:
isObstacle in interface SimulatedObject
Tags copied from interface: SimulatedObject
Returns:
true if the object should be considered an obstacle, false otherwise.

isPushable

public boolean isPushable()
Description copied from interface: SimulatedObject
true if the object is pushable false otherwise.
Specified by:
isPushable in interface SimulatedObject
Tags copied from interface: SimulatedObject
Returns:
true if the object is pushable, false otherwise.

isPickupable

public boolean isPickupable()
Description copied from interface: SimulatedObject
true if the object can be picked up, false otherwise.
Specified by:
isPickupable in interface SimulatedObject
Tags copied from interface: SimulatedObject
Returns:
true if the object can be picked up, false otherwise.

receive

public void receive(Message m)
Description copied from interface: SimulatedObject
Receive a message. This is principally for robot to robot communication. Most objects can safely ignore this.
Specified by:
receive in interface SimulatedObject
Tags copied from interface: SimulatedObject
Parameters:
m - the message.

getClosestPoint

public Vec2 getClosestPoint(Vec2 from)
Description copied from interface: SimulatedObject
Find the closest point on the object from a particular location. This is useful for obstacle avoidance and so on.
Specified by:
getClosestPoint in interface SimulatedObject
Tags copied from interface: SimulatedObject
Parameters:
from - the place from which the point is determined.
Returns:
the closest point.

checkCollision

public boolean checkCollision(Circle2 c)
determine if the object is intersecting with a specified circle. This is useful for obstacle avoidance and so on.
Specified by:
checkCollision in interface SimulatedObject
Parameters:
c - the circle which may be intersecting the current object.
Returns:
true if collision detected.

checkCollision

public boolean checkCollision(Polygon2 p)
determine if the object is intersecting with a specified polygon. This is useful for obstacle avoidance and so on.
Specified by:
checkCollision in interface SimulatedObject
Parameters:
p - the polygon which may be intersecting the current object.
Returns:
true if collision detected.

getPosition

public Vec2 getPosition()
Description copied from interface: SimulatedObject
Find the center point of the object in absolute coordinates.
Specified by:
getPosition in interface SimulatedObject
Tags copied from interface: SimulatedObject
Returns:
the point.

getCenter

public Vec2 getCenter(Vec2 from)
Description copied from interface: SimulatedObject
Find the center point of the object from a particular location.
Specified by:
getCenter in interface SimulatedObject
Tags copied from interface: SimulatedObject
Parameters:
from - the place from which the point is determined.
Returns:
the center point.

push

public void push(Vec2 d,
                 Vec2 v)
Description copied from interface: SimulatedObject
Try to push the object.
Specified by:
push in interface SimulatedObject
Tags copied from interface: SimulatedObject
Parameters:
d - the direction and distance of the push.
v - the velocity of the push.

pickUp

public void pickUp(SimulatedObject o)
Description copied from interface: SimulatedObject
Try to pick up the object.
Specified by:
pickUp in interface SimulatedObject
Tags copied from interface: SimulatedObject
Parameters:
o - the object picking it up - this is used for drawing purposes.

putDown

public void putDown(Vec2 p)
Description copied from interface: SimulatedObject
Try to put down the object.
Specified by:
putDown in interface SimulatedObject
Tags copied from interface: SimulatedObject
Parameters:
p - the location of deposit.

setVisionClass

public void setVisionClass(int v)
Description copied from interface: SimulatedObject
Change the way the object is perceived by vision hardware. This can be used to make old targets invisible (a simulation hack.... sorry).
Specified by:
setVisionClass in interface SimulatedObject
Tags copied from interface: SimulatedObject
Parameters:
v - the new vision class.

getVisionClass

public int getVisionClass()
Description copied from interface: SimulatedObject
Return the vision class of the object.
Specified by:
getVisionClass in interface SimulatedObject
Tags copied from interface: SimulatedObject
Parameters:
v - the new vision class.

setID

public void setID(int i)
Description copied from interface: SimulatedObject
Set the id of the object.
Specified by:
setID in interface SimulatedObject
Tags copied from interface: SimulatedObject
Parameters:
id - the new id.

getID

public int getID()
Description copied from interface: SimulatedObject
Return the id.
Specified by:
getID in interface SimulatedObject

quit

public void quit()
Description copied from interface: SimulatedObject
Clean up.
Specified by:
quit in interface SimulatedObject

drawID

public void drawID(java.awt.Graphics g,
                   int w,
                   int h,
                   double t,
                   double b,
                   double l,
                   double r)
Draw the attractor's ID.
Specified by:
drawID in interface SimulatedObject
Tags copied from interface: SimulatedObject
Parameters:
g - graphics area to draw the object.
w - the width in pixels of g.
h - the height in pixels of g.
t - the y coordinate represented by the top boundary of the drawing area.
b - the y coordinate represented by the bottom boundary of the drawing area.
l - the x coordinate represented by the left boundary of the drawing area.
r - the x coordinate represented by the right boundary of the drawing area.

drawState

public void drawState(java.awt.Graphics g,
                      int w,
                      int h,
                      double t,
                      double b,
                      double l,
                      double r)
Draw the attractor's State.
Specified by:
drawState in interface SimulatedObject
Tags copied from interface: SimulatedObject
Parameters:
g - graphics area to draw the object.
w - the width in pixels of g.
h - the height in pixels of g.
t - the y coordinate represented by the top boundary of the drawing area.
b - the y coordinate represented by the bottom boundary of the drawing area.
l - the x coordinate represented by the left boundary of the drawing area.
r - the x coordinate represented by the right boundary of the drawing area.

setTrailLength

public void setTrailLength(int l)
Set the length of the trail (in movement steps). Non-robots can ignore this.
Specified by:
setTrailLength in interface SimulatedObject
Parameters:
l - int, the length of the trail.

clearTrail

public void clearTrail()
Clear the trail. Non-robots can ignore this.
Specified by:
clearTrail in interface SimulatedObject

drawTrail

public void drawTrail(java.awt.Graphics g,
                      int w,
                      int h,
                      double t,
                      double b,
                      double l,
                      double r)
Draw the attractor's Trail.
Specified by:
drawTrail in interface SimulatedObject
Tags copied from interface: SimulatedObject
Parameters:
g - graphics area to draw the object.
w - the width in pixels of g.
h - the height in pixels of g.
t - the y coordinate represented by the top boundary of the drawing area.
b - the y coordinate represented by the bottom boundary of the drawing area.
l - the x coordinate represented by the left boundary of the drawing area.
r - the x coordinate represented by the right boundary of the drawing area.

drawIcon

public void drawIcon(java.awt.Graphics g,
                     int w,
                     int h,
                     double t,
                     double b,
                     double l,
                     double r)
Draw the attractor as an icon. Default is just to do a regular draw.
Specified by:
drawIcon in interface SimulatedObject
Tags copied from interface: SimulatedObject
Parameters:
g - graphics area to draw the object.
w - the width in pixels of g.
h - the height in pixels of g.
t - the y coordinate represented by the top boundary of the drawing area.
b - the y coordinate represented by the bottom boundary of the drawing area.
l - the x coordinate represented by the left boundary of the drawing area.
r - the x coordinate represented by the right boundary of the drawing area.

draw

public void draw(java.awt.Graphics g,
                 int w,
                 int h,
                 double t,
                 double b,
                 double l,
                 double r)
Draw the attractor.
Specified by:
draw in interface SimulatedObject
Tags copied from interface: SimulatedObject
Parameters:
g - graphics area to draw the object.
w - the width in pixels of g.
h - the height in pixels of g.
t - the y coordinate represented by the top boundary of the drawing area.
b - the y coordinate represented by the bottom boundary of the drawing area.
l - the x coordinate represented by the left boundary of the drawing area.
r - the x coordinate represented by the right boundary of the drawing area.

draw

public void draw(Vec2 pos,
                 java.awt.Graphics g,
                 int w,
                 int h,
                 double t,
                 double b,
                 double l,
                 double r)
Draw the object in a specific spot.
Specified by:
draw in interface SimulatedObject
Tags copied from interface: SimulatedObject
Parameters:
p - location to draw it at.
g - graphics area to draw the object.
w - the width in pixels of g.
h - the height in pixels of g.
t - the y coordinate represented by the top boundary of the drawing area.
b - the y coordinate represented by the bottom boundary of the drawing area.
l - the x coordinate represented by the left boundary of the drawing area.
r - the x coordinate represented by the right boundary of the drawing area.