diff --git a/assignments/src/MV3500Cohort2023MarchJune/homework3/Islas/ExampleSimulationProgram.java b/assignments/src/MV3500Cohort2023MarchJune/homework3/Islas/ExampleSimulationProgram.java index 969c44d902d5ab9e2f32ea3471be2d3db2a81fb1..f21d15eae2ac5f2f47ab04288de6efbbee9ebb3b 100644 --- a/assignments/src/MV3500Cohort2023MarchJune/homework3/Islas/ExampleSimulationProgram.java +++ b/assignments/src/MV3500Cohort2023MarchJune/homework3/Islas/ExampleSimulationProgram.java @@ -236,20 +236,23 @@ public class ExampleSimulationProgram Double dMinusP_X = entityStatePdu_2.getEntityLocation().getX() - entityStatePdu_1.getEntityLocation().getX(); Double dMinusP_Z = entityStatePdu_2.getEntityLocation().getZ() - entityStatePdu_1.getEntityLocation().getZ(); Double magnitudeDMinusP = Math.sqrt(dMinusP_X * dMinusP_X + dMinusP_Z * dMinusP_Z); - Double speed = 77.2; // Average speed of CH53 - meters per second + // Final velocity values Double velocityX = dMinusP_X * speed / magnitudeDMinusP; Double velocityZ = dMinusP_Z * speed / magnitudeDMinusP; + // Moves Entity 1 towards Entity 2 entityStatePdu_1.getEntityLocation().setX(entityStatePdu_1.getEntityLocation().getX() + velocityX); entityStatePdu_1.getEntityLocation().setZ(entityStatePdu_1.getEntityLocation().getZ() + velocityZ); - // decide whether to fire, and then update the firePdu. Hmmm, you might want a target to shoot at! + + // Calculates the total distance between the two Entities double magnitudeX = entityStatePdu_2.getEntityLocation().getX() - entityStatePdu_1.getEntityLocation().getX(); double magnitudeY = entityStatePdu_2.getEntityLocation().getY() - entityStatePdu_1.getEntityLocation().getY(); double magnitudeZ = entityStatePdu_2.getEntityLocation().getZ() - entityStatePdu_1.getEntityLocation().getZ(); double magnitude = Math.sqrt(magnitudeX * magnitudeX + magnitudeY * magnitudeY + magnitudeZ * magnitudeZ); + // Shows an easy to identify log of Entity movement and a firing action System.out.println(""); System.out.println(entityStatePdu_1.getEntityLocation()); if (magnitude < firePdu_1a.getRange()) { @@ -259,6 +262,7 @@ public class ExampleSimulationProgram System.out.println("Fire at target"); } System.out.println(""); + // etc. etc. your code goes here for your simulation of interest // something happens between my simulation entities, la de da de da... diff --git a/assignments/src/MV3500Cohort2023MarchJune/homework3/Islas/package-info.java b/assignments/src/MV3500Cohort2023MarchJune/homework3/Islas/package-info.java index 2029f30135f62a1de90a0214727fb21feeb22de3..3ae2e78cb32bc2556a55f36cbb9a9b0bfb84d5ef 100644 --- a/assignments/src/MV3500Cohort2023MarchJune/homework3/Islas/package-info.java +++ b/assignments/src/MV3500Cohort2023MarchJune/homework3/Islas/package-info.java @@ -6,8 +6,11 @@ * @see <a href="https://stackoverflow.com/questions/22095487/why-is-package-info-java-useful">StackOverflow: why-is-package-info-java-useful</a> * @see <a href="https://stackoverflow.com/questions/624422/how-do-i-document-packages-in-java">StackOverflow: how-do-i-document-packages-in-java</a> * - * Updating original example to include X, Y, and Z coordinates for each entity sent across the network. + * Sets coordinates for Entity 1 and Entity 2. When simulations starts, Entity 1 advances towards Entity 2 and + * fires munitions when in range. Prints Entity 1 location and firing info (on occurance) to console after each step of the simulation. + * * Adjusted time between loops to three seconds to allow for ease of reading. + * * Adjusted total number of loops to 4 to shorten simulation time. * */