Version 0.7.9
============= Added open book Added a weighted static evaluation function where the position of each piece is important
This commit is contained in:
@ -8,6 +8,7 @@ import java.util.ArrayList;
|
||||
import suicideChess.Board.NoPieceOnSquare;
|
||||
import suicideChess.Board.UnableToParseFENStringException;
|
||||
import suicideChess.Move.NotAValidMoveException;
|
||||
import suicideChess.OpeningBook.NoOpeningMovesLeft;
|
||||
import suicideChess.Square.NotAValidSquare;
|
||||
import suicideChess.SuicideProblems.NoSuchSuicideProblem;
|
||||
|
||||
@ -36,7 +37,7 @@ public class SuicideChess {
|
||||
/**
|
||||
* The name to be displayed
|
||||
*/
|
||||
public static final String NAME = "djib's SuShi v0.7";
|
||||
public static final String NAME = "djib's SuShi v0.7.9";
|
||||
|
||||
/**
|
||||
* Displays informations in the console.
|
||||
@ -118,14 +119,14 @@ public class SuicideChess {
|
||||
/**
|
||||
* This variable says whether the computer should display a "thinking output"
|
||||
*/
|
||||
private static boolean post = true;
|
||||
private static boolean postThinkingOutput = true;
|
||||
|
||||
/**
|
||||
* Should computer display thinking output or not ?
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean postThinkingOutput() {
|
||||
return post;
|
||||
return postThinkingOutput;
|
||||
}
|
||||
|
||||
private static void displayPlayer(Board bitboard) {
|
||||
@ -136,6 +137,13 @@ public class SuicideChess {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//this variable is used to decide whether or not the computer should use it's opening book
|
||||
//private static boolean playingWithOpeningBook = true;
|
||||
|
||||
//this variable tells if the game is in the opening phase.
|
||||
private static boolean openingPhase = true;
|
||||
|
||||
/**
|
||||
* The main function
|
||||
* @param args No parameters should be transmitted to this function.
|
||||
@ -149,6 +157,9 @@ public class SuicideChess {
|
||||
System.out.println("If you want a graphical interface, you can use XBoard, WinBoard or any compatible program.");
|
||||
System.out.println();
|
||||
|
||||
OpeningBook.load();
|
||||
SuicideProblems.load();
|
||||
System.out.println();
|
||||
|
||||
BufferedReader moveInput = new BufferedReader(new InputStreamReader(System.in));
|
||||
Board bitboard = new Board();
|
||||
@ -215,14 +226,19 @@ public class SuicideChess {
|
||||
case XBoardProtocol.NEW:
|
||||
bitboard=new Board();
|
||||
addPlayedPosition(bitboard);
|
||||
openingPhase = true;
|
||||
OpeningBook.reset();
|
||||
computerPlaying = true; //the computer does not play in foce mode.
|
||||
bitboard.display();
|
||||
|
||||
if(playInACSII())
|
||||
bitboard.display();
|
||||
//System.out.println("variant suicide");
|
||||
break;
|
||||
case XBoardProtocol.HINT:
|
||||
System.out.println("Hint: "+ComputerPlayer.doRandomMove(bitboard));
|
||||
break;
|
||||
case XBoardProtocol.FORCE:
|
||||
openingPhase=false; //don't know what will happen next
|
||||
computerPlaying = false;
|
||||
break;
|
||||
case XBoardProtocol.PING:
|
||||
@ -236,15 +252,17 @@ public class SuicideChess {
|
||||
if (asciiGame) {
|
||||
bitboard.display();
|
||||
}
|
||||
openingPhase = false; //due to the way I implemented the opening book
|
||||
break;
|
||||
case XBoardProtocol.POST:
|
||||
post=true;
|
||||
postThinkingOutput=true;
|
||||
break;
|
||||
case XBoardProtocol.NOPOST:
|
||||
post=false;
|
||||
postThinkingOutput=false;
|
||||
break;
|
||||
case XBoardProtocol.SETBOARD:
|
||||
bitboard=new Board(whatMove.substring(9));
|
||||
openingPhase = false;
|
||||
if(asciiGame)
|
||||
bitboard.display();
|
||||
break;
|
||||
@ -305,6 +323,8 @@ public class SuicideChess {
|
||||
System.out.println("Illegal move: "+theMove.toString());
|
||||
} else {
|
||||
bitboard.doMove(allLegalMoves.get(foundMoveIndex));
|
||||
if(openingPhase)
|
||||
OpeningBook.played(allLegalMoves.get(foundMoveIndex));
|
||||
addPlayedPosition(bitboard);
|
||||
if (asciiGame) {
|
||||
//allLegalMoves.get(foundMoveIndex).display();
|
||||
@ -341,7 +361,17 @@ public class SuicideChess {
|
||||
}
|
||||
|
||||
if (computerPlaying) {
|
||||
Move computerMove = ComputerPlayer.doAlphaBetaMove(bitboard);
|
||||
Move computerMove;
|
||||
if(openingPhase) {
|
||||
try {
|
||||
computerMove = OpeningBook.getMove(bitboard);
|
||||
} catch (NoOpeningMovesLeft e) {
|
||||
openingPhase = false;
|
||||
computerMove = ComputerPlayer.doAlphaBetaMove(bitboard);
|
||||
}
|
||||
} else {
|
||||
computerMove = ComputerPlayer.doAlphaBetaMove(bitboard);
|
||||
}
|
||||
bitboard.doMove(computerMove);
|
||||
addPlayedPosition(bitboard);
|
||||
XBoardProtocol.doMove(computerMove);
|
||||
|
Reference in New Issue
Block a user