@@ -22,62 +22,62 @@ public void decide() {
2222 System .out .println ("decide" );
2323
2424 if (this .mySide .equals ("Police" )) {
25- for (Police police : this .world .getPolices ())
26- {
27- if (police .getStatus () == EAgentStatus .Dead )
28- continue ;
29-
30- boolean doingBombOperation = police .getDefusionRemainingTime () != -1 ;
31- if (doingBombOperation )
32- {
33- System .out .println ("Agent[" + police .getId () + "]: " + "Continue Bomb Operation" );
34- continue ;
35- }
36-
37- ECommandDirection bombsiteDirection = findBombsiteDirection (police .getPosition ());
38- if (bombsiteDirection == null )
39- {
40- System .out .println ("Agent[" + police .getId () + "]: " + "Random Move" );
41- int randIndex = (int ) (Math .random () * ECommandDirection .values ().length );
42- ECommandDirection randDir = ECommandDirection .values ()[randIndex ];
43- move (police .getId (), randDir );
44- }
45- else
46- {
47- System .out .println ("Agent[" + police .getId () + "]: " + "Start Bomb Operation" );
48- defuse (police .getId (), bombsiteDirection );
49- }
50- }
51- }
52- else
53- {
54- for (Terrorist terrorist : this .world .getTerrorists ())
55- {
56- if (terrorist .getStatus () == EAgentStatus .Dead )
57- continue ;
58-
59- boolean doingBombOperation = terrorist .getPlantingRemainingTime () != -1 ;
60- if (doingBombOperation )
61- {
62- System .out .println ("Agent[" + terrorist .getId () + "]: " + "Continue Bomb Operation" );
63- continue ;
64- }
65-
66- ECommandDirection bombsiteDirection = findBombsiteDirection (terrorist .getPosition ());
67- if (bombsiteDirection == null )
68- {
69- System .out .println ("Agent[" + terrorist .getId () + "]: " + "Random Move" );
70- int randIndex = (int ) (Math .random () * ECommandDirection .values ().length );
71- ECommandDirection randDir = ECommandDirection .values ()[randIndex ];
72- move (terrorist .getId (), randDir );
73- }
74- else
75- {
76- System .out .println ("Agent[" + terrorist .getId () + "]: " + "Start Bomb Operation" );
77- plant (terrorist .getId (), bombsiteDirection );
78- }
79- }
80- }
25+ for (Police police : this .world .getPolices ())
26+ {
27+ if (police .getStatus () == EAgentStatus .Dead )
28+ continue ;
29+
30+ boolean doingBombOperation = police .getDefusionRemainingTime () != -1 ;
31+ if (doingBombOperation )
32+ {
33+ System .out .println ("Agent[" + police .getId () + "]: " + "Continue Bomb Operation" );
34+ continue ;
35+ }
36+
37+ ECommandDirection bombsiteDirection = findBombsiteDirection (police .getPosition ());
38+ if (bombsiteDirection == null )
39+ {
40+ System .out .println ("Agent[" + police .getId () + "]: " + "Random Move" );
41+ int randIndex = (int ) (Math .random () * ECommandDirection .values ().length );
42+ ECommandDirection randDir = ECommandDirection .values ()[randIndex ];
43+ move (police .getId (), randDir );
44+ }
45+ else
46+ {
47+ System .out .println ("Agent[" + police .getId () + "]: " + "Start Bomb Operation" );
48+ defuse (police .getId (), bombsiteDirection );
49+ }
50+ }
51+ }
52+ else
53+ {
54+ for (Terrorist terrorist : this .world .getTerrorists ())
55+ {
56+ if (terrorist .getStatus () == EAgentStatus .Dead )
57+ continue ;
58+
59+ boolean doingBombOperation = terrorist .getPlantingRemainingTime () != -1 ;
60+ if (doingBombOperation )
61+ {
62+ System .out .println ("Agent[" + terrorist .getId () + "]: " + "Continue Bomb Operation" );
63+ continue ;
64+ }
65+
66+ ECommandDirection bombsiteDirection = findBombsiteDirection (terrorist .getPosition ());
67+ if (bombsiteDirection == null )
68+ {
69+ System .out .println ("Agent[" + terrorist .getId () + "]: " + "Random Move" );
70+ int randIndex = (int ) (Math .random () * ECommandDirection .values ().length );
71+ ECommandDirection randDir = ECommandDirection .values ()[randIndex ];
72+ move (terrorist .getId (), randDir );
73+ }
74+ else
75+ {
76+ System .out .println ("Agent[" + terrorist .getId () + "]: " + "Start Bomb Operation" );
77+ plant (terrorist .getId (), bombsiteDirection );
78+ }
79+ }
80+ }
8181 }
8282
8383
@@ -99,22 +99,22 @@ public void defuse(int agentId, ECommandDirection bombsiteDirection)
9999
100100 private ECommandDirection findBombsiteDirection (Position position )
101101 {
102- if ((this .world .getBoard ().get (position .getY () - 1 ).get (position .getX ()).getValue () >= ECell .SmallBombSite .getValue ()) &&
103- (this .world .getBoard ().get (position .getY () - 1 ).get (position .getX ()).getValue () <= ECell .VastBombSite .getValue ()))
104- return ECommandDirection .Up ;
102+ if ((this .world .getBoard ().get (position .getY () - 1 ).get (position .getX ()).getValue () >= ECell .SmallBombSite .getValue ()) &&
103+ (this .world .getBoard ().get (position .getY () - 1 ).get (position .getX ()).getValue () <= ECell .VastBombSite .getValue ()))
104+ return ECommandDirection .Up ;
105105
106- if ((this .world .getBoard ().get (position .getY ()).get (position .getX () + 1 ).getValue () >= ECell .SmallBombSite .getValue ()) &&
107- (this .world .getBoard ().get (position .getY ()).get (position .getX () + 1 ).getValue () <= ECell .VastBombSite .getValue ()))
108- return ECommandDirection .Right ;
106+ if ((this .world .getBoard ().get (position .getY ()).get (position .getX () + 1 ).getValue () >= ECell .SmallBombSite .getValue ()) &&
107+ (this .world .getBoard ().get (position .getY ()).get (position .getX () + 1 ).getValue () <= ECell .VastBombSite .getValue ()))
108+ return ECommandDirection .Right ;
109109
110- if ((this .world .getBoard ().get (position .getY () + 1 ).get (position .getX ()).getValue () >= ECell .SmallBombSite .getValue ()) &&
111- (this .world .getBoard ().get (position .getY () + 1 ).get (position .getX ()).getValue () <= ECell .VastBombSite .getValue ()))
112- return ECommandDirection .Down ;
110+ if ((this .world .getBoard ().get (position .getY () + 1 ).get (position .getX ()).getValue () >= ECell .SmallBombSite .getValue ()) &&
111+ (this .world .getBoard ().get (position .getY () + 1 ).get (position .getX ()).getValue () <= ECell .VastBombSite .getValue ()))
112+ return ECommandDirection .Down ;
113113
114- if ((this .world .getBoard ().get (position .getY ()).get (position .getX () - 1 ).getValue () >= ECell .SmallBombSite .getValue ()) &&
115- (this .world .getBoard ().get (position .getY ()).get (position .getX () - 1 ).getValue () <= ECell .VastBombSite .getValue ()))
116- return ECommandDirection .Left ;
114+ if ((this .world .getBoard ().get (position .getY ()).get (position .getX () - 1 ).getValue () >= ECell .SmallBombSite .getValue ()) &&
115+ (this .world .getBoard ().get (position .getY ()).get (position .getX () - 1 ).getValue () <= ECell .VastBombSite .getValue ()))
116+ return ECommandDirection .Left ;
117117
118- return null ;
118+ return null ;
119119 }
120120}
0 commit comments