|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--morey.spore.Processor
Processor is the "Central Brain" for Spore War. Eventhough Spore War is a decentralized system, the Central Brain will be used to keep things fairly reproducible. I beleive that there will be timing issues that I will eventually have to deal with like if two near by polygons move at the exact time what is the result. At this point the Processor will have unpredictable results. For now, I'm willing to live with that.
Team assignments (the integer numbers...) ....How is it done?
This first kick at the can will have:
Here is a link to the source code
SporeListener,
Spore,
SporeAction| Field Summary | |
static double |
BOARD_SIZE
the default board size |
double |
boardSize
the board size |
protected ProximityList |
claims
a spatial list of the current claims (to test for collisions) |
protected java.util.Vector |
controlListeners
a list of Objects listening to the control actions of the Processor |
protected static int |
numOfTeams
A constant fo the upper limit of teams |
protected java.util.Hashtable |
programs
a list of spore programs that the Processor knows |
protected boolean |
rebuildTeamList
a list of Objects listening to SporeEvents |
protected int |
runVersion
holds the version of this run |
protected java.util.Vector |
sporeListeners
a list of Objects listening to SporeEvents |
protected ProximityList |
spores
a spatial list of the live spore (to test for collisions) |
protected Heap |
teamList
the list of all the active teams. |
protected Team[] |
teams
the list of Teams |
protected double |
time
the current processor time |
| Constructor Summary | |
Processor()
Construct the Processor with BOARD_SIZE size |
|
Processor(double boardSize)
Construct the Processor with a particular size |
|
| Method Summary | |
protected void |
add(double x,
double y,
double angle,
java.lang.String prog,
int team)
|
protected void |
addCode(java.io.StreamTokenizer st)
puts the "program" from the code into the Processor |
void |
addControlListener(ControlListener cl)
adds a ControlListener from the list of listeners |
void |
addSpore(Spore s)
adds a spore to the processList |
void |
addSporeListener(SporeListener sl)
adds a SporeListener from the list of listeners |
boolean |
claim(Spore s)
puts a spore's claim to the territory |
void |
clear()
|
void |
clearBoard()
removes all the current claims and spores from the Processor |
boolean |
enter(Spore s)
has a spore enter new territory. |
double |
getBoardSize()
the accessor to the boardSize |
java.util.Iterator |
getOrderedSpores()
gets the names of the programs on the list. |
java.util.Enumeration |
getPrograms()
gets the names of the programs on the list. |
Spore |
getSpore(java.lang.String name)
|
java.util.Stack |
getStack(java.lang.String name)
gets a "program" from the programs list. |
double |
getTime()
gets the current "processor" time (an internal time that has little to do with real time). |
protected void |
init()
initialize the Processor |
void |
leave(Spore s)
has a spore leave it's territory. |
protected void |
load(java.lang.String filename)
loads a file into the content field of this SimpleWall. |
void |
processNext()
processes the next spore. |
void |
putProgram(java.lang.String name,
Spore s,
boolean force)
adds a "program" to the programs list. |
void |
removeControlListener(ControlListener cl)
remove a ControlListener from the list of listeners |
void |
removePrograms()
removes all the currently loaded programs from the Processor |
void |
removeSporeListener(SporeListener sl)
remove a SporeListener from the list of listeners |
void |
run()
runs the Processor on the processList |
void |
sporeUpdate(SporeEventObject se)
tells of the SporeListeners of the SporeEvent |
void |
step()
|
void |
stop()
stop the current run |
void |
updateActions(java.lang.String action)
tells of the ControlListeners of the new action done on the Processor |
void |
updateProgram(java.lang.String programs)
tells of the ControlListeners of the on the Processor |
void |
updateState(int state)
tells of the ControlListeners of the new action Processor state |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
public static final double BOARD_SIZE
public final double boardSize
protected java.util.Hashtable programs
protected double time
protected int runVersion
protected Heap teamList
protected ProximityList spores
protected ProximityList claims
protected Team[] teams
protected static final int numOfTeams
protected transient java.util.Vector sporeListeners
protected transient java.util.Vector controlListeners
protected boolean rebuildTeamList
| Constructor Detail |
public Processor(double boardSize)
boardSize - the size of the boardpublic Processor()
| Method Detail |
protected void init()
public void run()
public void processNext()
public double getTime()
public boolean claim(Spore s)
s - - a spore that wants to claim new spacepublic void leave(Spore s)
s - - a spore that will leave it's old spacepublic boolean enter(Spore s)
s - - a spore that will enter a new spacepublic java.util.Stack getStack(java.lang.String name)
public Spore getSpore(java.lang.String name)
public java.util.Enumeration getPrograms()
public java.util.Iterator getOrderedSpores()
public void removePrograms()
Processorpublic void clearBoard()
Processor
public void putProgram(java.lang.String name,
Spore s,
boolean force)
throws DuplicateCodeException
name - the name of this programs - an example spore that will be the template for spawningforce - if true it will replace existing programs with the same namepublic void addSpore(Spore s)
processLists - - a spore to be added to the processListpublic void stop()
public double getBoardSize()
public void addSporeListener(SporeListener sl)
sl - - a sporeListener that wants to hear about the sporeEvents
generated by this processorpublic void removeSporeListener(SporeListener sl)
sl - - a sporeListener that wants to be removed from the list of
Listenerspublic void sporeUpdate(SporeEventObject se)
se - - the sporeEvent to be shared with all the SporeListenerspublic void addControlListener(ControlListener cl)
cl - - a controlListener that wants to hear about this processorpublic void removeControlListener(ControlListener cl)
cl - - a ControlListener that wants to be removed from the list of
Listenerspublic void updateProgram(java.lang.String programs)
programs - the programs on the Processorpublic void updateActions(java.lang.String action)
action - the new action done on the Processorpublic void updateState(int state)
action - the new action done on the Processorprotected void addCode(java.io.StreamTokenizer st)
code - - the unparsed (genetic) code for a sporeprotected void load(java.lang.String filename)
filename - - the file name / URL where thet codes will be foundpublic void step()
protected void add(double x,
double y,
double angle,
java.lang.String prog,
int team)
public void clear()
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||