1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package nl.tudelft.goal.ut3.environment;
18
19 import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
20 import eis.exceptions.PerceiveException;
21 import eis.iilang.Function;
22 import eis.iilang.Identifier;
23 import eis.iilang.Numeral;
24 import eis.iilang.Percept;
25 import nl.tudelft.goal.unreal.messages.UnrealIdOrLocation;
26 import static nl.tudelft.goal.ut3.environment.AbstractEnvironmentTests.startupPercepts;
27 import static nl.tudelft.goal.ut3.environment.AbstractEnvironmentTests.testBot;
28 import org.junit.Test;
29 import static org.junit.Assert.*;
30
31
32
33
34
35 public class MapPerceptTests extends AbstractEnvironmentTests {
36
37
38
39
40 @Test
41 public void navPointTest() {
42 boolean bFoundUdamage = false;
43 for (Percept p : startupPercepts) {
44 if (p.getName().equals("navPoint")) {
45 assertTrue(p.getParameters().size() == 3);
46 if (p.getParameters().get(0).equals(new Identifier("UTPickupFactory_UDamage_0"))) {
47 bFoundUdamage = true;
48
49
50 Function udamageLocation = new Function("location", new Numeral(0.72), new Numeral(1.17), new Numeral(172.0));
51 assertTrue(udamageLocation.equals(p.getParameters().get(1)));
52 }
53 }
54 }
55 assertTrue(bFoundUdamage);
56 }
57
58 @Test
59 public void pickupBioRifleTest() {
60 boolean bioRifleFound = false;
61
62 for (Percept p : startupPercepts) {
63 if (p.getName().equals("pickup") && p.getParameters().size() == 3) {
64 if (p.getParameters().get(2).equals(new Identifier("bio_rifle"))) {
65 bioRifleFound = true;
66 }
67 }
68 }
69 assertTrue(bioRifleFound);
70 }
71
72 @Test
73 public void pickupShockRifleTest() {
74 boolean shockRifleFound = false;
75
76 for (Percept p : startupPercepts) {
77 if (p.getName().equals("pickup") && p.getParameters().size() == 3) {
78 if (p.getParameters().get(2).equals(new Identifier("shock_rifle"))) {
79 shockRifleFound = true;
80 }
81 }
82 }
83 assertTrue(shockRifleFound);
84 }
85
86 @Test
87 public void pickupLinkGunTest() {
88 boolean linkGunFound = false;
89
90 for (Percept p : startupPercepts) {
91 if (p.getName().equals("pickup") && p.getParameters().size() == 3) {
92 if (p.getParameters().get(2).equals(new Identifier("link_gun"))) {
93 linkGunFound = true;
94 }
95 }
96 }
97 assertTrue(linkGunFound);
98 }
99
100 @Test
101 public void pickupStingerMinigunTest() {
102 boolean stingerFound = false;
103
104 for (Percept p : startupPercepts) {
105 if (p.getName().equals("pickup") && p.getParameters().size() == 3) {
106 if (p.getParameters().get(2).equals(new Identifier("stinger_minigun"))) {
107 stingerFound = true;
108 }
109 }
110 }
111 assertTrue(stingerFound);
112 }
113
114
115 @Test
116 public void pickupFlakCannonTest() {
117 boolean flakCannonFound = false;
118
119 for (Percept p : startupPercepts) {
120 if (p.getName().equals("pickup") && p.getParameters().size() == 3) {
121 if (p.getParameters().get(2).equals(new Identifier("flak_cannon"))) {
122 flakCannonFound = true;
123 }
124 }
125 }
126 assertTrue(flakCannonFound);
127 }
128
129 @Test
130 public void pickupRocketLauncherTest() {
131 boolean rocketLauncherFound = false;
132
133 for (Percept p : startupPercepts) {
134 if (p.getName().equals("pickup") && p.getParameters().size() == 3) {
135 if (p.getParameters().get(2).equals(new Identifier("rocket_launcher"))) {
136 rocketLauncherFound = true;
137 }
138 }
139 }
140 assertTrue(rocketLauncherFound);
141 }
142
143 @Test
144 public void pickupSniperRifleTest() {
145 boolean sniperRifleFound = false;
146
147 for (Percept p : startupPercepts) {
148 if (p.getName().equals("pickup") && p.getParameters().size() == 3) {
149 if (p.getParameters().get(2).equals(new Identifier("sniper_rifle"))) {
150 sniperRifleFound = true;
151 }
152 }
153 }
154 assertTrue(sniperRifleFound);
155 }
156
157 @Test
158 public void pickupRedeemerTest() {
159 boolean redeemerFound = false;
160
161 for (Percept p : startupPercepts) {
162 if (p.getName().equals("pickup") && p.getParameters().size() == 3) {
163 if (p.getParameters().get(2).equals(new Identifier("redeemer"))) {
164 redeemerFound = true;
165 }
166 }
167 }
168 assertTrue(redeemerFound);
169 }
170
171
172
173
174 @Test
175 public void pickupDeployablesTest() {
176 boolean slowVolumeFound = false;
177
178 for (Percept p : startupPercepts) {
179
180
181
182
183 if (p.getName().equals("pickup")) {
184 if (p.getParameters().size() == 3 && p.getParameters().get(2).equals(new Identifier("slow_volume"))) {
185 slowVolumeFound = true;
186 assertEquals(new Identifier("deployable"), p.getParameters().get(1));
187 }
188 }
189 }
190 assertTrue(slowVolumeFound);
191 }
192
193
194
195
196
197 @Test
198 public void flagBasePercept() {
199 for (Percept p : startupPercepts) {
200 if (p.getName().equals("base")) {
201 assertTrue(p.getParameters().size() == 2);
202 if (p.getParameters().get(0).equals(new Identifier("blue"))) {
203 assertEquals(new Identifier("UTCTFBlueFlagBase_0"), p.getParameters().get(1));
204 }
205 if (p.getParameters().get(0).equals(new Identifier("red"))) {
206 assertEquals(new Identifier("UTCTFRedFlagBase_0"), p.getParameters().get(1));
207 }
208 }
209 }
210 }
211 }