Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.94 KB | None | 0 0
  1. package ctf.agent;
  2.  
  3. import static java.lang.System.out;
  4.  
  5. import ctf.common.AgentAction;
  6. import ctf.common.AgentEnvironment;
  7. import java.awt.Point;
  8. import java.util.ArrayList;
  9. import java.util.LinkedList;
  10. import java.util.Random;
  11. import java.util.Collections;
  12.  
  13. public class srs140430Agent extends Agent {
  14. Random rand = new Random();
  15. final int unvisited = 0;
  16. final int empty = 1;
  17. final int obstacle = 2;
  18. final int mybase = 3;
  19. final int theirbase = 4;
  20. final int bfsvisited = 5;
  21. final int mine = 6;
  22.  
  23. class Board {
  24. int size;
  25. int[][] b;
  26.  
  27. Point mybasepoint;
  28. Point theirbasepoint;
  29.  
  30. Board(int size, boolean left) {
  31. this.size = size;
  32. b = new int[size][size];
  33.  
  34. for (int i = 0; i < size; i++) {
  35. b[0][i] = empty;
  36. b[size - 1][i] = empty;
  37. }
  38.  
  39. if (left) {
  40. b[0][(size - 1) / 2] = mybase;
  41. mybasepoint = new Point(0, (size - 1) / 2);
  42. b[size - 1][(size - 1) / 2] = theirbase;
  43. theirbasepoint = new Point(size - 1, (size - 1) / 2);
  44. } else {
  45. b[size - 1][(size - 1) / 2] = mybase;
  46. mybasepoint = new Point(size - 1, (size - 1) / 2);
  47. b[0][(size - 1) / 2] = theirbase;
  48. theirbasepoint = new Point(0, (size - 1) / 2);
  49. }
  50.  
  51. }
  52.  
  53. public boolean reachable(Point target, Point from){
  54. return target == from || getPath(from, target).size() != 1;
  55. }
  56.  
  57. public LinkedList<Point> getPath(Point from, Point to) {
  58.  
  59. int[][] visited = new int[size][size];
  60. int[][] cum_cost = new int[size][size];
  61. for (int i = 0; i < size; i++)
  62. for (int j = 0; j < size; j++) cum_cost[i][j] = Integer.MAX_VALUE / 2;
  63. for (int i = 0; i < size; i++) for (int j = 0; j < size; j++) visited[i][j] = b[i][j];
  64. Point[][] pred = new Point[size][size];
  65.  
  66. LinkedList<Point> Q = new LinkedList<Point>();
  67.  
  68. visited[from.x][from.y] = bfsvisited;
  69. cum_cost[from.x][from.y] = 0;
  70. pred[from.x][from.y] = null;
  71. Q.add(from);
  72.  
  73. while (!Q.isEmpty()) {
  74. Point min_p = Q.peek();
  75. int min_cost = cum_cost[min_p.x][min_p.y] + distance(min_p, to);
  76.  
  77. for (Point p : Q) {
  78. int cost = cum_cost[p.x][p.y] + distance(p, to);
  79. if (cost < min_cost) {
  80. min_p = p;
  81. min_cost = cost;
  82. }
  83. }
  84. if (min_p.equals(to)) break;
  85.  
  86. Q.remove(min_p);
  87. visited[min_p.x][min_p.y] = bfsvisited;
  88. ArrayList<Point> neighbors = neighbors(min_p);
  89.  
  90. for (Point neighbor : neighbors) {
  91. if (!Q.contains(neighbor) && visited[neighbor.x][neighbor.y] == empty) Q.add(neighbor);
  92.  
  93. int new_cost = cum_cost[min_p.x][min_p.y] + 1 + distance(min_p, to);
  94. int old_cost = cum_cost[neighbor.x][neighbor.y] + distance(neighbor, to);
  95.  
  96. if (new_cost < old_cost) {
  97. cum_cost[neighbor.x][neighbor.y] = cum_cost[min_p.x][min_p.y] + 1;
  98. pred[neighbor.x][neighbor.y] = min_p;
  99. }
  100. }
  101. }
  102.  
  103. LinkedList<Point> path = new LinkedList<>();
  104. Point p = to;
  105.  
  106. while (p != null) {
  107. path.push(p);
  108. p = pred[p.x][p.y];
  109. }
  110. return path;
  111. }
  112.  
  113. public int n_discovered(){
  114. int n = 0;
  115. for(int i = 0; i < size; i++)
  116. for(int j = 0 ; j < size;j++)
  117. if(b[i][j] != unvisited)
  118. n+=1;
  119. return n;
  120. }
  121.  
  122. public int evalPoint(Point point, Point current, Point goal) {
  123. //TODO: avoid unvisited nodes with lots of barriers around them
  124. int dist_pg = distance(point, goal);
  125. int dist_pc = getPath(current, point).size();
  126.  
  127. int pg_weight = Math.min(n_discovered()/size*size + 1/2, 1);
  128.  
  129. // count number of unvisited nodes near target node;
  130. int unvisited_neighbors = 0;
  131. int obstacles_nearby = 0;
  132. int radius = 1;
  133. int radius_obstacle = 2;
  134. for (int i = -radius; i <= radius; i++) {
  135. for (int j = -radius; j <= radius; j++) {
  136. int neighborx = point.x + i;
  137. int neighbory = point.y + j;
  138. if (neighborx >= size || neighbory >= size) continue;
  139. if (neighborx < 0 || neighbory < 0) continue;
  140. if (b[neighborx][neighbory] == unvisited) unvisited_neighbors += 1;
  141. }
  142. }
  143.  
  144. for (int i = -radius_obstacle; i <= radius_obstacle; i++) {
  145. for (int j = -radius_obstacle; j <= radius_obstacle; j++) {
  146. int neighborx = point.x + i;
  147. int neighbory = point.y + j;
  148. if (neighborx >= size || neighbory >= size) continue;
  149. if (neighborx < 0 || neighbory < 0) continue;
  150. if (b[neighborx][neighbory] == obstacle) obstacles_nearby += 1;
  151. }
  152. }
  153.  
  154. return dist_pc + dist_pg/2 + obstacles_nearby;
  155. }
  156.  
  157. public ArrayList<Point> getReachableUnvisited(Point from) {
  158. int[][] visited = new int[size][size];
  159. for (int i = 0; i < size; i++) for (int j = 0; j < size; j++) visited[i][j] = b[i][j];
  160.  
  161. LinkedList<Point> Q = new LinkedList<Point>();
  162. ArrayList<Point> reachable = new ArrayList<Point>();
  163.  
  164. visited[from.x][from.y] = bfsvisited;
  165. Q.add(from);
  166.  
  167. while (!Q.isEmpty()) {
  168. Point p = Q.pop();
  169. visited[p.x][p.y] = bfsvisited;
  170. ArrayList<Point> neighbors = neighbors(p);
  171. for (Point neighbor : neighbors) {
  172. if (visited[neighbor.x][neighbor.y] == unvisited) {
  173. reachable.add(neighbor);
  174. visited[neighbor.x][neighbor.y] = bfsvisited;
  175. }
  176. if (visited[neighbor.x][neighbor.y] == empty && !Q.contains(neighbor)) Q.add(neighbor);
  177. }
  178. }
  179.  
  180. return reachable;
  181. }
  182.  
  183. public ArrayList<Point> neighbors(Point p) {
  184. int x = p.x;
  185. int y = p.y;
  186. ArrayList<Point> neighborz = new ArrayList<>();
  187. if (x - 1 >= 0) neighborz.add(new Point(x - 1, y));
  188. if (x + 1 < size) neighborz.add(new Point(x + 1, y));
  189. if (y - 1 >= 0) neighborz.add(new Point(x, y - 1));
  190. if (y + 1 < size) neighborz.add(new Point(x, y + 1));
  191.  
  192. return neighborz;
  193. }
  194.  
  195. public String toString() {
  196. StringBuilder s = new StringBuilder();
  197. for (int i = size - 1; i >= 0; i--) {
  198. for (int j = 0; j < size; j++) {
  199. s.append(b[j][i]);
  200. s.append(' ');
  201. }
  202. s.append('\n');
  203. }
  204.  
  205. return s.toString();
  206. }
  207. }
  208.  
  209. static int distance(Point p1, Point p2) {
  210. return Math.abs(p1.x - p2.x) + Math.abs(p1.y - p2.y);
  211. }
  212.  
  213. static int n_agents = 0;
  214. static Board board;
  215. static int size = 0;
  216. static boolean doneSizing = false;
  217. static int turn = 0;
  218. static srs140430Agent oddAgent;
  219. static srs140430Agent evenAgent;
  220.  
  221. boolean topAgent, bottomAgent;
  222. boolean leftTeam, rightTeam;
  223. boolean determineSize = false;
  224. boolean newGame = true;
  225. int id;
  226. Point coord;
  227. Point prev;
  228. Point goal;
  229. LinkedList<Point> path;
  230. LinkedList<Boolean> memory = new LinkedList<>();
  231.  
  232. public srs140430Agent() {
  233. n_agents += 1;
  234. id = n_agents;
  235. board = null;
  236. size = 2;
  237. doneSizing = false;
  238. turn = 0;
  239.  
  240. if (id % 2 == 0) evenAgent = this;
  241. else oddAgent = this;
  242. }
  243.  
  244. public int getMove(AgentEnvironment env) {
  245. if (newGame) newGameSetup(env);
  246. if (bottomAgent) turn += 1;
  247. if(memory != null){
  248. if (leftTeam)
  249. memory.add(env.isObstacleEastImmediate());
  250. if (rightTeam)
  251. memory.add(env.isObstacleWestImmediate());
  252. }
  253. if (determineSize) return investigateSize(env);
  254.  
  255.  
  256. if (coord == null) {
  257. out.println("COORD IS NULL");
  258. if (env.isBaseSouth(0, true)) coord = new Point(homeColumn(), (board.size - 1) / 2 + 1);
  259. else coord = new Point(homeColumn(), (board.size - 1) / 2 - 1);
  260. }
  261.  
  262. if(memory != null){
  263. int x = coord.x;
  264. if(leftTeam)
  265. x += 1;
  266. else
  267. x -= 1;
  268.  
  269. if(topAgent){
  270. for(int y = size - 1; y >= coord.y; y--){
  271. if(memory.poll())
  272. board.b[x][y] = obstacle;
  273. else
  274. board.b[x][y] = empty;
  275. }
  276. }
  277.  
  278. else{
  279. for(int y = 0; y <= coord.y; y++){
  280. if(memory.poll())
  281. board.b[x][y] = obstacle;
  282. else
  283. board.b[x][y] = empty;
  284. }
  285. }
  286. memory = null;
  287. }
  288.  
  289. out.println("*************");
  290.  
  291. if (topAgent) {
  292. out.println("Top Agent's Move:");
  293. }
  294.  
  295. if (bottomAgent) {
  296. out.println("Bottom Agent's Move:");
  297. }
  298.  
  299. checkIfReset(env);
  300. checkForObstacles(env);
  301.  
  302. int move = -1;
  303. if(!env.hasFlag() && attackFlagBearer(env) != AgentAction.DO_NOTHING){
  304. out.println("Attacking Flag");
  305. move = attackFlagBearer(env);
  306. prev = coord;
  307. coord = newCoord(move);
  308.  
  309. return move;
  310. }
  311.  
  312. if(topAgent && env.hasFlag(AgentEnvironment.ENEMY_TEAM)){
  313. ArrayList<Point> neighbors = board.neighbors(coord);
  314. int[][] eval = new int[board.size][board.size];
  315. for(int i =0; i < board.size; i ++){
  316. for(int j = 0; j < board.size; j++){
  317. if(i > coord.x){
  318. if(env.isFlagEast(AgentEnvironment.OUR_TEAM, false))
  319. eval[i][j] += 5;
  320. }
  321. if(i < coord.x){
  322. if(env.isFlagWest(AgentEnvironment.OUR_TEAM, false))
  323. eval[i][j] += 5;
  324. }
  325. if(j > coord.y){
  326. if(env.isFlagNorth(AgentEnvironment.OUR_TEAM, false))
  327. eval[i][j] += 5;
  328. }
  329. if(j < coord.y){
  330. if(env.isFlagSouth(AgentEnvironment.OUR_TEAM, false))
  331. eval[i][j] += 5;
  332. }
  333.  
  334. if(getOtherAgent().coord.x == i && getOtherAgent().coord.y == j)
  335. eval[i][j] -= 500;
  336. }
  337. }
  338.  
  339. Collections.shuffle(neighbors);
  340. Point best = null;
  341. int val = -1;
  342. for(Point p: neighbors){
  343. if(eval[p.x][p.y] > val){
  344. best = p;
  345. val = eval[p.x][p.y];
  346. }
  347. }
  348.  
  349. move = actionFromPoints(coord, best);
  350. prev = coord;
  351. coord = newCoord(move);
  352.  
  353. System.out.printf("PANIC, CURR = %s, TARGET = %s, %d\n", coord, best, val);
  354.  
  355. return move;
  356. }
  357.  
  358. move = computeNextMove(env);
  359.  
  360. if (isBlocked(move, env)){
  361. move = rand.nextInt(4);
  362. if (isBlocked(move, env))
  363. move = rand.nextInt(4);
  364. }
  365.  
  366.  
  367. if (isBlocked(move, env))
  368. move = AgentAction.DO_NOTHING;
  369.  
  370. prev = coord;
  371. coord = newCoord(move);
  372.  
  373. return move;
  374. }
  375.  
  376. int attackFlagBearer(AgentEnvironment env){
  377. if(!env.hasFlag(AgentEnvironment.ENEMY_TEAM)){
  378. return AgentAction.DO_NOTHING;
  379. }
  380.  
  381. if(env.isFlagEast(AgentEnvironment.OUR_TEAM, true)){
  382. out.println("ENEMY FLAGBEARER IS ADJACENT!");
  383. return AgentAction.MOVE_EAST;
  384. }
  385.  
  386. if(env.isFlagWest(AgentEnvironment.OUR_TEAM, true)){
  387. out.println("ENEMY FLAGBEARER IS ADJACENT!");
  388. return AgentAction.MOVE_WEST;
  389. }
  390.  
  391. if(env.isFlagNorth(AgentEnvironment.OUR_TEAM, true)){
  392. out.println("ENEMY FLAGBEARER IS ADJACENT!");
  393. return AgentAction.MOVE_NORTH;
  394. }
  395.  
  396. if(env.isFlagSouth(AgentEnvironment.OUR_TEAM, true)){
  397. out.println("ENEMY FLAGBEARER IS ADJACENT!");
  398. return AgentAction.MOVE_SOUTH;
  399. }
  400.  
  401. return AgentAction.DO_NOTHING;
  402. }
  403.  
  404. void setGoal(AgentEnvironment env){
  405. if (bottomAgent && goal == null) goal = board.theirbasepoint;
  406. if (topAgent && goal == null) goal = new Point(board.mybasepoint.x, board.mybasepoint.y - 1);
  407.  
  408. if (env.hasFlag()){
  409. goal = board.mybasepoint;
  410. path = null;
  411. }
  412.  
  413. if(goal == board.mybasepoint && !env.hasFlag()){
  414. goal = board.theirbasepoint;
  415. path = null;
  416. }
  417.  
  418. if(topAgent && goal.equals(coord)){
  419. int ydiff = board.mybasepoint.y - coord.y;
  420. goal = new Point(board.mybasepoint.x, board.mybasepoint.y + ydiff);
  421. }
  422. }
  423.  
  424. int computeNextMove(AgentEnvironment env) {
  425. setGoal(env);
  426.  
  427. if(path != null){
  428. Point target = path.peekLast();
  429. if(board.b[target.x][target.y] != unvisited){
  430. out.println("TARGET IS ALREAD VISITED");
  431. path = null;
  432. }
  433. else if (coord.equals(path.peek())) {
  434. out.println("FOLLOWING PATH");
  435. path.pop();
  436. if(!path.isEmpty())
  437. return actionFromPoints(coord, path.peek());
  438. else
  439. path = null;
  440. }
  441. else
  442. path = null;
  443. }
  444.  
  445. //recompute path
  446. if (path == null) {
  447. out.println("COMPUTING PATH TO NEW TARGET");
  448. int min_cost = Integer.MAX_VALUE;
  449. Point target = null;
  450. if(!board.reachable(goal, coord)){
  451. for (Point p : board.getReachableUnvisited(coord)) {
  452. if (board.evalPoint(p, coord, goal) < min_cost){ target = p;
  453. min_cost = board.evalPoint(p, coord, goal);
  454. }
  455. }
  456. }
  457. else{
  458. out.println("GOAL IS REACHABLE");
  459. if(topAgent)
  460. target = goal;
  461. else if(!env.hasFlag()){
  462. if(rand.nextDouble() < 0.25){
  463. for (Point p : board.getReachableUnvisited(coord)) {
  464. if (board.evalPoint(p, coord, goal) < min_cost){ target = p;
  465. min_cost = board.evalPoint(p, coord, goal);
  466. }
  467. }
  468. }else{
  469. target = goal;
  470. }
  471.  
  472. }
  473. else{
  474. target = goal;
  475. }
  476. }
  477. out.printf("NEW TARGET: %s%n",target);
  478. path = board.getPath(coord, target);
  479. }
  480.  
  481. out.printf("%s %s%n", coord, path);
  482.  
  483. if(topAgent){
  484. if(env.isAgentNorth(AgentEnvironment.ENEMY_TEAM, true))
  485. return AgentAction.MOVE_NORTH;
  486. if(env.isAgentSouth(AgentEnvironment.ENEMY_TEAM, true))
  487. return AgentAction.MOVE_SOUTH;
  488. if(env.isAgentWest(AgentEnvironment.ENEMY_TEAM, true))
  489. return AgentAction.MOVE_WEST;
  490. if(env.isAgentEast(AgentEnvironment.ENEMY_TEAM, true))
  491. return AgentAction.MOVE_EAST;
  492. }
  493.  
  494.  
  495.  
  496. if(path.isEmpty())
  497. return AgentAction.DO_NOTHING;
  498.  
  499. if (coord.equals(path.peek())) {
  500. out.println("FOLLOWING PATH");
  501. path.pop();
  502. if(!path.isEmpty())
  503. return actionFromPoints(coord, path.peek());
  504. else
  505. path = null;
  506. }
  507.  
  508. out.println("RETURNING RANDOM");
  509.  
  510. return rand.nextInt(4);
  511. }
  512.  
  513.  
  514.  
  515. int actionFromPoints(Point from, Point to) {
  516. assert from != null;
  517. assert to != null;
  518. int diffx = to.x - from.x;
  519. int diffy = to.y - from.y;
  520.  
  521. switch (diffx) {
  522. case 1:
  523. return AgentAction.MOVE_EAST;
  524. case -1:
  525. return AgentAction.MOVE_WEST;
  526. }
  527.  
  528. switch (diffy) {
  529. case 1:
  530. return AgentAction.MOVE_NORTH;
  531. case -1:
  532. return AgentAction.MOVE_SOUTH;
  533. }
  534.  
  535. return AgentAction.DO_NOTHING;
  536. }
  537.  
  538. int xOffset(int move) {
  539. switch (move) {
  540. case AgentAction.MOVE_EAST:
  541. return 1;
  542. case AgentAction.MOVE_WEST:
  543. return -1;
  544. default:
  545. return 0;
  546. }
  547. }
  548.  
  549. int yOffset(int move) {
  550. switch (move) {
  551. case AgentAction.MOVE_NORTH:
  552. return 1;
  553. case AgentAction.MOVE_SOUTH:
  554. return -1;
  555. default:
  556. return 0;
  557. }
  558. }
  559.  
  560. Point newCoord(int move) {
  561. return new Point(coord.x + xOffset(move), coord.y + yOffset(move));
  562. }
  563.  
  564. boolean isBlocked(int move, AgentEnvironment env) {
  565. if(move == AgentAction.DO_NOTHING)
  566. return false;
  567. srs140430Agent other = getOtherAgent();
  568. assert other != this;
  569. Point temp = newCoord(move);
  570.  
  571. if (temp.equals(other.coord)) return true;
  572.  
  573. switch (move) {
  574. case AgentAction.MOVE_EAST:
  575. if(env.hasFlag() && env.isAgentEast(AgentEnvironment.ENEMY_TEAM, true))
  576. return true;
  577. assert (temp.equals(other.coord)) == env.isAgentEast(AgentEnvironment.OUR_TEAM, true);
  578. return env.isObstacleEastImmediate() || (env.isFlagEast(AgentEnvironment.OUR_TEAM, true) && !env.hasFlag());
  579.  
  580. case AgentAction.MOVE_WEST:
  581. if(env.hasFlag() && env.isAgentWest(AgentEnvironment.ENEMY_TEAM, true))
  582. return true;
  583. assert (temp.equals(other.coord)) == env.isAgentWest(AgentEnvironment.OUR_TEAM, true);
  584. return env.isObstacleWestImmediate() || (env.isFlagWest(AgentEnvironment.OUR_TEAM, true) && !env.hasFlag());
  585.  
  586. case AgentAction.MOVE_NORTH:
  587. if(env.hasFlag() && env.isAgentNorth(AgentEnvironment.ENEMY_TEAM, true))
  588. return true;
  589. assert (temp.equals(other.coord)) == env.isAgentNorth(AgentEnvironment.OUR_TEAM, true);
  590. return env.isObstacleNorthImmediate() || (env.isFlagNorth(AgentEnvironment.OUR_TEAM, true) && !env.hasFlag());
  591.  
  592. case AgentAction.MOVE_SOUTH:
  593. if(env.hasFlag() && env.isAgentSouth(AgentEnvironment.ENEMY_TEAM, true))
  594. return true;
  595. assert (temp.equals(other.coord)) == env.isAgentSouth(AgentEnvironment.OUR_TEAM, true);
  596. return env.isObstacleSouthImmediate() || (env.isFlagSouth(AgentEnvironment.OUR_TEAM, true) && !env.hasFlag());
  597.  
  598. case AgentAction.DO_NOTHING:
  599. return false;
  600. }
  601. assert false;
  602. return true;
  603. }
  604.  
  605. void checkForObstacles(AgentEnvironment env) {
  606. if (coord.x - 1 >= 0) {
  607. boolean obst = env.isObstacleWestImmediate();
  608. int val = obst ? obstacle : empty;
  609. if (board.b[coord.x - 1][coord.y] == unvisited) board.b[coord.x - 1][coord.y] = val;
  610. }
  611. if (coord.x + 1 < size) {
  612. boolean obst = env.isObstacleEastImmediate();
  613. int val = obst ? obstacle : empty;
  614. if (board.b[coord.x + 1][coord.y] == unvisited) board.b[coord.x + 1][coord.y] = val;
  615. }
  616. if (coord.y - 1 >= 0) {
  617. boolean obst = env.isObstacleSouthImmediate();
  618. int val = obst ? obstacle : empty;
  619. if (board.b[coord.x][coord.y - 1] == unvisited) board.b[coord.x][coord.y - 1] = val;
  620. }
  621. if (coord.y + 1 < size) {
  622. boolean obst = env.isObstacleNorthImmediate();
  623. int val = obst ? obstacle : empty;
  624. if (board.b[coord.x][coord.y + 1] == unvisited) board.b[coord.x][coord.y + 1] = val;
  625. }
  626. }
  627.  
  628. void checkIfReset(AgentEnvironment env) {
  629. if (onHomeColumn(env)) {
  630. if (topAgent && env.isObstacleNorthImmediate())
  631. coord = new Point(homeColumn(), board.size - 1);
  632. else if (bottomAgent && env.isObstacleSouthImmediate()) coord = new Point(homeColumn(), 0);
  633. }
  634. }
  635.  
  636. void newGameSetup(AgentEnvironment env) {
  637. if (env.isObstacleSouthImmediate()) bottomAgent = true;
  638. else topAgent = true;
  639.  
  640. leftTeam = env.isBaseEast(1, false);
  641. rightTeam = !leftTeam;
  642.  
  643. newGame = false;
  644. determineSize = true;
  645. }
  646.  
  647. int investigateSize(AgentEnvironment env) {
  648. if (topAgent && !env.isFlagSouth(0, true)) {
  649. size += 1;
  650. return AgentAction.MOVE_SOUTH;
  651. }
  652. if (bottomAgent && !env.isFlagNorth(0, true)) {
  653. size += 1;
  654. return AgentAction.MOVE_NORTH;
  655. }
  656. if (!doneSizing) {
  657. doneSizing = true;
  658. determineSize = false;
  659. return AgentAction.DO_NOTHING;
  660. }
  661.  
  662. determineSize = false;
  663. size += 1;
  664. board = new Board(size, leftTeam);
  665.  
  666. return AgentAction.DO_NOTHING;
  667. }
  668.  
  669. boolean onHomeColumn(AgentEnvironment env) {
  670. if (leftTeam) return !env.isBaseWest(0, false);
  671.  
  672. return !env.isBaseEast(0, false);
  673. }
  674.  
  675. srs140430Agent getOtherAgent() {
  676. if (id % 2 == 0) return oddAgent;
  677. else return evenAgent;
  678. }
  679.  
  680. int homeColumn() {
  681. return leftTeam ? 0 : board.size - 1;
  682. }
  683. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement