Skip to content

Commit

Permalink
Update clients
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmdrz-mirdamadi committed Sep 4, 2022
1 parent 9f4d5bb commit a9355c0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 deletions.
13 changes: 9 additions & 4 deletions Clients/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,27 @@ class GameState
>> coolDownRate
>> linearAttackRange >> rangedAttackRadius
>> map.width >> map.height
>> map.goldCount >> map.sightRange;
>> map.goldCount
>> map.sightRange; // equivalent to (2r+1)
map.setGridSize();
}
void setInfo() {
cin >> location.first >> location.second;
cin >> location.first >> location.second; // (row, column)
for (auto& tile : map.grid) {
cin >> tile.type >> tile.data
>> tile.coordinates.first
>> tile.coordinates.second;
}
cin >> agentID >> currentRound >> attackRatio
cin >> agentID // player1: 0,1 --- player2: 2,3
>> currentRound // 1 indexed
>> attackRatio
>> deflvl >> atklvl
>> wallet >> safeWallet;
wallets = vector<int>(4);
for (auto& w : wallets) {
for (auto& w : wallets) { // current wallet
cin >> w;
}
cin >> lastAction; // -1 if unsuccessful
}
Action getAction();
int rounds;
Expand All @@ -102,6 +106,7 @@ class GameState
int deflvl, atklvl;
int wallet, safeWallet;
vector<int> wallets;
int lastAction;
};

int main()
Expand Down
25 changes: 13 additions & 12 deletions Clients/main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace AICUP
public class Point
{
public Point() { }
public int first { get; set; }
public int second { get; set; }
public int x { get; set; }
public int y { get; set; }
};

enum Action
Expand Down Expand Up @@ -76,37 +76,37 @@ public GameState()
map.width = int.Parse(maptok[0]);
map.height = int.Parse(maptok[1]);
map.goldCount = Convert.ToInt32(Console.ReadLine());
map.sightRange = Convert.ToInt32(Console.ReadLine());
map.sightRange = Convert.ToInt32(Console.ReadLine()); // equivalent to (2r+1)
map.setGridSize();
}

public void setInfo()
{
var loctok = Console.ReadLine().Split();
location.first = int.Parse(loctok[0]);
location.second = int.Parse(loctok[1]);
var loctok = Console.ReadLine().Split(); // (row, column)
location.x = int.Parse(loctok[0]);
location.y = int.Parse(loctok[1]);
foreach (var item in map.grid)
{
var token = Console.ReadLine().Split();
item.type = (MapType)int.Parse(token[0]);
item.data = int.Parse(token[1]);
item.coordinates.first = int.Parse(token[2]);
item.coordinates.second = int.Parse(token[3]);
item.coordinates.x = int.Parse(token[2]);
item.coordinates.y = int.Parse(token[3]);
}
var inp= Console.ReadLine();
agentID = Convert.ToInt32(inp);
currentRound = Convert.ToInt32(Console.ReadLine());
agentID = Convert.ToInt32(Console.ReadLine()); // player1: 0,1 --- player2: 2,3
currentRound = Convert.ToInt32(Console.ReadLine()); // 1 indexed
attackRatio = float.Parse(Console.ReadLine());
deflvl = Convert.ToInt32(Console.ReadLine());
atklvl = Convert.ToInt32(Console.ReadLine());
wallet = Convert.ToInt32(Console.ReadLine());
safeWallet = Convert.ToInt32(Console.ReadLine());
wallets = new List<int>();
wallets = new List<int>(); // current wallet
var walletstok = Console.ReadLine().Split();
for (int i = 0; i < 4; i++)
{
wallets.Add(int.Parse(walletstok[i]));
}
lastAction = Convert.ToInt32(Console.ReadLine()); // -1 if unsuccessful
}

public Action getAction()
Expand All @@ -128,6 +128,7 @@ public Action getAction()
public int deflvl, atklvl;
public int wallet, safeWallet;
List<int> wallets;
public int lastAction;
};

class Program
Expand Down
14 changes: 8 additions & 6 deletions Clients/main.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public static class GameState {
public int deflvl, atklvl;
public int wallet, safeWallet;
public Vector<Integer> wallets;
public int lastAction;

public GameState() {
map = new Map();
Expand All @@ -87,14 +88,14 @@ public GameState() {
map.width = scanner.nextInt();
map.height = scanner.nextInt();
map.goldCount = scanner.nextInt();
map.sightRange = scanner.nextInt();
map.sightRange = scanner.nextInt(); // equivalent to (2r+1)
map.grid = new Vector<>();
}

public void setInfo() {
int x = scanner.nextInt();
int y = scanner.nextInt();
location = new Point(x, y);
location = new Point(x, y); // (row, column)
for (int i = 0; i < map.sightRange * map.sightRange; i++) {
MapTile tile = new MapTile();
tile.type = MapType.values()[scanner.nextInt()];
Expand All @@ -104,17 +105,18 @@ public void setInfo() {
tile.coordinates = new Point(x, y);
map.grid.add(tile);
}
agentID = scanner.nextInt();
currentRound = scanner.nextInt();
agentID = scanner.nextInt(); // player1: 0,1 --- player2: 2,3
currentRound = scanner.nextInt(); // 1 indexed
attackRatio = scanner.nextFloat();
deflvl = scanner.nextInt();
atklvl = scanner.nextInt();
wallet = scanner.nextInt();
safeWallet = scanner.nextInt();
wallets = new Vector<>();
for(int i = 0;i < 4; i++) {
wallets = new Vector<>(); // current wallet
for(int i = 0; i < 4; i++) {
wallets.add(scanner.nextInt());
}
lastAction = scanner.nextInt(); // -1 if unsuccessful
scanner.nextLine();
}

Expand Down
6 changes: 4 additions & 2 deletions Clients/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self) -> None:
self.map = Map()
self.map.width, self.map.height = map(int, input().split())
self.map.gold_count = int(input())
self.map.sight_range = int(input())
self.map.sight_range = int(input()) # equivalent to (2r+1)
self.map.set_grid_size()
self.debug_log = ''

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

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

def debug_file(self) -> None:
Expand Down

0 comments on commit a9355c0

Please sign in to comment.