Super IA (#5)
Reviewed-on: #5 Co-authored-by: Persson-dev <sim16.prib@gmail.com> Co-committed-by: Persson-dev <sim16.prib@gmail.com>
This commit was merged in pull request #5.
This commit is contained in:
@@ -70,24 +70,27 @@ public class Game {
|
||||
playerTurn = Color.getEnemy(playerTurn);
|
||||
}
|
||||
|
||||
public GameStatus checkGameStatus() {
|
||||
final Color enemy = Color.getEnemy(getPlayerTurn());
|
||||
|
||||
// this is the bottleneck of algorithms using this chess engine
|
||||
public GameStatus checkGameStatus(Color color) {
|
||||
if (checkDraw())
|
||||
return GameStatus.Draw;
|
||||
|
||||
if (this.board.isKingInCheck(enemy))
|
||||
if (this.board.hasAllowedMoves(enemy))
|
||||
if (this.board.isKingInCheck(color))
|
||||
if (this.board.hasAllowedMoves(color))
|
||||
return GameStatus.Check;
|
||||
else
|
||||
return GameStatus.CheckMate;
|
||||
|
||||
if (!board.hasAllowedMoves(enemy))
|
||||
if (!board.hasAllowedMoves(color))
|
||||
return GameStatus.Pat;
|
||||
|
||||
return GameStatus.OnGoing;
|
||||
}
|
||||
|
||||
public GameStatus checkGameStatus() {
|
||||
return checkGameStatus(Color.getEnemy(getPlayerTurn()));
|
||||
}
|
||||
|
||||
public void addAction(PlayerCommand command) {
|
||||
this.movesHistory.add(command);
|
||||
}
|
||||
@@ -119,4 +122,8 @@ public class Game {
|
||||
return this.movesHistory;
|
||||
}
|
||||
|
||||
public boolean pawnShouldBePromoted() {
|
||||
return this.board.pawnShouldBePromoted();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user