Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NetworkedGraphicsMV3500
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Savage
NetworkedGraphicsMV3500
Commits
87f5a4b9
Commit
87f5a4b9
authored
8 months ago
by
owner
Browse files
Options
Downloads
Patches
Plain Diff
Homework 3
parent
8cc719f4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
assignments/src/MV3500Cohort2024JulySeptember/homework3/Lennon/LennonSimulationProgram.java
+5
-8
5 additions, 8 deletions
...lySeptember/homework3/Lennon/LennonSimulationProgram.java
with
5 additions
and
8 deletions
assignments/src/MV3500Cohort2024JulySeptember/homework3/Lennon/LennonSimulationProgram.java
+
5
−
8
View file @
87f5a4b9
...
...
@@ -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
(
tru
e
);
disChannel
.
getPduRecorder
().
setVerbose
(
fals
e
);
// 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
=
1
0
;
// set number of turns in the game; also avoid infinite loops.
final
int
SIMULATION_MAX_LOOP_COUNT
=
2
0
;
// 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"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment