-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b547cb
commit 510e3f7
Showing
11 changed files
with
536 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.groupg.game.ai; | ||
|
||
import com.groupg.game.board.Board; | ||
import com.groupg.game.board.PointsPosition; | ||
import com.groupg.game.gameobject.PieceColor; | ||
|
||
public class Evaluation { | ||
private int evaluation; | ||
private int positionEvaluated; | ||
private Board board; | ||
|
||
public Evaluation() { | ||
} | ||
|
||
public Evaluation(int evaluation, Board board) { | ||
this.evaluation = evaluation; | ||
this.board = board; | ||
} | ||
|
||
public int getEvaluation() { | ||
return evaluation; | ||
} | ||
|
||
public void setEvaluation(int evaluation) { | ||
this.evaluation = evaluation; | ||
} | ||
|
||
public int getPositionEvaluated() { | ||
return positionEvaluated; | ||
} | ||
|
||
public void setPositionEvaluated(int positionEvaluated) { | ||
this.positionEvaluated = positionEvaluated; | ||
} | ||
|
||
public Board getBoard() { | ||
return board; | ||
} | ||
|
||
public void setBoard(Board board) { | ||
this.board = board; | ||
} | ||
|
||
public int getAddedPiece(Board board) { | ||
for (int i = 0; i < PointsPosition.NUMBER_OF_POINTS; i++) { | ||
if (this.board.getBitBoard(PieceColor.BLACK).get(i) != board.getBitBoard(PieceColor.BLACK).get(i)) return i; | ||
} | ||
|
||
return -1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.groupg.game.ai; | ||
|
||
import com.groupg.game.board.Board; | ||
import com.groupg.game.board.PointsPosition; | ||
import com.groupg.game.gameobject.PieceColor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.BitSet; | ||
|
||
public class GenerateMove { | ||
public static ArrayList<Board> getMidPhasePossibleStates(Board currentBoardState, boolean isMaximizer) { | ||
ArrayList<Board> possibleBoardStates = new ArrayList<>(); | ||
|
||
for (int i = 0; i < PointsPosition.NUMBER_OF_POINTS; i++) { | ||
if (isMaximizer) { | ||
|
||
} | ||
} | ||
return null; | ||
} | ||
|
||
public static ArrayList<Board> getOpeningPhasePossibleStates(Board currentBoardState, boolean isMaximizer) { | ||
ArrayList<Board> possibleBoardStates = new ArrayList<>(); | ||
|
||
for (int i = 0; i < PointsPosition.NUMBER_OF_POINTS; i++) { | ||
if (currentBoardState.isEmptyPoint(i)) { | ||
Board copyCurrentBoard = currentBoardState.getCopy(); | ||
|
||
if (isMaximizer) { | ||
copyCurrentBoard.setPositionValue(PieceColor.BLACK, i); | ||
if (PointsPosition.checkMill(i, copyCurrentBoard.getBitBoard(PieceColor.BLACK))) { | ||
possibleBoardStates = (getAllRemoveStates(copyCurrentBoard, possibleBoardStates, true)); | ||
} else { | ||
possibleBoardStates.add(copyCurrentBoard); | ||
} | ||
} else { | ||
copyCurrentBoard.setPositionValue(PieceColor.WHITE, i); | ||
if (PointsPosition.checkMill(i, copyCurrentBoard.getBitBoard(PieceColor.WHITE))) { | ||
possibleBoardStates = (getAllRemoveStates(copyCurrentBoard, possibleBoardStates, false)); | ||
} else { | ||
possibleBoardStates.add(copyCurrentBoard); | ||
} | ||
} | ||
} | ||
} | ||
return possibleBoardStates; | ||
} | ||
|
||
private static ArrayList<Board> getAllRemoveStates(Board boardCopy, ArrayList<Board> boardStates, boolean isMaximizer) { | ||
for (int i = 0; i < PointsPosition.NUMBER_OF_POINTS; i++) { | ||
Board newBoardCopy = boardCopy.getCopy(); | ||
if (checkCaptureValid(i, newBoardCopy, (isMaximizer) ? PieceColor.BLACK : PieceColor.WHITE)) { | ||
boardStates.add(newBoardCopy); | ||
} | ||
} | ||
return boardStates; | ||
} | ||
|
||
public static boolean checkCaptureValid(int capturePosition, Board boardCopy, PieceColor pieceColor) { | ||
PieceColor capturedColor = (pieceColor == PieceColor.WHITE) ? PieceColor.BLACK : PieceColor.WHITE; | ||
BitSet capturedBitBoard = boardCopy.getBitBoard(capturedColor); | ||
|
||
boolean allPiecesMill = true; | ||
for (int i = 0; i < capturedBitBoard.size(); i++) { | ||
if (capturedBitBoard.get(i)) { | ||
if (!PointsPosition.checkMill(i, capturedBitBoard)) { | ||
allPiecesMill = false; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
if (capturePosition >= 0 && (allPiecesMill || !PointsPosition.checkMill(capturePosition, boardCopy.getBitBoard(capturedColor))) && capturedBitBoard.get(capturePosition)) { | ||
capturedBitBoard.clear(capturePosition); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} |
Oops, something went wrong.