ArrayList selectAttacksDefensive(ArrayList list) { AttacksTable t = chess.attacksBlack; if (chess.isWhiteTurn()) { t = chess.attacksWhite; } ArrayList aux = new ArrayList(); foreach (AIMove mov in list) { if (mov.eatenValue >= mov.movedValue || t.numAttacking(mov.finalPos) > 2) { aux.Add(mov); } } return(aux); }
ArrayList selectMovesDefensive(ArrayList list) { AttacksTable mine = chess.attacksBlack; AttacksTable their = chess.attacksWhite; if (chess.isWhiteTurn()) { mine = chess.attacksWhite; their = chess.attacksBlack; } ArrayList aux = new ArrayList(); foreach (AIMove mov in list) { if (their.numAttacking(mov.finalPos) < mine.numAttacking(mov.finalPos)) { aux.Add(mov); } } return(aux); }
AIMove gimmeMove(int i, int j, int x, int y) { AttacksTable t = chess.attacksBlack; if (!chess.isWhiteTurn()) { t = chess.attacksWhite; } AIMove move = new AIMove(); move.initialPos = new Vector2(i, j); move.finalPos = new Vector2(x, y); move.movedValue = gimmeValue(board [i, j].pieceSquare); move.eatenValue = gimmeValue(board [x, y].pieceSquare); move.risk = 5 - t.numAttacking(x, y); if (move.risk < 0) { move.risk = 0; } return(move); }