Skip to content

Commit c637c89

Browse files
committed
final submit
1 parent 1d68b51 commit c637c89

File tree

2 files changed

+19
-29
lines changed

2 files changed

+19
-29
lines changed

src/main/java/main/java/hackerearth/taunt/Taunt.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -889,35 +889,6 @@ public int heuristicValue(final int movesPlayed,
889889
}
890890

891891
public int evaluatePosition(final Board board) {
892-
double firstPlayerMoveScore = 0, secondPlayerMoveScore = 0;
893-
double firstPlayerBlockScore = 0, secondPlayerBlockScore = 0;
894-
double firstPlayerCaptureScore = 0, secondPlayerCaptureScore = 0;
895-
final Set<Cell> firstPlayerDestinations = Arrays.stream(board.moves[1])
896-
.filter(Objects::nonNull)
897-
.map(move -> move.end)
898-
.collect(Collectors.toSet()),
899-
secondPlayerDestinations = Arrays.stream(board.moves[2])
900-
.filter(Objects::nonNull)
901-
.map(move -> move.end)
902-
.collect(Collectors.toSet());
903-
for (int i = 0; i < board.options[1]; i++) {
904-
if (moves[1][i].isACapture()) {
905-
firstPlayerCaptureScore++;
906-
} else if (secondPlayerDestinations.contains(moves[1][i].end)) {
907-
firstPlayerBlockScore++;
908-
} else {
909-
firstPlayerMoveScore++;
910-
}
911-
}
912-
for (int i = 0; i < board.options[2]; i++) {
913-
if (moves[2][i].isACapture()) {
914-
secondPlayerCaptureScore++;
915-
} else if (secondPlayerDestinations.contains(moves[1][i].end)) {
916-
secondPlayerBlockScore++;
917-
} else {
918-
secondPlayerMoveScore++;
919-
}
920-
}
921892
return (board.pieceCount[1] - board.pieceCount[2]) * MinMax.PIECE_VALUE;
922893
}
923894

src/main/java/main/java/hackerearth/taunt/TauntTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,25 @@ public void test11() {
206206
Assert.assertNotEquals(new Board.Cell(7, 0), move.end);
207207
}
208208

209+
@Test
210+
public void test13() {
211+
final MinMax minMax = new MinMax(700, 10);
212+
// minMax.setTest(true);
213+
final Move move = minMax.iterativeSearchForBestMove(1, constructBoard("000 000 131 121\n" +
214+
"121 121 111 111\n" +
215+
"000 000 000 000\n" +
216+
"111 000 000 000\n" +
217+
"131 220 000 131\n" +
218+
"000 000 000 000\n" +
219+
"210 000 000 000\n" +
220+
"000 000 000 210\n" +
221+
"000 210 000 220\n" +
222+
"220 230 230 230"));
223+
minMax.metrics();
224+
System.out.println(move);
225+
Assert.assertNotEquals(new Board.Cell(4, 0), move.start);
226+
}
227+
209228
private Board constructBoard(final String input) {
210229
final String rows[] = input.split("\n");
211230
final byte[][] board = new byte[Board.ROWS][Board.COLS];

0 commit comments

Comments
 (0)