|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--tjhCell
Encapsulates a cell in our pseudo-biological simulation. The cell's properties include a position, a reference to its parent (if any) and a list of children (if any). This is a tree structure.
| Field Summary | |
protected float |
angular_momentum
the current angular momentum of the cell (in degrees) |
protected static float |
ANGULAR_MOMENTUM
the maximum angular momentum of each cell in degrees |
protected boolean |
has_parent
stores whether this cell has a parent, or is the root cell for this creature |
protected tjhCreature |
host_creature
a reference to the owning host creature |
protected tjh2dVector |
location
the current location of the cell |
protected tjhNeuron |
neuron
the cell's brains (they're a bit thick at the moment) |
protected tjhCell |
parent
a reference to the parent of the cell (if any) |
protected static float |
RADIUS
the radius of the cells, fixed for now at least |
protected boolean |
seen_green
stores whether the cell has seen a green enemy cell nearby |
protected boolean |
seen_red
stores whether the cell has seen a red enemy cell nearby |
protected static float |
SIGHT_DIST
the distance within which cells can sense each other |
protected java.util.Vector |
subnodes
a list of the cells that are children of this cell |
protected int |
type
stores the type of the cell, determines its interactions and how it is drawn |
protected static boolean |
USE_BRAINS
do we want the cells to use their brains? |
| Constructor Summary | |
tjhCell()
default constructor |
|
| Method Summary | |
protected boolean |
CanMoveBy(tjh2dVector delta,
tjh2dVector limit,
tjhBuckets buckets,
tjhCell asker,
java.util.Vector deaths)
detect any collisions with other cells that the requested move would cause |
protected boolean |
CanMoveTo(tjh2dVector prop_loc,
tjh2dVector limit,
tjhBuckets buckets,
tjhCell asker,
java.util.Vector deaths)
collision detection/resolution check for a *single* cell, doesn't recurse |
protected boolean |
CanRotate(tjh2dVector centre,
float delta,
tjh2dVector limit,
tjhBuckets buckets,
tjhCell asker,
java.util.Vector deaths)
will the requested rotation cause a collision? |
protected boolean |
CloserThan(tjh2dVector loc,
tjhCell them,
float d)
is the point loc closer to the cell them than the distance d? |
void |
Draw(java.awt.Graphics g)
draws the cell (recurses to draw its daughter cells too) |
protected boolean |
InArea(tjh2dVector loc,
tjh2dVector limit)
is the point loc within the area of the simulation? |
protected void |
Instantiate(tjhGene genome,
tjhCreature host,
tjhBuckets buckets,
tjh2dVector limit)
top-level call to instantiate a tree of cells from the given genome. |
protected void |
InstantiateChildren(tjhGene genome,
tjhCreature host,
tjhBuckets buckets,
tjh2dVector limit)
recurses down to instantiate all mid-level and leaf-level nodes in the tree of cells that is being created |
protected boolean |
IsOurChild(tjhCell child)
is the specified cell below us in the tree? |
protected void |
Killed(tjhBuckets buckets)
this cell has been killed, ask it to tidy itself away |
protected void |
MoveArms(java.awt.Graphics g,
tjhBuckets buckets,
tjh2dVector limit)
each cell moves about its parent axis (as long as no collision is caused) |
protected void |
MoveBy(tjh2dVector delta,
tjhBuckets buckets)
all checks have been made, just move the cells |
protected boolean |
MoveIfCan(tjh2dVector delta,
tjh2dVector limit,
tjhBuckets buckets)
a move request, the cell will move as requested only if able to |
protected int |
NearestVisible(java.util.Vector within_sight)
returns the index (in the list within_sight) of the nearest enemy cell |
protected float |
RandomAngle()
return a random angle between 0 and 360 degrees |
protected float |
RandomAngularMomentum()
pick an angular momentum at random |
protected void |
RemoveAllFromGlobalList(tjhBuckets buckets)
recurses down to ask all children to remove themselves from the global buckets structure |
protected void |
Rotate(tjh2dVector centre,
float delta,
tjhBuckets buckets)
all checks have been made, just rotate the cell |
protected boolean |
RotateIfCan(tjh2dVector centre,
float delta,
tjh2dVector limit,
tjhBuckets buckets)
a rotation request, the cell will rotate only if no collision is caused |
protected void |
StimulusResponse(java.awt.Graphics g,
tjhBuckets buckets)
if the neurons are active, reset the angular momentum in response to the nearby cells, otherwise does nothing |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
protected static final float RADIUS
protected static final float ANGULAR_MOMENTUM
protected static final float SIGHT_DIST
protected static final boolean USE_BRAINS
protected tjh2dVector location
protected tjhCell parent
protected tjhCreature host_creature
protected boolean has_parent
protected java.util.Vector subnodes
protected int type
protected float angular_momentum
protected tjhNeuron neuron
protected boolean seen_red
protected boolean seen_green
| Constructor Detail |
public tjhCell()
| Method Detail |
public void Draw(java.awt.Graphics g)
protected void Instantiate(tjhGene genome,
tjhCreature host,
tjhBuckets buckets,
tjh2dVector limit)
protected void InstantiateChildren(tjhGene genome,
tjhCreature host,
tjhBuckets buckets,
tjh2dVector limit)
protected void Killed(tjhBuckets buckets)
protected void RemoveAllFromGlobalList(tjhBuckets buckets)
protected boolean MoveIfCan(tjh2dVector delta,
tjh2dVector limit,
tjhBuckets buckets)
protected boolean CanMoveBy(tjh2dVector delta,
tjh2dVector limit,
tjhBuckets buckets,
tjhCell asker,
java.util.Vector deaths)
protected void MoveArms(java.awt.Graphics g,
tjhBuckets buckets,
tjh2dVector limit)
protected void StimulusResponse(java.awt.Graphics g,
tjhBuckets buckets)
protected int NearestVisible(java.util.Vector within_sight)
protected boolean RotateIfCan(tjh2dVector centre,
float delta,
tjh2dVector limit,
tjhBuckets buckets)
protected boolean CanRotate(tjh2dVector centre,
float delta,
tjh2dVector limit,
tjhBuckets buckets,
tjhCell asker,
java.util.Vector deaths)
protected boolean CanMoveTo(tjh2dVector prop_loc,
tjh2dVector limit,
tjhBuckets buckets,
tjhCell asker,
java.util.Vector deaths)
protected boolean IsOurChild(tjhCell child)
protected void MoveBy(tjh2dVector delta,
tjhBuckets buckets)
protected void Rotate(tjh2dVector centre,
float delta,
tjhBuckets buckets)
protected boolean InArea(tjh2dVector loc,
tjh2dVector limit)
protected boolean CloserThan(tjh2dVector loc,
tjhCell them,
float d)
protected float RandomAngularMomentum()
protected float RandomAngle()
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||