Skip to content

Commit a9355c0

Browse files
Update clients
1 parent 9f4d5bb commit a9355c0

File tree

4 files changed

+34
-24
lines changed

4 files changed

+34
-24
lines changed

Clients/main.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,27 @@ class GameState
7171
>> coolDownRate
7272
>> linearAttackRange >> rangedAttackRadius
7373
>> map.width >> map.height
74-
>> map.goldCount >> map.sightRange;
74+
>> map.goldCount
75+
>> map.sightRange; // equivalent to (2r+1)
7576
map.setGridSize();
7677
}
7778
void setInfo() {
78-
cin >> location.first >> location.second;
79+
cin >> location.first >> location.second; // (row, column)
7980
for (auto& tile : map.grid) {
8081
cin >> tile.type >> tile.data
8182
>> tile.coordinates.first
8283
>> tile.coordinates.second;
8384
}
84-
cin >> agentID >> currentRound >> attackRatio
85+
cin >> agentID // player1: 0,1 --- player2: 2,3
86+
>> currentRound // 1 indexed
87+
>> attackRatio
8588
>> deflvl >> atklvl
8689
>> wallet >> safeWallet;
8790
wallets = vector<int>(4);
88-
for (auto& w : wallets) {
91+
for (auto& w : wallets) { // current wallet
8992
cin >> w;
9093
}
94+
cin >> lastAction; // -1 if unsuccessful
9195
}
9296
Action getAction();
9397
int rounds;
@@ -102,6 +106,7 @@ class GameState
102106
int deflvl, atklvl;
103107
int wallet, safeWallet;
104108
vector<int> wallets;
109+
int lastAction;
105110
};
106111

107112
int main()

Clients/main.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace AICUP
66
public class Point
77
{
88
public Point() { }
9-
public int first { get; set; }
10-
public int second { get; set; }
9+
public int x { get; set; }
10+
public int y { get; set; }
1111
};
1212

1313
enum Action
@@ -76,37 +76,37 @@ public GameState()
7676
map.width = int.Parse(maptok[0]);
7777
map.height = int.Parse(maptok[1]);
7878
map.goldCount = Convert.ToInt32(Console.ReadLine());
79-
map.sightRange = Convert.ToInt32(Console.ReadLine());
79+
map.sightRange = Convert.ToInt32(Console.ReadLine()); // equivalent to (2r+1)
8080
map.setGridSize();
8181
}
8282

8383
public void setInfo()
8484
{
85-
var loctok = Console.ReadLine().Split();
86-
location.first = int.Parse(loctok[0]);
87-
location.second = int.Parse(loctok[1]);
85+
var loctok = Console.ReadLine().Split(); // (row, column)
86+
location.x = int.Parse(loctok[0]);
87+
location.y = int.Parse(loctok[1]);
8888
foreach (var item in map.grid)
8989
{
9090
var token = Console.ReadLine().Split();
9191
item.type = (MapType)int.Parse(token[0]);
9292
item.data = int.Parse(token[1]);
93-
item.coordinates.first = int.Parse(token[2]);
94-
item.coordinates.second = int.Parse(token[3]);
93+
item.coordinates.x = int.Parse(token[2]);
94+
item.coordinates.y = int.Parse(token[3]);
9595
}
96-
var inp= Console.ReadLine();
97-
agentID = Convert.ToInt32(inp);
98-
currentRound = Convert.ToInt32(Console.ReadLine());
96+
agentID = Convert.ToInt32(Console.ReadLine()); // player1: 0,1 --- player2: 2,3
97+
currentRound = Convert.ToInt32(Console.ReadLine()); // 1 indexed
9998
attackRatio = float.Parse(Console.ReadLine());
10099
deflvl = Convert.ToInt32(Console.ReadLine());
101100
atklvl = Convert.ToInt32(Console.ReadLine());
102101
wallet = Convert.ToInt32(Console.ReadLine());
103102
safeWallet = Convert.ToInt32(Console.ReadLine());
104-
wallets = new List<int>();
103+
wallets = new List<int>(); // current wallet
105104
var walletstok = Console.ReadLine().Split();
106105
for (int i = 0; i < 4; i++)
107106
{
108107
wallets.Add(int.Parse(walletstok[i]));
109108
}
109+
lastAction = Convert.ToInt32(Console.ReadLine()); // -1 if unsuccessful
110110
}
111111

112112
public Action getAction()
@@ -128,6 +128,7 @@ public Action getAction()
128128
public int deflvl, atklvl;
129129
public int wallet, safeWallet;
130130
List<int> wallets;
131+
public int lastAction;
131132
};
132133

133134
class Program

Clients/main.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public static class GameState {
7575
public int deflvl, atklvl;
7676
public int wallet, safeWallet;
7777
public Vector<Integer> wallets;
78+
public int lastAction;
7879

7980
public GameState() {
8081
map = new Map();
@@ -87,14 +88,14 @@ public GameState() {
8788
map.width = scanner.nextInt();
8889
map.height = scanner.nextInt();
8990
map.goldCount = scanner.nextInt();
90-
map.sightRange = scanner.nextInt();
91+
map.sightRange = scanner.nextInt(); // equivalent to (2r+1)
9192
map.grid = new Vector<>();
9293
}
9394

9495
public void setInfo() {
9596
int x = scanner.nextInt();
9697
int y = scanner.nextInt();
97-
location = new Point(x, y);
98+
location = new Point(x, y); // (row, column)
9899
for (int i = 0; i < map.sightRange * map.sightRange; i++) {
99100
MapTile tile = new MapTile();
100101
tile.type = MapType.values()[scanner.nextInt()];
@@ -104,17 +105,18 @@ public void setInfo() {
104105
tile.coordinates = new Point(x, y);
105106
map.grid.add(tile);
106107
}
107-
agentID = scanner.nextInt();
108-
currentRound = scanner.nextInt();
108+
agentID = scanner.nextInt(); // player1: 0,1 --- player2: 2,3
109+
currentRound = scanner.nextInt(); // 1 indexed
109110
attackRatio = scanner.nextFloat();
110111
deflvl = scanner.nextInt();
111112
atklvl = scanner.nextInt();
112113
wallet = scanner.nextInt();
113114
safeWallet = scanner.nextInt();
114-
wallets = new Vector<>();
115-
for(int i = 0;i < 4; i++) {
115+
wallets = new Vector<>(); // current wallet
116+
for(int i = 0; i < 4; i++) {
116117
wallets.add(scanner.nextInt());
117118
}
119+
lastAction = scanner.nextInt(); // -1 if unsuccessful
118120
scanner.nextLine();
119121
}
120122

Clients/main.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __init__(self) -> None:
6666
self.map = Map()
6767
self.map.width, self.map.height = map(int, input().split())
6868
self.map.gold_count = int(input())
69-
self.map.sight_range = int(input())
69+
self.map.sight_range = int(input()) # equivalent to (2r+1)
7070
self.map.set_grid_size()
7171
self.debug_log = ''
7272

@@ -81,7 +81,8 @@ def set_info(self) -> None:
8181
self.atklvl = int(input())
8282
self.wallet = int(input())
8383
self.safe_wallet = int(input())
84-
self.wallets = [*map(int, input().split())]
84+
self.wallets = [*map(int, input().split())] # current wallet
85+
self.last_action = int(input()) # -1 if unsuccessful
8586

8687
def debug(self) -> None:
8788
# Customize to your needs
@@ -93,6 +94,7 @@ def debug(self) -> None:
9394
self.debug_log += f'wallet: {str(self.wallet)}\n'
9495
self.debug_log += f'safe wallet: {str(self.safe_wallet)}\n'
9596
self.debug_log += f'list of wallets: {str(self.wallets)}\n'
97+
self.debug_log += f'last action: {str(self.last_action)}\n'
9698
self.debug_log += f'{60 * "-"}\n'
9799

98100
def debug_file(self) -> None:

0 commit comments

Comments
 (0)