Skip to content

Commit 5d75775

Browse files
committed
Clean up
1 parent b149e0a commit 5d75775

File tree

7 files changed

+107
-106
lines changed

7 files changed

+107
-106
lines changed

CppClient/Game/gamecfg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"": "creating a new decision thread each time a snapshot of game is received from server",
1616
"create_new_thread": true,
1717
"agent_name": "0",
18-
"team_nickname": "BabyKnight",
18+
"team_nickname": "Team1",
1919
"token": "team_id1-xx"
2020
}
2121
}

JavaClient/gamecfg.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"general": {
3-
"command_files": [
4-
"ks/commands"
5-
],
63
"offline_mode": true
74
},
85

@@ -18,7 +15,7 @@
1815
"": "creating a new decision thread each time a snapshot of game is received from server",
1916
"create_new_thread": true,
2017
"agent_name": "0",
21-
"team_nickname": "BabyKnight",
18+
"team_nickname": "Team1",
2219
"token": "team_id1-xx"
2320
}
2421
}

JavaClient/src/ai/AI.java

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

PythonClient/gamecfg.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"general": {
3-
"command_files": [
4-
"ks/commands"
5-
],
6-
"offline_mode": true
3+
"command_files": [
4+
"ks/commands"
5+
],
6+
"offline_mode": true
77
},
88

99
"net": {
@@ -18,7 +18,7 @@
1818
"": "creating a new decision thread each time a snapshot of game is received from server",
1919
"create_new_thread": true,
2020
"agent_name": "0",
21-
"team_nickname": "BabyKnight",
21+
"team_nickname": "Team1",
2222
"token": "team_id1-xx"
2323
}
2424
}

PythonClient/gamecfg2.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"general": {
3-
"command_files": [
4-
"ks/commands"
5-
],
6-
"offline_mode": true
3+
"command_files": [
4+
"ks/commands"
5+
],
6+
"offline_mode": true
77
},
88

99
"net": {
@@ -18,7 +18,7 @@
1818
"": "creating a new decision thread each time a snapshot of game is received from server",
1919
"create_new_thread": true,
2020
"agent_name": "0",
21-
"team_nickname": "BabyKnight2",
22-
"token": "team_id1-xx"
21+
"team_nickname": "Team2",
22+
"token": "team_id2-xx"
2323
}
2424
}

PythonRandomClient/gamecfg.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"general": {
3-
"command_files": [
4-
"ks/commands"
5-
],
6-
"offline_mode": true
3+
"command_files": [
4+
"ks/commands"
5+
],
6+
"offline_mode": true
77
},
88

99
"net": {
@@ -19,6 +19,6 @@
1919
"create_new_thread": true,
2020
"agent_name": "0",
2121
"team_nickname": "RandomTeam",
22-
"token": "team_id1-xx"
22+
"token": "random_team-xx"
2323
}
2424
}

PythonServer/generate_ks.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,34 @@
99
from koala_serializer import generate
1010

1111

12-
commands_reletive_path = 'ks/commands.ks'
13-
models_reletive_path = 'ks/models.ks'
12+
ks_rel_dir = "app/ks"
13+
commands_ksfile = "commands.ks"
14+
models_ksfile = "models.ks"
15+
1416
destinations = [
15-
'../PythonClient',
16-
'../PythonRandomClient',
17-
'../CppClient/Game',
18-
'../JavaClient/src'
17+
"../PythonClient/ks",
18+
"../PythonRandomClient/ks",
19+
"../CppClient/Game/ks",
20+
"../JavaClient/src/ks",
21+
"../CSharpClient/Game/KS"
1922
]
2023

2124
for dest in destinations:
22-
for rel_path in [commands_reletive_path, models_reletive_path]:
23-
path = os.path.join(dest, rel_path)
25+
for ksfile in [commands_ksfile, models_ksfile]:
26+
path = os.path.join(dest, ksfile)
2427
if not os.path.exists(os.path.dirname(path)):
2528
os.mkdir(os.path.dirname(path))
26-
copyfile(os.path.join('app', rel_path), path)
29+
copyfile(os.path.join(ks_rel_dir, ksfile), path)
2730

2831
all_args = [
29-
('python', 'app/ks', 'snake_case'),
30-
('python', '../PythonClient/ks', 'snake_case'),
31-
('python', '../PythonRandomClient/ks', 'snake_case'),
32-
('cpp', '../CppClient/Game/ks', 'camelCase'),
33-
('java', '../JavaClient/src', 'camelCase')
32+
('python', ks_rel_dir, 'snake_case'),
33+
('python', "../PythonClient/ks", 'snake_case'),
34+
('python', "../PythonRandomClient/ks", 'snake_case'),
35+
('cpp', "../CppClient/Game/ks", 'camelCase'),
36+
('java', "../JavaClient/src", 'camelCase'),
37+
('cs', '../CSharpClient/Game/KS', 'PascalCase')
3438
]
3539

3640
for args in all_args:
37-
generate(os.path.join('app', commands_reletive_path), *args)
38-
generate(os.path.join('app', models_reletive_path), *args)
41+
generate(os.path.join(ks_rel_dir, commands_ksfile), *args)
42+
generate(os.path.join(ks_rel_dir, models_ksfile), *args)

0 commit comments

Comments
 (0)