|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.ObjectsimuLCS.Simulation
Important class: handles the entities, the Thread for running the Simulation, and the Thread to update the Behaviour shown to the user when there is a GUI.
| Nested Class Summary | |
(package private) class |
Simulation.Animation
The inner class handling the simulation (MAIN PROCEDURE) |
(package private) class |
Simulation.TimerUpdate
The task to be executed every X milliSeconds |
| Field Summary | |
protected java.lang.Thread |
animation
|
protected Arena |
arena
|
private java.io.BufferedWriter |
bW
|
private java.util.SortedSet |
entities
The entities used in the Simulation |
private java.lang.String |
fileBaseForPlotting
|
private java.lang.String |
fileBaseForSeveralPlotting
|
private java.io.FileWriter |
fW
|
protected java.util.Random |
generator
|
private java.awt.Graphics2D |
graphics
|
private java.awt.Graphics2D |
graphicsOffscreen
|
private boolean |
hasAlreadyOneAgentInteractive
|
private boolean |
isNewRun
Used to know when to ask the name of the file |
private boolean |
isPlotting
|
private boolean |
isSimuRunning
|
private int |
maxTimeSteps
|
private int |
nbAgentsToCreate
|
protected int |
nbOfRuns
|
protected int |
nbOfRunsDone
|
private java.awt.Image |
offscreen
|
private int |
plottingInterval
|
private java.io.PrintWriter |
pW
|
private boolean |
simuStep
Used to run the simulation only for one step |
private int |
timeStep
|
private static int |
UPDATE_BEHAVIOUR_TO_SHOW
|
private Utils |
utils
|
private G_MainWindow |
window
|
| Constructor Summary | |
Simulation(Utils u)
|
|
| Method Summary | |
void |
add()
Add one default entity |
void |
add(Entity e)
Adding the given entity to the Simulation. |
void |
add(int name)
Add the default entity : the AgentClassifierLearning with the TemplateRSPVerySimple (by convention). |
void |
addWithChoice()
The user can choose which Agent should be added, if there is a GUI otherwise, the default Agent is added. |
void |
clearSimu(java.awt.Graphics2D g)
Erasing everything in the Drawing Panel |
private void |
closeFile()
Close the data file and creates the gnuplot file and the file saving the rules at the end, for each agent |
void |
create()
|
void |
create(int numAgents)
|
void |
createAnimation()
Creating the Thread for the Animation |
void |
finish()
Stopping the simulation. |
java.util.Iterator |
getEntities()
|
java.lang.String |
getFileBaseForPlotting()
|
java.lang.String |
getFileBaseForSeveralPlotting()
|
static int |
getMaxNbEntities()
|
int |
getMaxTimeSteps()
|
int |
getNbOfRuns()
|
int |
getNumberOfEntities()
|
private void |
init()
Initializing the simulation |
boolean |
isNewRun()
|
boolean |
isSimuRunning()
|
void |
launchUpdateThread(long timeInMilliSeconds)
Launch the Thread that updates every timeInMilliSeconds
the behaviour shown in the display (to avoid real-time, because
it makes the simulation really slow) |
void |
linkToGraphics(G_MainWindow win)
|
private void |
openFile()
Open the file to start recording the average reward. |
void |
paintSimu(java.awt.Graphics2D g)
Painting all the simulation |
void |
remove(Entity e)
Removing the given entity to the simulation |
void |
reset()
Starting again with the default simulation. |
void |
run()
Starts the Thread Animation |
void |
setFileBaseForPlotting(java.lang.String string)
|
void |
setFileBaseForSeveralPlotting(java.lang.String string)
|
void |
setMaximumTimeSteps(int max)
|
void |
setMaxTimeSteps(int i)
|
void |
setNbOfRuns(int i)
|
void |
setNewRun(boolean b)
|
void |
start()
Starting the simulation ! |
void |
step()
Just one time step more. |
void |
stop()
Pausing the simulation. |
void |
updateBehaviours()
The function to launch in the Thread updateTask |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private java.util.SortedSet entities
private G_MainWindow window
private java.awt.Graphics2D graphics
private Utils utils
private boolean isSimuRunning
private boolean simuStep
private boolean isNewRun
protected int nbOfRuns
protected int nbOfRunsDone
private boolean isPlotting
private int plottingInterval
private java.lang.String fileBaseForPlotting
private java.lang.String fileBaseForSeveralPlotting
private java.io.FileWriter fW
private java.io.BufferedWriter bW
private java.io.PrintWriter pW
private int timeStep
private int maxTimeSteps
private static final int UPDATE_BEHAVIOUR_TO_SHOW
protected java.lang.Thread animation
private int nbAgentsToCreate
private boolean hasAlreadyOneAgentInteractive
protected java.util.Random generator
private java.awt.Image offscreen
private java.awt.Graphics2D graphicsOffscreen
protected Arena arena
| Constructor Detail |
public Simulation(Utils u)
| Method Detail |
public void linkToGraphics(G_MainWindow win)
public void add()
public void add(int name)
name - public void addWithChoice()
public void add(Entity e)
e - public void remove(Entity e)
e - public void paintSimu(java.awt.Graphics2D g)
g - public void clearSimu(java.awt.Graphics2D g)
g - public void create()
public void create(int numAgents)
private void openFile()
private void closeFile()
Utils.writeFileGnuplot(String, Entity[], String),
Utils.writeFileWithRules(String, Entity[])public void start()
public void stop()
public void finish()
public void step()
public void reset()
private void init()
public void createAnimation()
public void launchUpdateThread(long timeInMilliSeconds)
timeInMilliSeconds
the behaviour shown in the display (to avoid real-time, because
it makes the simulation really slow)
timeInMilliSeconds - public void run()
public void updateBehaviours()
launchUpdateThread(long),
Simulation.TimerUpdatepublic static int getMaxNbEntities()
public int getNumberOfEntities()
public java.util.Iterator getEntities()
public boolean isSimuRunning()
public boolean isNewRun()
public void setNewRun(boolean b)
b - public java.lang.String getFileBaseForPlotting()
public void setFileBaseForPlotting(java.lang.String string)
string - public java.lang.String getFileBaseForSeveralPlotting()
public void setFileBaseForSeveralPlotting(java.lang.String string)
public void setMaximumTimeSteps(int max)
public int getNbOfRuns()
public void setNbOfRuns(int i)
i - public int getMaxTimeSteps()
public void setMaxTimeSteps(int i)
i -
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||