@@ -0,0 +1,1952 @@
+package es.ucm.fdi.tp.ataxx;%0A%0Aimport java.util.List;%0A%0Aimport es.ucm.fdi.tp.basecode.bgame.Utils;%0Aimport es.ucm.fdi.tp.basecode.bgame.control.Player;%0Aimport es.ucm.fdi.tp.basecode.bgame.model.Board;%0Aimport es.ucm.fdi.tp.basecode.bgame.model.GameError;%0Aimport es.ucm.fdi.tp.basecode.bgame.model.GameMove;%0Aimport es.ucm.fdi.tp.basecode.bgame.model.GameRules;%0Aimport es.ucm.fdi.tp.basecode.bgame.model.Pair;%0Aimport es.ucm.fdi.tp.basecode.bgame.model.Piece;%0A%0A/**%0A * A random player for ConnectN.%0A * %0A * %3Cp%3E%0A * Un jugador aleatorio para ConnectN.%0A *%0A */%0Apublic class AtaxxRandomPlayer extends Player %7B%0A%0A%09/**%0A%09 * %0A%09 */%0A%09private static final long serialVersionUID = 1L;%0A%0A%09@Override%0A%09public GameMove requestMove(Piece p, Board board, List%3CPiece%3E pieces, GameRules rules) %7B%0A%09%09if (board.isFull()) %7B%0A%09%09%09throw new GameError(%22The board is full, cannot make a random move!!%22);%0A%09%09%7D%0A%0A%09%09int rows = board.getRows();%0A%09%09int cols = board.getCols();%0A%0A%09%09// pick an initial random position%0A%09%09int currRow = Utils.randomInt(rows);%0A%09%09int currCol = Utils.randomInt(cols);%0A%09%09%0A%09%09Pair%3CInteger,Integer%3E pos = null;%0A%09%09%0A%09%09// start at (currRow,currColl) and look for the first empty position.%0A%09%09while (true) %7B%0A%09%09%09if (board.getPosition(currRow, currCol) == null) %7B%0A%09%09%09%09pos = surroundings(board, rows, cols, p);%0A%09%09%09%09if(pos != null) %7B%0A%09%09%09%09%09return new AtaxxMove(pos.getFirst(), pos.getSecond(), rows, cols, p);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09currCol = (currCol + 1) %25 cols;%0A%09%09%09if (currCol == 0) %7B%0A%09%09%09%09currRow = (currRow + 1) %25 rows;%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%7D%0A%0A%09private Pair%3CInteger,Integer%3E surroundings(Board board, int row, int col, Piece p) %7B%0A%09%09int minRow = Math.max(0, row-2),%0A%09%09    maxRow = Math.min(board.getRows()-1, row+2);%0A%09%09int minCol = Math.max(0, col-2),%0A%09%09    maxCol = Math.min(board.getCols()-1, col+2);%0A%09%09%0A%09%09%0A%09%09for(int i = minRow; i%3CmaxRow; i++)%7B%0A%09%09%09for(int j = minCol; j%3CmaxCol; j++)%7B%0A%09%09%09%09if(p.equals(board.getPosition(i,j))) %7B%0A%09%09%09%09%09return new Pair%3CInteger,Integer%3E(i,j);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return null;%0A%09%7D%0A%7D

Add random player for Ataxx game