Commit 480f51d7 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

In enum "SelfCategory", renamed "INSIDE_THREAT_AREA" to "THREATENED" and...

In enum "SelfCategory", renamed "INSIDE_THREAT_AREA" to "THREATENED" and "OUTSIDE_THREAT_AREA" to "COMMON_FATE"

This renaming better honors the self-categorization theory and its term "identities" (even my implementation uses the term category).
parent 46cfef2a
Pipeline #418897 passed with stages
in 127 minutes and 49 seconds
......@@ -29,7 +29,7 @@ import java.util.Collection;
* methods in this class because, usually, first a stimulus is processed and
* then pedestrians decide which behavior to follow. E.g., first a {@link Threat}
* is recognized and then a pedestrian decides to follow a
* {@link SelfCategory#INSIDE_THREAT_AREA} behavior.
* {@link SelfCategory#THREATENED} behavior.
*/
public interface ICognitionModel {
......
......@@ -30,7 +30,7 @@ public class SimpleCognitionModel implements ICognitionModel {
if (stimulus instanceof ChangeTarget) {
nextSelfCategory = SelfCategory.CHANGE_TARGET;
} else if (stimulus instanceof Threat) {
nextSelfCategory = SelfCategory.INSIDE_THREAT_AREA;
nextSelfCategory = SelfCategory.THREATENED;
} else if (stimulus instanceof Wait || stimulus instanceof WaitInArea) {
nextSelfCategory = SelfCategory.WAIT;
} else if (stimulus instanceof ElapsedTime) {
......
......@@ -55,12 +55,12 @@ public class ThreatCognitionModel implements ICognitionModel {
// Current stimulus is a threat => store it and make clear that pedestrian is inside threat area.
pedestrian.getThreatMemory().add((Threat) stimulus);
pedestrian.setSelfCategory(SelfCategory.INSIDE_THREAT_AREA);
pedestrian.setSelfCategory(SelfCategory.THREATENED);
// Gerta suggests to apply SelfCategory.OUTSIDE_THREAT_AREA
// Gerta suggests to apply SelfCategory.COMMON_FATE
// so that agents directly search a safe zone if they are blocked by a wall.
if (TopographyHelper.pedestrianIsBlockedByObstacle(pedestrian, topography)) {
pedestrian.setSelfCategory(SelfCategory.OUTSIDE_THREAT_AREA);
pedestrian.setSelfCategory(SelfCategory.COMMON_FATE);
}
}
......@@ -102,12 +102,12 @@ public class ThreatCognitionModel implements ICognitionModel {
boolean pedestrianIsInsideThreatArea = (distanceToThreat <= latestThreat.getRadius());
boolean pedestrianIsBlockedByObstacle = TopographyHelper.pedestrianIsBlockedByObstacle(pedestrian, topography);
// Gerta suggests to apply SelfCategory.OUTSIDE_THREAT_AREA
// Gerta suggests to apply SelfCategory.COMMON_FATE
// so that agents directly search a safe zone if they are blocked by a wall.
if (pedestrianIsInsideThreatArea && pedestrianIsBlockedByObstacle == false) {
pedestrian.setSelfCategory(SelfCategory.INSIDE_THREAT_AREA);
pedestrian.setSelfCategory(SelfCategory.THREATENED);
} else {
pedestrian.setSelfCategory(SelfCategory.OUTSIDE_THREAT_AREA);
pedestrian.setSelfCategory(SelfCategory.COMMON_FATE);
}
}
......@@ -125,7 +125,7 @@ public class ThreatCognitionModel implements ICognitionModel {
* This behavior is triggered by method {@link #handleThreat(Pedestrian, Stimulus)}.
*/
private void imitateThreatenedNeighborIfPresent(Pedestrian pedestrian) {
List<Pedestrian> threatenedNeighbors = TopographyHelper.getNeighborsWithSelfCategory(pedestrian, SelfCategory.OUTSIDE_THREAT_AREA, topography);
List<Pedestrian> threatenedNeighbors = TopographyHelper.getNeighborsWithSelfCategory(pedestrian, SelfCategory.COMMON_FATE, topography);
List<Pedestrian> threatenedIngroupNeighbors = threatenedNeighbors.stream()
.filter(ped -> ped.getGroupMembership() == GroupMembership.IN_GROUP)
.collect(Collectors.toList());
......
......@@ -62,10 +62,10 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM {
} else {
osmBehaviorController.makeStepToTarget(pedestrian, topography);
}
} else if (selfCategory == SelfCategory.INSIDE_THREAT_AREA) {
} else if (selfCategory == SelfCategory.THREATENED) {
osmBehaviorController.changeToTargetRepulsionStrategyAndIncreaseSpeed(pedestrian, topography);
osmBehaviorController.makeStepToTarget(pedestrian, topography);
} else if (selfCategory == SelfCategory.OUTSIDE_THREAT_AREA) {
} else if (selfCategory == SelfCategory.COMMON_FATE) {
osmBehaviorController.changeTargetToSafeZone(pedestrian, topography);
osmBehaviorController.makeStepToTarget(pedestrian, topography);
} else if (selfCategory == SelfCategory.WAIT) {
......
......@@ -58,10 +58,10 @@ public class UpdateSchemeSequential implements UpdateSchemeOSM {
} else {
stepForward(pedestrian, currentTimeInSec, timeStepInSec);
}
} else if (selfCategory == SelfCategory.INSIDE_THREAT_AREA) {
} else if (selfCategory == SelfCategory.THREATENED) {
osmBehaviorController.changeToTargetRepulsionStrategyAndIncreaseSpeed(pedestrian, topography);
stepForward(pedestrian, currentTimeInSec, timeStepInSec);
} else if (selfCategory == SelfCategory.OUTSIDE_THREAT_AREA) {
} else if (selfCategory == SelfCategory.COMMON_FATE) {
osmBehaviorController.changeTargetToSafeZone(pedestrian, topography);
stepForward(pedestrian, currentTimeInSec, timeStepInSec);
} else if (selfCategory == SelfCategory.WAIT) {
......
......@@ -67,12 +67,12 @@ public class UpdateSchemeEventDriven implements DynamicElementAddListener, Dynam
} else {
osmBehaviorController.makeStepToTarget(pedestrian, topography);
}
} else if (selfCategory == SelfCategory.INSIDE_THREAT_AREA) {
} else if (selfCategory == SelfCategory.THREATENED) {
osmBehaviorController.changeToTargetRepulsionStrategyAndIncreaseSpeed(pedestrian, topography);
osmBehaviorController.makeStepToTarget(pedestrian, topography);
} else if (selfCategory == SelfCategory.OUTSIDE_THREAT_AREA) {
} else if (selfCategory == SelfCategory.COMMON_FATE) {
// TODO: Check if "changeToTargetRepulsionStrategyAndIncreaseSpeed()" is really necessary here.
// It is necessary here if pedestrian was "INSIDE_THREAT_AREA" before but locomotion layer
// It is necessary here if pedestrian was "THREATENED" before but locomotion layer
// had no time to call this method.
osmBehaviorController.changeToTargetRepulsionStrategyAndIncreaseSpeed(pedestrian, topography);
osmBehaviorController.changeTargetToSafeZone(pedestrian, topography);
......
......@@ -64,9 +64,9 @@ public class SimpleCognitionModelTest {
}
@Test
public void updatesSetsInsideThreatOnThreatStimulus() {
public void updatesSetsThreatenedOnThreatStimulus() {
testCognitionLayer(SelfCategory.TARGET_ORIENTED,
SelfCategory.INSIDE_THREAT_AREA,
SelfCategory.THREATENED,
new Threat());
}
......
......@@ -88,7 +88,7 @@ public class ThreatCognitionModelTest {
}
@Test
public void updateSetsInsideThreatAreaIfThreatStimulusAndPedIsNotBlockedByObstacles() {
public void updateSetsThreatenedIfThreatStimulusAndPedIsNotBlockedByObstacles() {
initializeTopography();
ThreatCognitionModel modelUnderTest = new ThreatCognitionModel();
......@@ -100,7 +100,7 @@ public class ThreatCognitionModelTest {
modelUnderTest.update(pedestrians);
assertEquals(SelfCategory.INSIDE_THREAT_AREA, pedestrian.getSelfCategory());
assertEquals(SelfCategory.THREATENED, pedestrian.getSelfCategory());
}
@Test
......@@ -180,11 +180,11 @@ public class ThreatCognitionModelTest {
modelUnderTest.update(pedestrians);
assertEquals(SelfCategory.OUTSIDE_THREAT_AREA, pedestrian.getSelfCategory());
assertEquals(SelfCategory.COMMON_FATE, pedestrian.getSelfCategory());
}
@Test
public void updateSetsInsideOrOutsideThreatAreaUponElapsedTimeStimulusIfPedestrianWasThreatenedBefore() {
public void updateSetsThreatenedOrCommonFateUponElapsedTimeStimulusIfPedestrianWasThreatenedBefore() {
initializeTopography();
AttributesTarget attributesTarget = new AttributesTarget();
......@@ -215,7 +215,7 @@ public class ThreatCognitionModelTest {
modelUnderTest.update(pedestrians);
SelfCategory expectedSelfCategory = (i <= threatRadius) ? SelfCategory.INSIDE_THREAT_AREA : SelfCategory.OUTSIDE_THREAT_AREA ;
SelfCategory expectedSelfCategory = (i <= threatRadius) ? SelfCategory.THREATENED : SelfCategory.COMMON_FATE;
assertEquals(expectedSelfCategory, pedestrian.getSelfCategory());
}
}
......@@ -259,7 +259,7 @@ public class ThreatCognitionModelTest {
Pedestrian threatenedNeighbor = new Pedestrian(attributesAgent, new Random());
threatenedNeighbor.setMostImportantStimulus(threatStimulus);
threatenedNeighbor.getThreatMemory().add(threatStimulus);
threatenedNeighbor.setSelfCategory(SelfCategory.OUTSIDE_THREAT_AREA);
threatenedNeighbor.setSelfCategory(SelfCategory.COMMON_FATE);
threatenedNeighbor.setPosition(new VPoint(threatRadius, threatRadius));
threatenedNeighbor.setGroupMembership(GroupMembership.IN_GROUP);
......@@ -277,7 +277,7 @@ public class ThreatCognitionModelTest {
modelUnderTest.update(pedestrians);
assertEquals(SelfCategory.INSIDE_THREAT_AREA, pedestrian.getSelfCategory());
assertEquals(SelfCategory.THREATENED, pedestrian.getSelfCategory());
}
}
\ No newline at end of file
......@@ -6,18 +6,27 @@ package org.vadere.state.psychology.cognition;
* categories, e.g., father, football fan, colleague. At a specific point in
* time, only one category is salient.
*
* Our agents use these categorizations to derive a specific behavior.
* E.g., if an agents is "COOPERATIVE" (category), the pedestrian swaps places
* (behavior) with other "COOPERATIVE" pedestrians (only if both feel committed
* to this category as in-group member, see {@łink GroupMembership}.
*
* Our agents use these categorizations to derive a specific behavior:
* <ul>
* <li>
* TARGET_ORIENTED agents try to reach the target as quickly as possible.
* </li>
* <li>
* E.g., if an agents is "COOPERATIVE" (category), the pedestrian swaps places
* (behavior) with other "COOPERATIVE" pedestrians (only if both feel committed
* to this category as in-group member, see {@łink GroupMembership}.
* </li>
* <li>
* THREATENED agents maximize the distance to a threat.
* </li>
* </ul>
* Usually, the self category of an agent changes during a simulation.
*/
public enum SelfCategory {
TARGET_ORIENTED,
COOPERATIVE,
INSIDE_THREAT_AREA,
OUTSIDE_THREAT_AREA,
THREATENED,
COMMON_FATE,
WAIT,
CHANGE_TARGET,
EVADE
......
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