Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobcat committed Jan 28, 2015
1 parent 0bbb293 commit d30ee9c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/Bobcat.h
Expand Up @@ -68,7 +68,7 @@ class Bobcat : public ProtocolListener {
if (search->timeUsed() < search->search_time) {
search->search_time += (search->search_time - search->timeUsed());
}
search->search_time = search->search_time*0.5 + search->timeUsed(); // not too sophisticated
search->search_time += search->search_time*0.5; // not too sophisticated
}
return 0;
}
Expand Down
40 changes: 22 additions & 18 deletions src/Search.h
Expand Up @@ -56,7 +56,7 @@ class Search : public MoveSorter {
while (ply) {
unmakeMove();
}
//storePV(); // leads to illegal moves/time forfeits with ponder on and/or mt. but why?
storePV();
}
}
return 0;
Expand Down Expand Up @@ -127,11 +127,12 @@ class Search : public MoveSorter {
score = searchNextDepthNotPV(next_depth, -alpha, BETA);

if (score > alpha && depth > 1 && next_depth < depth - 1) {
score = searchNextDepthNotPV(depth - 1, -alpha, ALPHA);
score = searchNextDepthNotPV(depth - 1, -alpha, BETA);
}

if (score > alpha) {
score = searchNextDepthPV(std::max(depth - 1, next_depth), -beta, -alpha);
next_depth = getNextDepth(0, true, depth, 1, move_data, alpha, best_score, EXACT, EXACT);
score = searchNextDepthPV(next_depth, -beta, -alpha);
}
}
unmakeMove();
Expand All @@ -143,7 +144,7 @@ class Search : public MoveSorter {
best_move = m;

if (score >= beta) {
updatePV(best_move, best_score, depth, BETA);
// updatePV(best_move, best_score, depth, BETA);
break;
}
updatePV(best_move, best_score, depth, EXACT);
Expand Down Expand Up @@ -213,7 +214,7 @@ class Search : public MoveSorter {

if (okToTryNullMove(depth, beta)) {
makeMoveAndEvaluate(0, beta - 1, beta);
score = searchNextDepthNotPV(depth - nullMoveReduction(depth), -beta + 1, ALPHA);
score = searchNextDepthNotPV(depth - nullMoveReduction(depth), -beta + 1, 128);
unmakeMove();

if (score >= beta) {
Expand Down Expand Up @@ -252,7 +253,7 @@ class Search : public MoveSorter {
score = searchNextDepthNotPV(next_depth, -beta + 1, nextExpectedNodeType);

if (score >= beta && depth > 1 && next_depth < depth - 1) {
score = searchNextDepthNotPV(depth - 1, -beta + 1, ALPHA);
score = searchNextDepthNotPV(depth - 1, -beta + 1, 128);
}
unmakeMove();

Expand All @@ -265,8 +266,9 @@ class Search : public MoveSorter {
}
}

if (expectedNodeType == BETA) {
nextExpectedNodeType = BETA; }
if (expectedNodeType == BETA) { // adding && move_count > n is very bad for percentage 'expected BETA right'
nextExpectedNodeType = 128; //BETA; //slightly less accurate than setting to 128 but much more 'hits' afterwards. for 'expected alpha right' percentage this is very bad
}
}
}

Expand Down Expand Up @@ -313,7 +315,7 @@ class Search : public MoveSorter {

if (okToTryNullMove(depth, beta)) {
makeMoveAndEvaluate(0, beta - 1, beta);
score = searchNextDepthNotPV(depth - nullMoveReduction(depth), -beta + 1, ALPHA);
score = searchNextDepthNotPV(depth - nullMoveReduction(depth), -beta + 1, 128);
unmakeMove();

if (score >= beta) {
Expand Down Expand Up @@ -353,11 +355,12 @@ class Search : public MoveSorter {
score = searchNextDepthNotPV(next_depth, -alpha, BETA);

if (score > alpha && depth > 1 && next_depth < depth - 1) {
score = searchNextDepthNotPV(depth - 1, -alpha, ALPHA);
score = searchNextDepthNotPV(depth - 1, -alpha, BETA);
}

if (score > alpha) {
score = searchNextDepthPV(std::max(depth - 1, next_depth), -beta, -alpha);
next_depth = getNextDepth(0, true, depth, 1, move_data, alpha, best_score, EXACT, EXACT);
score = searchNextDepthPV(next_depth, -beta, -alpha);
}
}
unmakeMove();
Expand Down Expand Up @@ -430,7 +433,7 @@ class Search : public MoveSorter {
Score score = searchNextDepthNotPV(next_depth, -alpha, BETA);

if (score > alpha && depth > 1 && next_depth < depth - 1) {
score = searchNextDepthNotPV(depth - 1, -alpha, ALPHA);
score = searchNextDepthNotPV(depth - 1, -alpha, 128);
}
unmakeMove();

Expand Down Expand Up @@ -610,7 +613,7 @@ class Search : public MoveSorter {
}

__forceinline void checkTime() {
if ((node_count & 1024) == 0) {
if ((node_count & 0x3FFF) == 0) {
if (protocol) {
if (!isAnalysing() && !protocol->isFixedDepth()) {
stop_search = search_depth > 1 && timeUsed() > search_time;
Expand Down Expand Up @@ -655,14 +658,15 @@ class Search : public MoveSorter {
game->moveToString(pv[ply][i].move, buf2));
}
if (protocol && verbosity > 0) {
//game->pos->board->print();
protocol->postPV(search_depth, max_ply_reached, node_count, nodesPerSecond(),
timeUsed(), transt->getLoad(), score, buf, node_type);
}
}
}

__forceinline void storePV() {
for (int i = 0; i < pos->pv_length; i++) {
for (int i = 0; i < pv_length[0]; i++) {
const PVEntry& entry = pv[0][i];
transt->insert(entry.key, entry.depth, entry.score, entry.node_type, entry.move);
}
Expand Down Expand Up @@ -739,9 +743,9 @@ class Search : public MoveSorter {
}
ply = 0;
search_depth = 0;
pos->pv_length = 0;
node_count = 1;
max_ply_reached = 0;
pos->pv_length = 0;
memset(pv, 0, sizeof(pv));
memset(killer_moves, 0, sizeof(killer_moves));
memset(history_scores, 0, sizeof(history_scores));
Expand All @@ -753,8 +757,8 @@ class Search : public MoveSorter {
expectedBetaRight = 0;
expectedAlphaWrong = 0;
expectedBetaWrong= 0;
pv_length[0] = 0;
pos->eval_score = eval->evaluate(alpha, beta);
pv_length[0] = 0;
findTransposition(depth, alpha, beta);
generateMoves();
}
Expand Down Expand Up @@ -825,7 +829,7 @@ class Search : public MoveSorter {
}

__forceinline Score transpositionScore(const Score score, int expectedNodeType) const {
int actualNodeType = pos->transp_flags & (ALPHA | BETA | EXACT);
/*int actualNodeType = pos->transp_flags & (ALPHA | BETA | EXACT);
if (trace) {
if (expectedNodeType == actualNodeType) {
if (expectedNodeType == ALPHA) {
Expand All @@ -843,7 +847,7 @@ class Search : public MoveSorter {
++expectedBetaWrong;
}
}
}
}*///measure is very accurate but knowing it without this is more interesting
return score;
}

Expand Down

0 comments on commit d30ee9c

Please sign in to comment.