Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
2fb363ec
Commit
2fb363ec
authored
Jan 18, 2020
by
Benedikt Kleinmeier
Browse files
Implemented "SimpleCognitionModelTest"
parent
c962231f
Pipeline
#204409
passed with stages
in 119 minutes and 18 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereSimulator/tests/org/vadere/simulator/control/psychology/cognition/SimpleCognitionModelTest.java
0 → 100644
View file @
2fb363ec
package
org.vadere.simulator.control.psychology.cognition
;
import
org.junit.Test
;
import
org.vadere.state.attributes.scenario.AttributesAgent
;
import
org.vadere.state.psychology.cognition.SelfCategory
;
import
org.vadere.state.psychology.perception.types.*
;
import
org.vadere.state.scenario.Pedestrian
;
import
org.vadere.state.scenario.Topography
;
import
org.vadere.util.geometry.shapes.VPoint
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Random
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
public
class
SimpleCognitionModelTest
{
private
Topography
createTopography
()
{
return
new
Topography
();
}
private
List
<
Pedestrian
>
createPedestrians
(
int
totalPedestrians
)
{
List
<
Pedestrian
>
pedestrians
=
new
ArrayList
<>();
long
seed
=
0
;
Random
random
=
new
Random
(
seed
);
for
(
int
i
=
0
;
i
<
totalPedestrians
;
i
++)
{
AttributesAgent
attributesAgent
=
new
AttributesAgent
(
i
);
Pedestrian
pedestrian
=
new
Pedestrian
(
attributesAgent
,
random
);
pedestrian
.
setPosition
(
new
VPoint
(
i
,
i
));
pedestrians
.
add
(
pedestrian
);
}
return
pedestrians
;
}
private
void
testCognitionLayer
(
SelfCategory
defaultSelfCategory
,
SelfCategory
expectedSelfCategory
,
Stimulus
presentStimulus
)
{
List
<
Pedestrian
>
pedestrians
=
createPedestrians
(
2
);
for
(
Pedestrian
pedestrian
:
pedestrians
)
{
pedestrian
.
setMostImportantStimulus
(
presentStimulus
);
pedestrian
.
setSelfCategory
(
defaultSelfCategory
);
}
SimpleCognitionModel
simpleCognitionModel
=
new
SimpleCognitionModel
();
simpleCognitionModel
.
initialize
(
createTopography
());
simpleCognitionModel
.
update
(
pedestrians
);
for
(
Pedestrian
pedestrian
:
pedestrians
)
{
assertEquals
(
expectedSelfCategory
,
pedestrian
.
getSelfCategory
());
}
}
@Test
public
void
updatesSetsChangeTargetOnChangeTargetStimulus
()
{
testCognitionLayer
(
SelfCategory
.
TARGET_ORIENTED
,
SelfCategory
.
CHANGE_TARGET
,
new
ChangeTarget
());
}
@Test
public
void
updatesSetsInsideThreatOnThreatStimulus
()
{
testCognitionLayer
(
SelfCategory
.
TARGET_ORIENTED
,
SelfCategory
.
INSIDE_THREAT_AREA
,
new
Threat
());
}
@Test
public
void
updatesSetsWaitOnWaitStimulus
()
{
testCognitionLayer
(
SelfCategory
.
TARGET_ORIENTED
,
SelfCategory
.
WAIT
,
new
Wait
());
}
@Test
public
void
updatesSetsWaitOnWaitInAreaStimulus
()
{
testCognitionLayer
(
SelfCategory
.
TARGET_ORIENTED
,
SelfCategory
.
WAIT
,
new
WaitInArea
());
}
@Test
public
void
updatesSetsTargetOrientedOnElapsedTime
()
{
testCognitionLayer
(
SelfCategory
.
WAIT
,
SelfCategory
.
TARGET_ORIENTED
,
new
ElapsedTime
());
}
}
\ No newline at end of file
VadereSimulator/tests/org/vadere/simulator/control/psychology/perception/SimplePerceptionModelTest.java
View file @
2fb363ec
...
...
@@ -144,7 +144,7 @@ public class SimplePerceptionModelTest {
@Test
public
void
updateUsesClosestThreatForPedestrian
()
{
// Place threat at (0,0) and (5,0) with radi
i
5 and
// Place threat
s
at (0,0) and (5,0) with radi
us
5 and
// place pedestrians at (1,0) and (4,0) and check result.
Topography
topography
=
createTopography
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment