Comparable{ float[] genes = new float[]{ 0.6f, 0.3f, 0.05f, 0.1f, 0.1f, 0.1f, 0.2f}; List&ltInteger&gt clearedRowsArray = Collections.synchronizedList(new ArrayList&ltInteger&gt()); float fitness; public float eval(int[][]board) { float sum = 0.0f; sum += genes[0] * BoardEvaluator.clearedRows(board); sum -= genes[1] * BoardEvaluator.pileHeight(board); sum -= genes[2] * BoardEvaluator.countSingleHoles(board); sum -= genes[3] * BoardEvaluator.countConnectedHoles(board); sum -= genes[4] * BoardEvaluator.blocksAboveHoles(board); sum -= genes[5] * BoardEvaluator.countWells(board); sum -= genes[6] * BoardEvaluator.bumpiness(board); return sum; } public int compareTo(Object obj) { if (obj instanceof TetrisAgent) { TetrisAgent other = (TetrisAgent) obj; if (this.fitness > other.fitness) return 1; else if (this.fitness < other.fitness) return -1; } return 0; } public static TetrisAgent randomAgent() { TetrisAgent agent = new TetrisAgent(); Random random = new Random(); for (int i = 0; i < agent.genes.length; i++) agent.genes[i] = random.nextFloat(); return agent; } public TetrisAgent cloneAgent() { TetrisAgent cloneAgent = new TetrisAgent(); for (int i = 0; i < this.genes.length; i++) cloneAgent.genes[i] = this.genes[i]; return cloneAgent; }}Classe BoardEvaluator Esta classe define metodos estaticos, utilizados pelo agente para avaliar determinada configuracao da grade. Os metodos clearedRows, pileHeight e countSingleHoles retornam o numero de linhas removidas, a altura maxima, e o numero de buracos, respectivamente. O metodo countConnectedHoles retorna o numero de buracos conectados, ou seja, buracos adjacentes sao contados apenas uma vez. O metodo blocksAboveHoles retorna a quantidade de blocos que se encontram acima de buracos. O metodo countWells retorna o numero de pocos, ou seja, regioes onde somente a peca do tipo I pode ser encaixada sem deixar buracos. Por fim, bumpiness calcula a nivelacao da grade, observando as diferencas de altura entre colunas adjacentes. Com excecao de clearedRows, admitimos que todas as caracteristicas avaliadas contribuem para o deterioramento da posicao, por isso o sinal negativo. Segue a classe BoardEvaluator:public class BoardEvaluator{ public static int clearedRows(int[][] board) { int cleared = 0; int columns = board[0].length; for(int y = 0; y < board.length - 1; y++) { boolean ok = true; for(int x = 1; (x < columns - 1) && ok; x++) if(board[y][x] == 0) ok = false; if(ok) cleared++; } return cleared; } public static int pileHeight(int[][] board) { int columns = board[0].length; for(int y = 0; y < board.length - 1; y++) { for(int x = 1; x < columns - 1; x++) { if(board[y][x] != 0) return board.length - 1 - y; } } return 0; } public static int countSingleHoles(int[][] board) { int holes = 0; int columns = board[0].length; for (int j = 1; j < columns - 1; j++) { boolean swap = false; for (int i = 0; i < board.length - 1; i++) { if (board[i][j] != 0) swap = true; else { if (swap) holes++; } } } return holes; } public static int countConnectedHoles(int[][] board) { int holes = 0; int columns = board[0].length; for (int j = 1; j < columns - 1; j++) { boolean swap = false; for (int i = 0; i < board.length - 1; i++) { if (board[i][j] != 0) swap = true; else { if (swap) holes++; swap = false; } } } return holes; } public static int