william #1
|
@ -15,9 +15,13 @@ public class GameTree {
|
|||
|
||||
static class Node {
|
||||
private final Collection<Node> childs;
|
||||
private final Pawn pawn;
|
||||
private final Pawn.PawnMovement movement;
|
||||
|
||||
Node(Collection<Node> childs) {
|
||||
Node(Collection<Node> childs, Pawn pawn, Pawn.PawnMovement movement) {
|
||||
this.childs = childs;
|
||||
this.pawn = pawn;
|
||||
this.movement = movement;
|
||||
}
|
||||
|
||||
public Collection<Node> getChilds() {
|
||||
|
|
|
@ -68,4 +68,59 @@ public class MiniMax {
|
|||
|
||||
return score;
|
||||
}
|
||||
|
||||
private static int didWin(Pawn pawn) {
|
||||
int goal = pawn.getPlayer() == Player.RED ? 7 : 0;
|
||||
|
||||
if (pawn.getRow() == goal) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int didCapture(Pawn pawn, PusherBoard board) {
|
||||
Pawn capturedPawn = board.getBoard()[pawn.getRow()][pawn.getCol()];
|
||||
|
||||
if (capturedPawn != null) {
|
||||
if (capturedPawn.getPlayer() != pawn.getPlayer()) {
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static class MiniMaxResult {
|
||||
private final int score;
|
||||
private final Pawn pawn;
|
||||
private final Pawn.PawnMovement movement;
|
||||
|
||||
public MiniMaxResult(int score, Pawn pawn, Pawn.PawnMovement movement) {
|
||||
this.score = score;
|
||||
this.pawn = pawn;
|
||||
this.movement = movement;
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public Pawn getPawn() {
|
||||
return pawn;
|
||||
}
|
||||
|
||||
public Pawn.PawnMovement getMovement() {
|
||||
return movement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MiniMaxResult{" +
|
||||
"score=" + score +
|
||||
", pawn=" + pawn +
|
||||
", movement=" + movement +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue