Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
gekomad committed Apr 6, 2016
1 parent e9763b0 commit 898521f
Show file tree
Hide file tree
Showing 15 changed files with 8 additions and 550 deletions.
19 changes: 1 addition & 18 deletions src/Eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,6 @@ int Eval::getScore(const int side, const int N_PIECE, const int alpha, const int
return lazyscore;
}

// int endGameValue = getEndgameValue(N_PIECE, side);
// if (abs(endGameValue) != INT_MAX) {
// return endGameValue;
// }

#ifdef DEBUG_MODE
evaluationCount[WHITE] = evaluationCount[BLACK] = 0;
memset(&SCORE_DEBUG, 0, sizeof(_TSCORE_DEBUG));
Expand Down Expand Up @@ -478,9 +473,7 @@ int Eval::getScore(const int side, const int N_PIECE, const int alpha, const int

cout << HEADER;
cout << "Material: " << setw(10) << (double) (lazyscore_white - lazyscore_black) / 100.0 << setw(15) << (double) (lazyscore_white) / 100.0 << setw(10) << (double) (lazyscore_black) / 100.0 << "\n";
// cout << "Semi-open file: " << setw(10) << (double) (SCORE_DEBUG.HALF_OPEN_FILE[WHITE] - SCORE_DEBUG.HALF_OPEN_FILE[BLACK]) / 100.0 << setw(15) << (double) (SCORE_DEBUG.HALF_OPEN_FILE[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.HALF_OPEN_FILE[BLACK]) / 100.0 << "\n";
cout << "Mobility: " << setw(10) << (double) (mobWhite - mobBlack) / 100.0 << setw(15) << (double) (mobWhite) / 100.0 << setw(10) << (double) (mobBlack) / 100.0 << "\n";
// cout << "Attack king: " << setw(10) << (double) (attack_king_white - attack_king_black) / 100.0 << setw(15) << (double) (attack_king_white) / 100.0 << setw(10) << (double) (attack_king_black) / 100.0 << "\n";
cout << "Bonus attack king:" << setw(10) << (double) (bonus_attack_king_white - bonus_attack_king_black) / 100.0 << setw(15) << (double) (bonus_attack_king_white) / 100.0 << setw(10) << (double) (bonus_attack_king_black) / 100.0 << "\n";

cout << HEADER;
Expand All @@ -506,7 +499,6 @@ int Eval::getScore(const int side, const int N_PIECE, const int alpha, const int
cout << " undevelop: " << setw(10) << (double) (SCORE_DEBUG.UNDEVELOPED_KNIGHT[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.UNDEVELOPED_KNIGHT[BLACK]) / 100.0 << "\n";
cout << " trapped: " << setw(10) << (double) (SCORE_DEBUG.KNIGHT_TRAPPED[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.KNIGHT_TRAPPED[BLACK]) / 100.0 << "\n";
cout << " mobility: " << setw(10) << (double) (SCORE_DEBUG.MOB_KNIGHT[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.MOB_KNIGHT[BLACK]) / 100.0 << "\n";
// cout << " near enemy king " << setw(10) << (double) (SCORE_DEBUG.XKNIGHT_NEAR_KING[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.XKNIGHT_NEAR_KING[BLACK]) / 100.0 << "\n";

cout << HEADER;
cout << "Bishop: " << setw(10) << (double) (Tresult.bishop[WHITE] - Tresult.bishop[BLACK]) / 100.0 << setw(15) << (double) (Tresult.bishop[WHITE]) / 100.0 << setw(10) << (double) (Tresult.bishop[BLACK]) / 100.0 << "\n";
Expand All @@ -515,7 +507,6 @@ int Eval::getScore(const int side, const int N_PIECE, const int alpha, const int
cout << " undevelop: " << setw(10) << (double) (SCORE_DEBUG.UNDEVELOPED_BISHOP[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.UNDEVELOPED_BISHOP[BLACK]) / 100.0 << "\n";
cout << " open diag: " << setw(10) << (double) (SCORE_DEBUG.OPEN_DIAG_BISHOP[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.OPEN_DIAG_BISHOP[BLACK]) / 100.0 << "\n";
cout << " bonus 2 bishops: " << setw(10) << (double) (SCORE_DEBUG.BONUS2BISHOP[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.BONUS2BISHOP[BLACK]) / 100.0 << "\n";
// cout << " near enemy king " << setw(10) << (double) (SCORE_DEBUG.XBISHOP_NEAR_KING[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.XBISHOP_NEAR_KING[BLACK]) / 100.0 << "\n";

cout << HEADER;
cout << "Rook: " << setw(10) << (double) (Tresult.rooks[WHITE] - Tresult.rooks[BLACK]) / 100.0 << setw(15) << (double) (Tresult.rooks[WHITE]) / 100.0 << setw(10) << (double) (Tresult.rooks[BLACK]) / 100.0 << "\n";
Expand All @@ -524,27 +515,19 @@ int Eval::getScore(const int side, const int N_PIECE, const int alpha, const int
cout << " mobility: " << setw(10) << (double) (SCORE_DEBUG.MOB_ROOK[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.MOB_ROOK[BLACK]) / 100.0 << "\n";
cout << " blocked: " << setw(10) << (double) (SCORE_DEBUG.ROOK_BLOCKED[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.ROOK_BLOCKED[BLACK]) / 100.0 << "\n";
cout << " open file: " << setw(10) << (double) (SCORE_DEBUG.ROOK_OPEN_FILE[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.ROOK_OPEN_FILE[BLACK]) / 100.0 << "\n";
// cout << " semi open file: " << setw(10) << (double) (SCORE_DEBUG.ROOK_SEMI_OPEN_FILE[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.ROOK_SEMI_OPEN_FILE[BLACK]) / 100.0 << "\n";
cout << " connected: " << setw(10) << (double) (SCORE_DEBUG.CONNECTED_ROOKS[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.CONNECTED_ROOKS[BLACK]) / 100.0 << "\n";
// cout << " near enemy king " << setw(10) << (double) (SCORE_DEBUG.XROOK_NEAR_KING[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.XROOK_NEAR_KING[BLACK]) / 100.0 << "\n";

cout << HEADER;
cout << "Queen: " << setw(10) << (double) (Tresult.queens[WHITE] - Tresult.queens[BLACK]) / 100.0 << setw(15) << (double) (Tresult.queens[WHITE]) / 100.0 << setw(10) << (double) (Tresult.queens[BLACK]) / 100.0 << "\n";
cout << " mobility: " << setw(10) << (double) (SCORE_DEBUG.MOB_QUEEN[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.MOB_QUEEN[BLACK]) / 100.0 << "\n";
cout << " bishop on queen: " << setw(10) << (double) (SCORE_DEBUG.BISHOP_ON_QUEEN[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.BISHOP_ON_QUEEN[BLACK]) / 100.0 << "\n";
// cout << " near enemy king " << setw(10) << (double) (SCORE_DEBUG.XQUEEN_NEAR_KING[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.XQUEEN_NEAR_KING[BLACK]) / 100.0 << "\n";

cout << HEADER;
cout << "King: " << setw(10) << (double) (Tresult.kings[WHITE] - Tresult.kings[BLACK]) / 100.0 << setw(15) << (double) (Tresult.kings[WHITE]) / 100.0 << setw(10) << (double) (Tresult.kings[BLACK]) / 100.0 << "\n";
cout << " distance: " << setw(10) << (double) (SCORE_DEBUG.DISTANCE_KING[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.DISTANCE_KING[BLACK]) / 100.0 << "\n";
cout << " open file: " << setw(10) << (double) (SCORE_DEBUG.END_OPENING_KING[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.END_OPENING_KING[BLACK]) / 100.0 << "\n";
cout << " pawn near: " << setw(10) << (double) (SCORE_DEBUG.PAWN_NEAR_KING[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.PAWN_NEAR_KING[BLACK]) / 100.0 << "\n";
// cout << " pawn storm: " << setw(10) << (double) (SCORE_DEBUG.PAWN_STORM[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.PAWN_STORM[BLACK]) / 100.0 << "\n";
cout << " mobility: " << setw(10) << (double) (SCORE_DEBUG.MOB_KING[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.MOB_KING[BLACK]) / 100.0 << "\n";
// cout << " bishop near king: " << setw(10) << (double) (SCORE_DEBUG.BISHOP_NEAR_KING[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.BISHOP_NEAR_KING[BLACK]) / 100.0 << "\n";
// cout << " queen near king: " << setw(10) << (double) (SCORE_DEBUG.QUEEN_NEAR_KING[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.QUEEN_NEAR_KING[BLACK]) / 100.0 << "\n";
// cout << " knight near king: " << setw(10) << (double) (SCORE_DEBUG.KNIGHT_NEAR_KING[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.KNIGHT_NEAR_KING[BLACK]) / 100.0 << "\n";
// cout << " rook near king: " << setw(10) << (double) (SCORE_DEBUG.ROOK_NEAR_KING[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.ROOK_NEAR_KING[BLACK]) / 100.0 << "\n";
// cout << " mobility: " << setw(10) << (double) (SCORE_DEBUG.MOB_KING[WHITE]) / 100.0 << setw(10) << (double) (SCORE_DEBUG.MOB_KING[BLACK]) / 100.0 << "\n";
cout << endl;
}
#endif
Expand Down
186 changes: 0 additions & 186 deletions src/GenMoves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,100 +176,6 @@ GenMoves::~GenMoves() {
free(repetitionMap);
}

//bool GenMoves::isPinned(const int side, const uchar position, const uchar piece) {
// u64 king = chessboard[KING_BLACK + side];
// int posKing = BITScanForward(king);
// u64 pow2position = POW2[position];
// if(!(LEFT_RIGHT_RANK_FILE[posKing] & pow2position)) {
// return false;
// }
// int xside = side ^ 1;
// chessboard[piece] &= NOTPOW2[position];
// u64 allpieces = getBitmap<WHITE>() | getBitmap<BLACK>();
// u64 qr = chessboard[QUEEN_BLACK + xside] | chessboard[ROOK_BLACK + xside];
// u64 qb = chessboard[QUEEN_BLACK + xside] | chessboard[BISHOP_BLACK + xside];
// if(king & RANK[position] && RANK[position] & qr) {
// //rank
// for(int n = position + 1; n <= ORIZ_LEFT[position]; n++) {
// if(qr & POW2[n]) {
// chessboard[piece] |= pow2position;
// return true;
// }
// if(allpieces & POW2[n]) {
// break;
// }
// }
// for(int n = position - 1; n >= ORIZ_RIGHT[position]; n--) {
// if(qr & POW2[n]) {
// chessboard[piece] |= pow2position;
// return true;
// }
// if(allpieces & POW2[n]) {
// break;
// }
// }
// } else if(king & FILE_[position] && FILE_[position] & qr) {
// for(int n = posKing + 8; n <= VERT_UPPER[posKing]; n += 8) {
// if(qr & POW2[n]) {
// chessboard[piece] |= pow2position;
// return true;
// }
// if(POW2[n]&allpieces) {
// break;
// }
// }
// for(int n = posKing - 8; n >= VERT_LOWER[posKing]; n -= 8) {
// if(qr & POW2[n]) {
// chessboard[piece] |= pow2position;
// return true;
// }
// if(POW2[n]&allpieces) {
// break;
// }
// }
// } else if(king & LEFT_DIAG[position] && LEFT_DIAG[position] & qb) {
// for(int n = position + 7; n <= LEFT_UPPER[position]; n += 7) {
// if(qb & POW2[n]) {
// chessboard[piece] |= pow2position;
// return true;
// }
// if(allpieces & POW2[n]) {
// break;
// }
// }
// for(int n = position - 7; n >= LEFT_LOWER[position]; n -= 7) {
// if(qb & POW2[n]) {
// chessboard[piece] |= pow2position;
// return true;
// }
// if(allpieces & POW2[n]) {
// break;
// }
// }
// } else if(king & RIGHT_DIAG[position] && RIGHT_DIAG[position] & qb) {
// for(int n = position + 9; n <= RIGHT_UPPER[position]; n += 9) {
// if(qb & POW2[n]) {
// chessboard[piece] |= pow2position;
// return true;
// }
// if(allpieces & POW2[n]) {
// break;
// }
// }
// for(int n = position - 9; n >= RIGHT_LOWER[position]; n -= 9) {
// if(qb & POW2[n]) {
// chessboard[piece] |= pow2position;
// return true;
// }
// if(allpieces & POW2[n]) {
// break;
// }
// }
// }
// chessboard[piece] |= pow2position;
// return false;
//}

void GenMoves::performCastle(const int side, const uchar type) {
ASSERT_RANGE(side, 0, 1);
if (side == WHITE) {
Expand Down Expand Up @@ -399,70 +305,6 @@ bool GenMoves::performKingShiftCapture(int side, const u64 enemies) {
return false;
}


//template<int side>
//bool GenMoves::attackSquare(const uchar position, u64 allpieces) {
// ASSERT_RANGE(position, 0, 63);
// ASSERT_RANGE(side, 0, 1);
// if (KNIGHT_MASK[position] & chessboard[KNIGHT_BLACK + (side ^ 1)]) {
// return true;
// }
// if (NEAR_MASK1[position] & chessboard[KING_BLACK + (side ^ 1)]) {
// return true;
// }
// //enpassant
// if (PAWN_FORK_MASK[side][position] & chessboard[PAWN_BLACK + (side ^ 1)]) {
// return true;
// }
// allpieces |= POW2[position];
// u64 enemies = chessboard[QUEEN_BLACK + (side ^ 1)] | chessboard[BISHOP_BLACK + (side ^ 1)];
// if (LEFT_RIGHT_DIAG[position] & enemies) {
// ///LEFT
// u64 q = allpieces & MASK_BIT_UNSET_LEFT_UP[position];
// if (q && enemies & POW2[BITScanReverse(q)]) {
// return true;
// }
// q = allpieces & MASK_BIT_UNSET_LEFT_DOWN[position];
// if (q && enemies & POW2[BITScanForward(q)]) {
// return true;
// }
// ///RIGHT
// q = allpieces & MASK_BIT_UNSET_RIGHT_UP[position];
// if (q && enemies & POW2[BITScanReverse(q)]) {
// return true;
// }
// q = allpieces & MASK_BIT_UNSET_RIGHT_DOWN[position];
// if (q && enemies & POW2[BITScanForward(q)]) {
// return true;
// }
// }
// ///
// u64 x = allpieces & FILE_[position];
// enemies = chessboard[QUEEN_BLACK + (side ^ 1)] | chessboard[ROOK_BLACK + (side ^ 1)];
// if (x & enemies) {
// u64 q = x & MASK_BIT_UNSET_UP[position];
// if (q && enemies & POW2[BITScanReverse(q)]) {
// return true;
// }
// q = x & MASK_BIT_UNSET_DOWN[position];
// if (q && enemies & POW2[BITScanForward(q)]) {
// return true;
// }
// }
// x = allpieces & RANK[position];
// if (x & enemies) {
// u64 q = x & MASK_BIT_UNSET_RIGHT[position];
// if (q && enemies & POW2[BITScanForward(q)]) {
// return true;
// }
// q = x & MASK_BIT_UNSET_LEFT[position];
// if (q && enemies & POW2[BITScanReverse(q)]) {
// return true;
// }
// }
// return false;
//}

void GenMoves::unPerformCastle(const int side, const uchar type) {
ASSERT_RANGE(side, 0, 1);
if (side == WHITE) {
Expand Down Expand Up @@ -801,34 +643,6 @@ bool GenMoves::generatePuzzle(const string type) {
}
}

/* if (type == "KRKP") {
pieces.push_back(ROOK_BLACK);
pieces.push_back(PAWN_WHITE);
} else if (type == "KQKP") {
pieces.push_back(QUEEN_BLACK);
pieces.push_back(PAWN_WHITE);
} else if (type == "KBBKN") {
pieces.push_back(BISHOP_BLACK);
pieces.push_back(BISHOP_BLACK);
pieces.push_back(KNIGHT_WHITE);
} else if (type == "KQKR") {
pieces.push_back(QUEEN_BLACK);
pieces.push_back(ROOK_WHITE);
} else if (type == "KRKB") {
pieces.push_back(ROOK_BLACK);
pieces.push_back(BISHOP_WHITE);
} else if (type == "KRKN") {
pieces.push_back(ROOK_BLACK);
pieces.push_back(KNIGHT_WHITE);
} else {
cout << "error type";
return;
}*/
writeRandomFen(pieces);
}
return true;
Expand Down
8 changes: 1 addition & 7 deletions src/GenMoves.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@

#include "ChessBoard.h"
#include "util/Bitboard.h"
//#include "Endgame.h"
#include <vector>

class GenMoves : public ChessBoard /* add Endgame and remove ChessBoard TODO*/ {
class GenMoves : public ChessBoard {

public:
static const int MAX_MOVE = 130;
Expand Down Expand Up @@ -256,7 +255,6 @@ class GenMoves : public ChessBoard /* add Endgame and remove ChessBoard TODO*/ {

bool makemove(_Tmove *move, bool rep = true, bool = false);

//bool isPinned(const int side, const uchar Position, const uchar piece);
void incListId() {
listId++;
#ifdef DEBUG_MODE
Expand Down Expand Up @@ -545,12 +543,8 @@ class GenMoves : public ChessBoard /* add Endgame and remove ChessBoard TODO*/ {
};
}

// int performRankFileCaptureCount(const int, const u64 enemies, const u64 allpieces);

int performRankFileCaptureAndShiftCount(const int position, const u64 enemies, const u64 allpieces);

// int performRankFileShiftCount(const int piece, const u64 allpieces);

void popStackMove() {
ASSERT(repetitionMapCount > 0);
if (--repetitionMapCount && repetitionMap[repetitionMapCount - 1] == 0) {
Expand Down
7 changes: 1 addition & 6 deletions src/IterativeDeeping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ void IterativeDeeping::run() {
int mateIn = INT_MAX;
string pvv;
_Tmove resultMove;
while (searchManager.getRunning(0) /*&& mateIn == INT_MAX && mply < maxDepth*/) {
// mateIn = INT_MAX;
while (searchManager.getRunning(0)) {
totMoves = 0;
++mply;
searchManager.init();
Expand All @@ -121,10 +120,6 @@ void IterativeDeeping::run() {

searchManager.setRunningThread(1);
searchManager.setRunning(1);
// if (mply == 2) {
// searchManager.setRunningAll(1);
// }

if (!searchManager.getRes(resultMove, ponderMove, pvv, &mateIn)) {
debug("IterativeDeeping cmove == 0, exit");
break;
Expand Down
1 change: 0 additions & 1 deletion src/IterativeDeeping.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class IterativeDeeping : public Thread<IterativeDeeping> {

#ifdef DEBUG_MODE
//for statistics

atomic_int checkSmp2;
#endif
SearchManager &searchManager = Singleton<SearchManager>::getInstance();
Expand Down
7 changes: 0 additions & 7 deletions src/Search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,6 @@ int Search::quiescence(int alpha, int beta, const char promotionPiece, int N_PIE
if (!(numMovesq++ & 1023)) {
setRunning(checkTime());
}
// int is_incheck_side = inCheck<side>();
// if (!is_incheck_side) {
// int score = lazyEval<side>();
// if (score + FUTIL_MARGIN < alpha)
// return score;
// }

int score = getScore(side, N_PIECE, alpha, beta, false);
if (score >= beta) {
Expand Down Expand Up @@ -395,7 +389,6 @@ int Search::search(int depth, int alpha, int beta, _TpvLine *pline, int N_PIECE,
}
ASSERT_RANGE(res, -_INFINITE, _INFINITE);
ASSERT(mainDepth >= depth);
// cout << side << " " << (*mateIn) << " " << res << "\n";
return res;
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/SearchManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#include "SearchManager.h"


SearchManager::SearchManager() {
SET(checkSmp1, 0);

Expand All @@ -44,7 +43,6 @@ SearchManager::SearchManager() {
};
}
}

}

void SearchManager::search(const int mply) {
Expand Down Expand Up @@ -209,19 +207,19 @@ void SearchManager::clearAge() {
}

int SearchManager::getForceCheck() {
return getThread(0).getForceCheck();// static variable
return getThread(0).getForceCheck();
}

u64 SearchManager::getZobristKey(int id) {
return getThread(id).getZobristKey();
}

void SearchManager::setForceCheck(bool a) {
getThread(0).setForceCheck(a); // static variable
getThread(0).setForceCheck(a);
}

void SearchManager::setRunningThread(bool r) {
getThread(0).setRunningThread(r);// static variable
getThread(0).setRunningThread(r);
}

void SearchManager::setRunning(int i) {
Expand Down
Loading

0 comments on commit 898521f

Please sign in to comment.