Skip to content
Snippets Groups Projects
Commit 9047d334 authored by Timberlake, James (Jack) (LT)'s avatar Timberlake, James (Jack) (LT)
Browse files

Updates to assignment 3

parent 05da0fe8
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ import edu.nps.moves.dis7.pdus.*;
import edu.nps.moves.dis7.utilities.DisChannel;
import edu.nps.moves.dis7.utilities.PduFactory;
import java.time.LocalDateTime;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -64,6 +65,11 @@ public class TimberlakeSimulationProgram {
/** MunitionDescriptor for these weapons */
protected MunitionDescriptor munitionDescriptor1;
/** TODO DetonationPdu for entity 1 second weapon (if any) */
protected DetonationPdu DetonationPdu_1a;
/** TODO DetonationPdu for entity 1 second weapon (if any) */
protected DetonationPdu DetonationPdu_1b;
// hey programmer, what other state do you want? this is a good place to declare it...
/**
......@@ -157,8 +163,11 @@ public class TimberlakeSimulationProgram {
firePdu_1b = pduFactory.makeFirePdu();
munitionDescriptor1 = new MunitionDescriptor();
DetonationPdu_1a = pduFactory.makeDetonationPdu();
DetonationPdu_1b = pduFactory.makeDetonationPdu();
DetonationPdu_1a.setSourceEntityID(entityID_1);
// Your model setup: define participants. who's who in this zoo?
// Assuming you keep track of entity objects... here is some support for for Entity 1.
......@@ -183,13 +192,18 @@ public class TimberlakeSimulationProgram {
entityStatePdu_2.setForceId(ForceID.OPPOSING);
entityStatePdu_2.setEntityType(new _002Triton()); // note import statement above
entityStatePdu_2.setMarking("Entity #2");
Random random = new Random();
int randX = random.nextInt(10);
int randY = random.nextInt(10);
entityStatePdu_2.getEntityLocation().setX(randX);
entityStatePdu_2.getEntityLocation().setY(randY);
// TODO how should we customize this munition? what are key parameters for your simulation?
// more is needed here by scenario authors...
// munitionDescriptor1.setQuantity(1);
// firePdu_1a.setDescriptor(munitionDescriptor1).setRange(1000.0f);
// Jack Added
// Jack Added ******* HIGHLIGHT, THEN CTRL-[SPACE] TO SEE OPTIONS!! ******
munitionDescriptor1.setQuantity(1);
munitionDescriptor1.setWarhead(MunitionDescriptorWarhead.HE_BLAST_FRAGMENTATION);
munitionDescriptor1.setFuse(MunitionDescriptorFuse.PROXIMITY);
......@@ -242,14 +256,57 @@ public class TimberlakeSimulationProgram {
// =============================================================================================
// * your own simulation code starts here! *****************************************************
// =============================================================================================
if (simulationLoopCount % 2 == 0) { // Fire every 3 loops
//firePdu_1a.setEventID(new EventIdentifier(1, 1, simulationLoopCount));
// Send the Fire PDU
DetonationPdu_1a.setLocationInWorldCoordinates(entityStatePdu_2.getEntityLocation()); // Set detonation at target's location
disChannel.sendSinglePdu(simulationTimeSeconds, firePdu_1a);
disChannel.sendSinglePdu(simulationTimeSeconds, DetonationPdu_1a);
System.out.println("******** Fire PDU sent at simulation loop: " + simulationLoopCount + " ********");
}
Vector3Double badGuyLocation = entityStatePdu_2.getEntityLocation();
//Boolean badGuyStatus = entityStatePdu_2.isEntityDamageStatusPdu();
Vector3Double goodGuyLocation = entityStatePdu_1.getEntityLocation();
System.out.println("Friendly Location: " + goodGuyLocation);
System.out.println("Enemy Location: " + badGuyLocation);
//System.out.println("Enemy Status: " + badGuyStatus);
Vector3Double detonationLocation = DetonationPdu_1a.getLocationInWorldCoordinates();
double distance = Math.sqrt(
Math.pow(detonationLocation.getX() - badGuyLocation.getX(), 2) +
Math.pow(detonationLocation.getY() - badGuyLocation.getY(), 2) +
Math.pow(detonationLocation.getZ() - badGuyLocation.getZ(), 2)
);
System.out.println("Distance between detonation and target: " + distance);
if (DetonationPdu_1a != null) {
System.out.println("Detonation PDU generated for firePdu_1a.");
} else {
System.out.println("Detonation PDU NOT generated for firePdu_1a.");
}
if (firePdu_1a.getTargetEntityID().equals(entityStatePdu_2.getEntityID())) {
System.out.println("FirePdu targets entityStatePdu_2.");
} else {
System.out.println("FirePdu is not targeting entityStatePdu_2.");
}
if (DetonationPdu_1a.getTargetEntityID().equals(entityStatePdu_2.getEntityID())) {
System.out.println("Detonation occurred and targeted entityStatePdu_2.");
} else {
System.out.println("Detonation DID NOT occur at entityStatePdu_2.");
}
if (entityStatePdu_2.isEntityDamageStatusPdu()) {
System.out.println("entityStatePdu_2 is damaged by the detonation.");
} else {
System.out.println("entityStatePdu_2 NOT damaged by the detonation.");
}
// are there any other variables to modify at the beginning of your loop?
// are your reading any DIS PDUs from the network? check for them here
......
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