Skip to content
Snippets Groups Projects
Commit 87f5a4b9 authored by owner's avatar owner
Browse files

Homework 3

parent 8cc719f4
No related branches found
No related tags found
No related merge requests found
......@@ -141,7 +141,7 @@ public class LennonSimulationProgram
disChannel.getDisNetworkInterface().setVerbose(true); // sending and receipt
disChannel.printlnTRACE ("just checking: hasVerboseSending()=" + disChannel.getDisNetworkInterface().hasVerboseSending() +
", hasVerboseReceipt()=" + disChannel.getDisNetworkInterface().hasVerboseReceipt());
disChannel.getPduRecorder().setVerbose(true);
disChannel.getPduRecorder().setVerbose(false);
// TODO confirm whether recorder is explicitly started by programmer (or not)
......@@ -209,10 +209,10 @@ public class LennonSimulationProgram
{
try
{
final int SIMULATION_MAX_LOOP_COUNT = 10; // set number of turns in the game; also avoid infinite loops.
final int SIMULATION_MAX_LOOP_COUNT = 20; // set number of turns in the game; also avoid infinite loops.
int simulationLoopCount = 0; // variable, initialized at 0
boolean simulationComplete = false; // sentinel variable as termination condition, are we done yet?
final int NUMBER_MINES = 5; // preset number of mines to be placed
final int NUMBER_MINES = 30; // preset number of mines to be placed
// TODO reset Clock Time for today's date and timestamp to zero, providing consistent outputs for each simulation run
String timeMessage = "Simulation time " + simulationTimeSeconds + " at LocalDateTime " + LocalDateTime.now();
disChannel.sendCommentPdu(simulationTimeSeconds, DisChannel.COMMENTPDU_TIME, timeMessage);
......@@ -288,15 +288,12 @@ public class LennonSimulationProgram
// compute a track, update an ESPDU, whatever it is that your model is doing...
// Where is my entity? Insert changes in position; this sample only changes X position.
entityStatePdu_1.getEntityLocation().setX(entityStatePdu_1.getEntityLocation().getX() + 1.0); // 1m per timestep
// decide whether to fire, and then update the firePdu. Hmmm, you might want a target to shoot at!
// etc. etc. your code goes here for your simulation of interest
// something happens between my simulation entities, la de da de da...
System.out.println ("... My simulation just did something, no really...");
System.out.flush(); // make sure this arrives to user even if other threads somehow become deadlocked
......@@ -336,7 +333,7 @@ public class LennonSimulationProgram
// staying synchronized with timestep: wait duration for elapsed time in this loop
// Thread.sleep needs a (long) parameter for milliseconds, which are clumsy to use sometimes
Thread.sleep((long)(getSimulationTimeStepDuration() * 1000)); // units of seconds * (1000 msec/sec) = milliseconds
System.out.println ("... [Pausing for " + getSimulationTimeStepDuration() + " seconds]");
//System.out.println ("... [Pausing for " + getSimulationTimeStepDuration() + " seconds]");
// OK now send the status PDUs for this loop, and then continue
System.out.println ("... sending PDUs of interest for simulation step " + simulationLoopCount + ", monitor loopback to confirm sent");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment