Commit b71107de authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

Bugfix in "TargetChangerController": "useStaticTargetForAgent()" did not...

Bugfix in "TargetChangerController": "useStaticTargetForAgent()" did not update agent's "nextTargetListIndex" properly
parent a87c170c
Pipeline #177442 passed with stages
in 139 minutes and 58 seconds
......@@ -160,9 +160,7 @@ public class TargetChangerController {
}
private void useStaticTargetForAgent(Agent agent) {
LinkedList<Integer> newTarget = new LinkedList<>();
newTarget.add(targetChanger.getAttributes().getNextTarget());
agent.setTargets(newTarget);
agent.setSingleTarget(targetChanger.getAttributes().getNextTarget(), false);
}
private void notifyListenersTargetChangerAreaReached(final Agent agent) {
......
......@@ -169,6 +169,32 @@ public class TargetChangerControllerTest {
assertListContainsSingleTarget(pedestrians.get(1).getTargets(), nextTarget);
}
@Test
public void updateSetsNextTargetListIndexToZeroOfAffectedPedestrianIfProbabilityIsOne() {
LinkedList<Integer> currentTargets = new LinkedList<Integer>(Arrays.asList(1, 2, 3));
int nextTargetIndex = 1;
pedestrians.get(1).setTargets(currentTargets);
pedestrians.get(1).setNextTargetListIndex(nextTargetIndex);
int nextTarget = 2;
double probability = 1.0;
AttributesTargetChanger attributesTargetChanger = createAttributesWithFixedRectangle();
attributesTargetChanger.setNextTarget(nextTarget);
attributesTargetChanger.setProbabilityToChangeTarget(probability);
TargetChanger targetChanger = new TargetChanger(attributesTargetChanger);
TargetChangerController controllerUnderTest = createTargetChangerController(targetChanger);
assertEquals(nextTargetIndex, pedestrians.get(1).getNextTargetListIndex());
controllerUnderTest.update(simTimeInSec);
assertEquals(0, pedestrians.get(1).getNextTargetListIndex());
assertListContainsSingleTarget(pedestrians.get(1).getTargets(), nextTarget);
}
@Test
public void updateDoesNotChangeTargetListOfAffectedPedestrianIfProbabilityIsZero() {
int nextTarget = 2;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment