Commit 92a60ae9 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

Renamed variables "closestPedestrian" to "neighbor"

parent 0262836d
Pipeline #275067 passed with stages
in 213 minutes and 12 seconds
......@@ -30,12 +30,12 @@ public class CounterflowCognitionModel implements ICognitionModel {
pedestrian.setSelfCategory(SelfCategory.TARGET_ORIENTED);
if (pedestrian.hasNextTarget()) {
Pedestrian closestPedestrian = TopographyHelper.getNeighborCloserToTargetCentroid(pedestrian, topography);
Pedestrian neighborCloserToTarget = TopographyHelper.getNeighborCloserToTargetCentroid(pedestrian, topography);
if (closestPedestrian != null) {
if (TopographyHelper.walkingDirectionDiffers(pedestrian, closestPedestrian, topography)) {
if (neighborCloserToTarget != null) {
if (TopographyHelper.walkingDirectionDiffers(pedestrian, neighborCloserToTarget, topography)) {
pedestrian.setSelfCategory(SelfCategory.EVADE);
} else if (closestPedestrian.getSelfCategory() == SelfCategory.EVADE) {
} else if (neighborCloserToTarget.getSelfCategory() == SelfCategory.EVADE) {
pedestrian.setSelfCategory(SelfCategory.EVADE); // Imitate behavior
}
}
......
......@@ -88,7 +88,7 @@ public class ThreatCognitionModel implements ICognitionModel {
if (pedestrian.getGroupMembership() == GroupMembership.OUT_GROUP) {
pedestrian.setSelfCategory(SelfCategory.TARGET_ORIENTED);
} else if (pedestrian.getGroupMembership() == GroupMembership.IN_GROUP) {
imitateThreatenedPedestrianIfPresent(pedestrian);
imitateThreatenedNeighborIfPresent(pedestrian);
} else {
throw new IllegalArgumentException("Can only process \"IN_GROUP\" and \"OUT_GROUP\" group membership!");
}
......@@ -124,15 +124,15 @@ public class ThreatCognitionModel implements ICognitionModel {
*
* This behavior is triggered by method {@link #handleThreat(Pedestrian, Stimulus)}.
*/
private void imitateThreatenedPedestrianIfPresent(Pedestrian pedestrian) {
List<Pedestrian> threatenedPedestrians = TopographyHelper.getNeighborsWithSelfCategory(pedestrian, SelfCategory.OUTSIDE_THREAT_AREA, topography);
List<Pedestrian> threatenedIngroupPeds = threatenedPedestrians.stream()
private void imitateThreatenedNeighborIfPresent(Pedestrian pedestrian) {
List<Pedestrian> threatenedNeighbors = TopographyHelper.getNeighborsWithSelfCategory(pedestrian, SelfCategory.OUTSIDE_THREAT_AREA, topography);
List<Pedestrian> threatenedIngroupNeighbors = threatenedNeighbors.stream()
.filter(ped -> ped.getGroupMembership() == GroupMembership.IN_GROUP)
.collect(Collectors.toList());
if (threatenedIngroupPeds.isEmpty() == false) {
Pedestrian threatenedPedestrian = threatenedIngroupPeds.get(0);
Threat latestThreat = threatenedPedestrian.getThreatMemory().getLatestThreat();
if (threatenedIngroupNeighbors.isEmpty() == false) {
Pedestrian threatenedNeighbor = threatenedIngroupNeighbors.get(0);
Threat latestThreat = threatenedNeighbor.getThreatMemory().getLatestThreat();
assert latestThreat != null;
......
......@@ -332,19 +332,19 @@ public class OSMBehaviorController {
return null;
}
List<Pedestrian> closestPedestrians = TopographyHelper.getNeighborsCloserToTarget(pedestrian, topography);
List<Pedestrian> neighborsCloserToTarget = TopographyHelper.getNeighborsCloserToTarget(pedestrian, topography);
if (closestPedestrians.size() > 0) {
for (Pedestrian closestPedestrian : closestPedestrians) {
if (closestPedestrian.hasNextTarget()) {
boolean closestPedIsCooperative = closestPedestrian.getSelfCategory() == SelfCategory.COOPERATIVE;
boolean walkingDirectionDiffers = TopographyHelper.walkingDirectionDiffers(pedestrian, closestPedestrian, topography);
if (neighborsCloserToTarget.size() > 0) {
for (Pedestrian neighbor : neighborsCloserToTarget) {
if (neighbor.hasNextTarget()) {
boolean neighborIsCooperative = neighbor.getSelfCategory() == SelfCategory.COOPERATIVE;
boolean walkingDirectionDiffers = TopographyHelper.walkingDirectionDiffers(pedestrian, neighbor, topography);
if (closestPedIsCooperative && walkingDirectionDiffers) {
return (PedestrianOSM)closestPedestrian;
if (neighborIsCooperative && walkingDirectionDiffers) {
return (PedestrianOSM)neighbor;
}
} else {
return (PedestrianOSM)closestPedestrian;
return (PedestrianOSM)neighbor;
}
}
}
......
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