1 package cz.cuni.amis.pogamut.ut2004.agent.module.sensor;
2
3 import java.util.HashMap;
4 import java.util.Map;
5 import java.util.logging.Logger;
6
7 import javax.vecmath.Vector3d;
8
9 import cz.cuni.amis.pogamut.base.agent.module.SensorModule;
10 import cz.cuni.amis.pogamut.base.communication.messages.InfoMessage;
11 import cz.cuni.amis.pogamut.base.communication.worldview.IWorldView;
12 import cz.cuni.amis.pogamut.base.communication.worldview.event.IWorldEventListener;
13 import cz.cuni.amis.pogamut.base.communication.worldview.object.IWorldObjectEvent;
14 import cz.cuni.amis.pogamut.base.communication.worldview.object.IWorldObjectEventListener;
15 import cz.cuni.amis.pogamut.base3d.worldview.object.Location;
16 import cz.cuni.amis.pogamut.base3d.worldview.object.Rotation;
17 import cz.cuni.amis.pogamut.ut2004.bot.IUT2004BotController;
18 import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
19 import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
20 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.AdrenalineGained;
21 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.BeginMessage;
22 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.BotDamaged;
23 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.BotKilled;
24 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Bumped;
25 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.FallEdge;
26 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.HearNoise;
27 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.HearPickup;
28 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.IncomingProjectile;
29 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ItemPickedUp;
30 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player;
31 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.PlayerDamaged;
32 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.PlayerKilled;
33 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.WallCollision;
34 import cz.cuni.amis.utils.NullCheck;
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 public class Senses extends SensorModule<UT2004Bot>
60 {
61
62
63
64
65 public static final double SENSE_THRESHOLD = 0.5;
66
67
68
69
70
71
72
73
74
75 public boolean isCollidingOnce()
76 {
77 if (!lastWallCollisionFlag) return false;
78
79 boolean col = agentInfo.getLocation().getDistance(lastWallCollision.getLocation()) < 100;
80 lastWallCollisionFlag = false;
81 return col;
82 }
83
84
85
86
87
88
89 public boolean isColliding()
90 {
91 if (lastWallCollision == null) return false;
92
93 return agentInfo.getTime() - lastWallCollisionTime < SENSE_THRESHOLD &&
94 agentInfo.getLocation().getDistance(lastWallCollision.getLocation()) < 100;
95 }
96
97
98
99
100
101 public Location getCollisionLocation() {
102 if (lastWallCollision == null) return null;
103 return lastWallCollision.getLocation();
104 }
105
106
107
108
109
110 public Vector3d getCollisionNormal() {
111 if (lastWallCollision == null) return null;
112 return lastWallCollision.getNormal();
113 }
114
115
116
117
118
119
120
121 public boolean isBumping ()
122 {
123 if (lastBumped == null) return false;
124 return agentInfo.getTime() - lastBumpedTime < SENSE_THRESHOLD && agentInfo.getLocation().getDistance(lastBumped.getLocation()) < 100;
125 }
126
127
128
129
130
131
132
133
134
135 public boolean isBumpingOnce() {
136 if (!lastBumpedFlag) return false;
137 boolean result = isBumping();
138 lastBumpedFlag = false;
139 return result;
140 }
141
142
143
144
145 public boolean isBumpingPlayer() {
146 if (!isBumping()) return false;
147 return players.getPlayer(lastBumped.getId()) != null;
148 }
149
150
151
152
153
154
155
156
157
158 public boolean isBumpingPlayerOnce() {
159 if (!lastBumpedFlag) return false;
160 boolean result = isBumpingPlayer();
161 lastBumpedFlag = false;
162 return result;
163 }
164
165
166
167
168
169 public Player getBumpingPlayer() {
170 if (lastBumped == null) return null;
171 return players.getPlayer(lastBumped.getId());
172 }
173
174
175
176
177
178 public Location getBumpLocation() {
179 if (lastBumped == null) return null;
180 return lastBumped.getLocation();
181 }
182
183
184
185
186
187
188
189 public boolean isFallEdge()
190 {
191 if (lastFallEdge == null) return false;
192
193 return agentInfo.getTime() - lastFallEdgeTime < SENSE_THRESHOLD && agentInfo.getLocation().getDistance(lastFallEdge.getLocation()) < 100;
194 }
195
196
197
198
199
200
201
202
203
204 public boolean isFallEdgeOnce()
205 {
206 if (!lastFallEdgeFlag) return false;
207 boolean result = isFallEdge();
208 lastFallEdgeFlag = false;
209 return result;
210 }
211
212
213
214
215
216
217
218 public boolean isHearingNoise()
219 {
220 if (lastHearNoise == null) return false;
221 return agentInfo.getTime() - lastHearNoiseTime < SENSE_THRESHOLD;
222 }
223
224
225
226
227
228
229
230
231
232 public boolean isHearingNoiseOnce() {
233 if (!lastHearNoiseFlag) return false;
234 boolean result = isHearingNoise();
235 lastHearNoiseFlag = false;
236 return result;
237 }
238
239
240
241
242
243 public Rotation getNoiseRotation() {
244 if (lastHearNoise == null) return null;
245 return lastHearNoise.getRotation();
246 }
247
248
249
250
251
252 public UnrealId getNoiseSource() {
253 if (lastHearNoise == null) return null;
254 return lastHearNoise.getSource();
255 }
256
257
258
259
260
261 public String getNoiseType() {
262
263 if (lastHearNoise == null) return null;
264 return lastHearNoise.getType();
265 }
266
267
268
269
270
271
272
273 public boolean isHearingPickup()
274 {
275 if (lastHearPickup == null) return false;
276 return agentInfo.getTime() - lastHearPickupTime < SENSE_THRESHOLD;
277 }
278
279
280
281
282
283
284
285
286
287 public boolean isHearingPickupOnce() {
288 if (!lastHearPickupFlag) return false;
289 boolean result = isHearingPickup();
290 lastHearPickupFlag = false;
291 return result;
292 }
293
294
295
296
297
298 public Rotation getPickupNoiseRotation() {
299 if (lastHearPickup == null) return null;
300 return lastHearPickup.getRotation();
301 }
302
303
304
305
306
307 public UnrealId getPickupNoiseSource() {
308 if (lastHearPickup == null) return null;
309 return lastHearPickup.getSource();
310 }
311
312
313
314
315
316 public String getPickupNoiseType() {
317
318 if (lastHearPickup == null) return null;
319 return lastHearPickup.getType();
320 }
321
322
323
324
325
326
327
328
329 public boolean isBeingDamaged ()
330 {
331 if (lastBotDamaged == null) return false;
332 return agentInfo.getTime() - lastBotDamagedTime < SENSE_THRESHOLD;
333 }
334
335
336
337
338
339
340
341
342
343 public boolean isBeingDamagedOnce ()
344 {
345 if (!isBeingDamaged()) return false;
346 if (!lastBotDamagedFlag) return false;
347 lastBotDamagedFlag = false;
348 return true;
349 }
350
351
352
353
354
355 public BotDamaged getLastDamage() {
356 return lastBotDamaged;
357 }
358
359
360
361
362
363
364
365
366 public boolean isShot() {
367 if (lastBotShot == null) return false;
368 return agentInfo.getTime() - lastBotShotTime < SENSE_THRESHOLD;
369 }
370
371
372
373
374
375
376
377
378
379 public boolean isShotOnce() {
380 if (!isShot()) return false;
381 if (!lastBotShotFlag) return false;
382 lastBotShotFlag = false;
383 return true;
384 }
385
386
387
388
389
390 public BotDamaged getLastShot() {
391 return lastBotShot;
392 }
393
394
395
396
397
398
399
400
401
402
403 public boolean seeIncomingProjectile ()
404 {
405 if (lastIncomingProjectile == null) return false;
406 return agentInfo.getTime() - lastIncomingProjectileTime < SENSE_THRESHOLD;
407 }
408
409
410
411
412
413 public boolean seeIncomingProjectileOnce() {
414 if (!seeIncomingProjectile()) return false;
415 if (!lastIncomingProjectileFlag) return false;
416 lastIncomingProjectileFlag = false;
417 return true;
418 }
419
420
421
422
423
424 public IncomingProjectile getLastIncomingProjectile() {
425 return lastIncomingProjectile;
426 }
427
428
429
430
431
432
433
434
435
436
437
438
439 public boolean isCausingDamage ()
440 {
441 if (lastPlayerDamaged == null) return false;
442 return agentInfo.getTime() - lastPlayerDamagedTime < SENSE_THRESHOLD;
443 }
444
445
446
447
448
449
450
451
452
453 public boolean isCausingDamageOnce ()
454 {
455 if (!isCausingDamage()) return false;
456 if (!lastPlayerDamagedFlag) return false;
457 lastPlayerDamagedFlag = false;
458 return true;
459 }
460
461
462
463
464
465 public PlayerDamaged getLastCausedDamage() {
466 return lastPlayerDamaged;
467 }
468
469
470
471
472
473
474
475
476 public boolean isHitPlayer() {
477 if (lastPlayerShot == null) return false;
478 return agentInfo.getTime() - lastPlayerShotTime < SENSE_THRESHOLD;
479 }
480
481
482
483
484
485
486
487
488
489 public boolean isHitPlayerOnce() {
490 if (!isHitPlayer()) return false;
491 if (!lastPlayerShotFlag) return false;
492 lastPlayerShotFlag = false;
493 return true;
494 }
495
496
497
498
499
500 public PlayerDamaged getLastHitPlayer() {
501 return lastPlayerShot;
502 }
503
504
505
506
507
508
509
510
511
512
513 public boolean isPlayerKilled() {
514 for (UnrealId id : playerKilled.keySet()) {
515 if (isPlayerKilled(id)) return true;
516 }
517 return false;
518 }
519
520
521
522
523
524
525
526
527
528 public boolean isPlayerKilledOnce() {
529 if (!playerKilledGlobalFlag) return false;
530 if (!isPlayerKilled()) return false;
531 playerKilledGlobalFlag = false;
532 return true;
533 }
534
535
536
537
538
539 public boolean isPlayerKilled(UnrealId playerId) {
540 return playerKilled.get(playerId) != null && agentInfo.getTime() - playerKilled.get(playerId).time < SENSE_THRESHOLD;
541 }
542
543
544
545
546
547 public boolean isPlayerKilled(Player player) {
548 return isPlayerKilled(player.getId());
549 }
550
551
552
553
554
555
556
557
558
559
560 public boolean isPlayerKilledOnce(UnrealId playerId) {
561 if (!isPlayerKilled(playerId)) return false;
562 if (playerKilled.get(playerId).queried) return false;
563 playerKilled.get(playerId).queried = true;
564 return true;
565 }
566
567
568
569
570
571
572
573
574
575
576 public boolean isPlayerKilledOnce(Player player) {
577 return isPlayerKilledOnce(player.getId());
578 }
579
580
581
582
583
584
585 public PlayerKilled getPlayerKilled(UnrealId playerId) {
586 if (playerKilled.get(playerId) == null) return null;
587 return playerKilled.get(playerId).event;
588 }
589
590
591
592
593
594
595 public PlayerKilled getPlayerKilled(Player player) {
596 return getPlayerKilled(player.getId());
597 }
598
599
600
601
602
603
604
605 public boolean isAdrenalineGained() {
606 return lastAdrenalineGained != null && agentInfo.getTime() - lastAdrenalineGainedTime < SENSE_THRESHOLD;
607 }
608
609
610
611
612
613
614
615
616
617 public boolean isAdrenalineGainedOnce() {
618 if (!lastAdrenalineGainedFlag) return false;
619 if (!isAdrenalineGained()) return false;
620 lastAdrenalineGainedFlag = false;
621 return true;
622 }
623
624
625
626
627
628
629
630 public boolean hasDied() {
631 return lastBotKilled != null && agentInfo.getTime() - lastBotKilledTime < SENSE_THRESHOLD;
632 }
633
634
635
636
637
638
639
640
641
642 public boolean hasDiedOnce() {
643 if (!lastBotKilledFlag) return false;
644 if (!hasDied()) return false;
645 lastBotKilledFlag = false;
646 return true;
647 }
648
649
650
651
652
653 public BotKilled getBotDeath() {
654 return lastBotKilled;
655 }
656
657
658
659
660
661
662
663 public boolean isItemPickedUp() {
664 return lastItemPickedUp != null && agentInfo.getTime() - lastItemPickedUpTime < SENSE_THRESHOLD;
665 }
666
667
668
669
670
671
672
673
674
675 public boolean isItemPickedUpOnce() {
676 if (!lastItemPickedUpFlag) return false;
677 if (!isItemPickedUp()) return false;
678 lastItemPickedUpFlag = false;
679 return true;
680 }
681
682
683
684
685
686 public ItemPickedUp getItemPickedUp() {
687 return lastItemPickedUp;
688 }
689
690
691
692
693
694 public Double getTimeDelta() {
695 if (previousBeginMessage == null) return null;
696 return lastBeginMessage.getTime() - previousBeginMessage.getTime();
697 }
698
699
700
701 Bumped lastBumped = null;
702 double lastBumpedTime = -1;
703 boolean lastBumpedFlag = false;
704
705 WallCollision lastWallCollision = null;
706 double lastWallCollisionTime = -1;
707 boolean lastWallCollisionFlag = false;
708
709 FallEdge lastFallEdge = null;
710 double lastFallEdgeTime = -1;
711 boolean lastFallEdgeFlag = false;
712
713 HearNoise lastHearNoise = null;
714 double lastHearNoiseTime = -1;
715 boolean lastHearNoiseFlag = false;
716
717 HearPickup lastHearPickup = null;
718 double lastHearPickupTime = -1;
719 boolean lastHearPickupFlag = false;
720
721 BotDamaged lastBotDamaged = null;
722 double lastBotDamagedTime = -1;
723 boolean lastBotDamagedFlag = false;
724
725 BotDamaged lastBotShot = null;
726 double lastBotShotTime = -1;
727 boolean lastBotShotFlag = false;
728
729 IncomingProjectile lastIncomingProjectile = null;
730 double lastIncomingProjectileTime = -1;
731 boolean lastIncomingProjectileFlag = false;
732
733 PlayerDamaged lastPlayerDamaged = null;
734 double lastPlayerDamagedTime = -1;
735 boolean lastPlayerDamagedFlag = false;
736
737 PlayerDamaged lastPlayerShot = null;
738 double lastPlayerShotTime = -1;
739 boolean lastPlayerShotFlag = false;
740
741 ItemPickedUp lastItemPickedUp = null;
742 double lastItemPickedUpTime = -1;
743 boolean lastItemPickedUpFlag = false;
744
745 private BeginMessage previousBeginMessage = null;
746 private BeginMessage lastBeginMessage = null;
747
748 private class Entry<EVENT extends InfoMessage> {
749
750 private EVENT event;
751 private boolean queried;
752 private double time;
753
754 public Entry(EVENT event) {
755 this.event = event;
756 this.queried = false;
757 this.time = agentInfo.getTime();
758 }
759
760 }
761
762 private Map<UnrealId, Entry<PlayerKilled>> playerKilled = new HashMap<UnrealId, Entry<PlayerKilled>>();
763 private boolean playerKilledGlobalFlag = false;
764
765 AdrenalineGained lastAdrenalineGained = null;
766 double lastAdrenalineGainedTime = -1;
767 boolean lastAdrenalineGainedFlag = false;
768
769 BotKilled lastBotKilled = null;
770 double lastBotKilledTime = -1;
771 boolean lastBotKilledFlag = false;
772
773
774
775
776
777
778
779 private class BumpedListener implements IWorldEventListener<Bumped>
780 {
781 @Override
782 public void notify(Bumped event)
783 {
784 lastBumped = event;
785 lastBumpedTime = agentInfo.getTime();
786 lastBumpedFlag = true;
787 }
788
789
790
791
792
793 public BumpedListener(IWorldView worldView)
794 {
795 worldView.addEventListener(Bumped.class, this);
796 }
797 }
798
799
800 BumpedListener bumpedListener;
801
802
803
804
805
806
807 private class WallCollisionListener implements IWorldEventListener<WallCollision>
808 {
809 @Override
810 public void notify(WallCollision event)
811 {
812 lastWallCollision = event;
813 lastWallCollisionTime = agentInfo.getTime();
814 lastWallCollisionFlag = true;
815 }
816
817
818
819
820
821 public WallCollisionListener(IWorldView worldView)
822 {
823 worldView.addEventListener(WallCollision.class, this);
824 }
825 }
826
827
828 WallCollisionListener wallCollisitonListener;
829
830
831
832
833
834
835 private class FallEdgeListener implements IWorldEventListener<FallEdge>
836 {
837 @Override
838 public void notify(FallEdge event)
839 {
840 lastFallEdge = event;
841 lastFallEdgeTime = agentInfo.getTime();
842 lastFallEdgeFlag = true;
843 }
844
845
846
847
848
849 public FallEdgeListener(IWorldView worldView)
850 {
851 worldView.addEventListener(FallEdge.class, this);
852 }
853 }
854
855
856 FallEdgeListener fallEdgeListener;
857
858
859
860
861
862
863 private class HearNoiseListener implements IWorldEventListener<HearNoise>
864 {
865 @Override
866 public void notify(HearNoise event)
867 {
868 lastHearNoise = event;
869 lastHearNoiseTime = agentInfo.getTime();
870 lastHearNoiseFlag = true;
871 }
872
873
874
875
876
877 public HearNoiseListener(IWorldView worldView)
878 {
879 worldView.addEventListener(HearNoise.class, this);
880 }
881 }
882
883
884 HearNoiseListener hearNoiseListener;
885
886
887
888
889
890
891 private class HearPickupListener implements IWorldEventListener<HearPickup>
892 {
893 @Override
894 public void notify(HearPickup event)
895 {
896 lastHearPickup = event;
897 lastHearPickupTime = agentInfo.getTime();
898 lastHearPickupFlag = true;
899 }
900
901
902
903
904
905 public HearPickupListener(IWorldView worldView)
906 {
907 worldView.addEventListener(HearPickup.class, this);
908 }
909 }
910
911
912 HearPickupListener hearPickupListener;
913
914
915
916
917
918
919 private class BotDamagedListener implements IWorldEventListener<BotDamaged>
920 {
921 @Override
922 public void notify(BotDamaged event)
923 {
924 lastBotDamaged = event;
925 lastBotDamagedTime = agentInfo.getTime();
926 lastBotDamagedFlag = true;
927
928 if (lastBotDamaged.isBulletHit()) {
929 lastBotShot = event;
930 lastBotShotTime = agentInfo.getTime();
931 lastBotShotFlag = true;
932 }
933 }
934
935
936
937
938
939 public BotDamagedListener(IWorldView worldView)
940 {
941 worldView.addEventListener(BotDamaged.class, this);
942 }
943 }
944
945
946 BotDamagedListener botDamagedListener;
947
948
949
950
951
952
953 private class IncomingProjectileListener implements IWorldObjectEventListener<IncomingProjectile, IWorldObjectEvent<IncomingProjectile>>
954 {
955 @Override
956 public void notify(IWorldObjectEvent<IncomingProjectile> event)
957 {
958 lastIncomingProjectile = event.getObject();
959 lastIncomingProjectileTime = agentInfo.getTime();
960 lastIncomingProjectileFlag = true;
961 }
962
963
964
965
966
967 public IncomingProjectileListener(IWorldView worldView)
968 {
969 worldView.addEventListener(IncomingProjectile.class, this);
970 }
971 }
972
973
974 IncomingProjectileListener incomingProjectileListener;
975
976
977
978
979
980
981 private class PlayerDamagedListener implements IWorldEventListener<PlayerDamaged>
982 {
983 @Override
984 public void notify(PlayerDamaged event)
985 {
986 lastPlayerDamaged = event;
987 lastPlayerDamagedTime = agentInfo.getTime();
988 lastPlayerDamagedFlag = true;
989
990 if (lastPlayerDamaged.isBulletHit()) {
991 lastPlayerShot = event;
992 lastPlayerShotTime = agentInfo.getTime();
993 lastPlayerShotFlag = true;
994 }
995 }
996
997
998
999
1000
1001 public PlayerDamagedListener(IWorldView worldView)
1002 {
1003 worldView.addEventListener(PlayerDamaged.class, this);
1004 }
1005 }
1006
1007
1008 PlayerDamagedListener playerDamagedListener;
1009
1010
1011
1012
1013
1014
1015 private class PlayerKilledListener implements IWorldEventListener<PlayerKilled>
1016 {
1017 @Override
1018 public void notify(PlayerKilled event)
1019 {
1020 if (event.getId() == null) return;
1021 playerKilled.put(event.getId(), new Entry<PlayerKilled>(event));
1022 playerKilledGlobalFlag = true;
1023 }
1024
1025
1026
1027
1028
1029 public PlayerKilledListener(IWorldView worldView)
1030 {
1031 worldView.addEventListener(PlayerKilled.class, this);
1032 }
1033 }
1034
1035
1036 PlayerKilledListener playerKilledListener;
1037
1038
1039
1040
1041
1042
1043 private class AdrenalineGainedListener implements IWorldEventListener<AdrenalineGained>
1044 {
1045 @Override
1046 public void notify(AdrenalineGained event)
1047 {
1048 lastAdrenalineGained = event;
1049 lastAdrenalineGainedFlag = true;
1050 lastAdrenalineGainedTime = agentInfo.getTime();
1051 }
1052
1053
1054
1055
1056
1057 public AdrenalineGainedListener(IWorldView worldView)
1058 {
1059 worldView.addEventListener(AdrenalineGained.class, this);
1060 }
1061 }
1062
1063
1064 AdrenalineGainedListener adrenalineGainedListener;
1065
1066
1067
1068
1069
1070
1071 private class BotKilledListener implements IWorldEventListener<BotKilled>
1072 {
1073 @Override
1074 public void notify(BotKilled event)
1075 {
1076 lastBotKilled = event;
1077 lastBotKilledFlag = true;
1078 lastBotKilledTime = agentInfo.getTime();
1079 }
1080
1081
1082
1083
1084
1085 public BotKilledListener(IWorldView worldView)
1086 {
1087 worldView.addEventListener(BotKilled.class, this);
1088 }
1089 }
1090
1091
1092 BotKilledListener botKilledListener;
1093
1094
1095
1096
1097
1098
1099 private class BeginMessageListener implements IWorldEventListener<BeginMessage>
1100 {
1101 @Override
1102 public void notify(BeginMessage event)
1103 {
1104 previousBeginMessage = lastBeginMessage;
1105 lastBeginMessage = event;
1106 }
1107
1108
1109
1110
1111
1112 public BeginMessageListener(IWorldView worldView)
1113 {
1114 worldView.addEventListener(BeginMessage.class, this);
1115 }
1116 }
1117
1118
1119 BeginMessageListener beginMessageListener;
1120
1121
1122
1123
1124
1125
1126
1127 private class ItemPickedUpListener implements IWorldEventListener<ItemPickedUp>
1128 {
1129 @Override
1130 public void notify(ItemPickedUp event)
1131 {
1132 lastItemPickedUp = event;
1133 lastItemPickedUpFlag = true;
1134 lastItemPickedUpTime = agentInfo.getTime();
1135 }
1136
1137
1138
1139
1140
1141 public ItemPickedUpListener(IWorldView worldView)
1142 {
1143 worldView.addEventListener(ItemPickedUp.class, this);
1144 }
1145 }
1146
1147
1148 ItemPickedUpListener itemPickedUpListener;
1149
1150
1151
1152
1153 protected AgentInfo agentInfo;
1154
1155 private Players players;
1156
1157
1158
1159
1160
1161 public Senses(UT2004Bot bot)
1162 {
1163 this(bot, new AgentInfo(bot), new Players(bot), null);
1164 }
1165
1166
1167
1168
1169
1170
1171
1172 public Senses(UT2004Bot bot, AgentInfo agentInfo, Players players)
1173 {
1174 this(bot, agentInfo, players, null);
1175 }
1176
1177
1178
1179
1180
1181
1182
1183 public Senses(UT2004Bot bot, AgentInfo agentInfo, Players players, Logger log)
1184 {
1185 super(bot, log);
1186
1187
1188 this.agentInfo = agentInfo;
1189 NullCheck.check(this.agentInfo, "agentInfo");
1190
1191
1192 this.players = players;
1193 NullCheck.check(this.players, "players");
1194
1195
1196 bumpedListener = new BumpedListener(worldView);
1197 wallCollisitonListener = new WallCollisionListener(worldView);
1198 fallEdgeListener = new FallEdgeListener(worldView);
1199 hearNoiseListener = new HearNoiseListener(worldView);
1200 hearPickupListener = new HearPickupListener(worldView);
1201 botDamagedListener = new BotDamagedListener(worldView);
1202 incomingProjectileListener = new IncomingProjectileListener(worldView);
1203 playerDamagedListener = new PlayerDamagedListener(worldView);
1204 playerKilledListener = new PlayerKilledListener(worldView);
1205 adrenalineGainedListener = new AdrenalineGainedListener(worldView);
1206 botKilledListener = new BotKilledListener(worldView);
1207 itemPickedUpListener = new ItemPickedUpListener(worldView);
1208 beginMessageListener = new BeginMessageListener(worldView);
1209
1210 cleanUp();
1211 }
1212
1213 @Override
1214 protected void cleanUp() {
1215 super.cleanUp();
1216 lastAdrenalineGained = null;
1217 lastAdrenalineGainedFlag = false;
1218 lastAdrenalineGainedTime = -1;
1219 lastBotDamaged = null;
1220 lastBotDamagedFlag = false;
1221 lastBotDamagedTime = -1;
1222 lastBotKilled = null;
1223 lastBotKilledFlag = false;
1224 lastBotKilledTime = -1;
1225 lastBotShot = null;
1226 lastBotShotFlag = false;
1227 lastBotShotTime = -1;
1228 lastBumped = null;
1229 lastBumpedFlag = false;
1230 lastBumpedTime = -1;
1231 lastFallEdge = null;
1232 lastFallEdgeFlag = false;
1233 lastFallEdgeTime = -1;
1234 lastHearNoise = null;
1235 lastHearNoiseFlag = false;
1236 lastHearNoiseTime = -1;
1237 lastHearPickup = null;
1238 lastHearPickupFlag = false;
1239 lastHearPickupTime = -1;
1240 lastIncomingProjectile = null;
1241 lastIncomingProjectileFlag = false;
1242 lastIncomingProjectileTime = -1;
1243 lastPlayerDamaged = null;
1244 lastPlayerDamagedFlag = false;
1245 lastPlayerDamagedTime = -1;
1246 lastPlayerShot = null;
1247 lastPlayerShotFlag = false;
1248 lastPlayerShotTime = -1;
1249 lastWallCollision = null;
1250 lastWallCollisionFlag = false;
1251 lastWallCollisionTime = -1;
1252 }
1253
1254 }