Skip to content

Commit

Permalink
Merge 6b01ecd into 7cbb23e
Browse files Browse the repository at this point in the history
  • Loading branch information
bsamseth committed Nov 16, 2018
2 parents 7cbb23e + 6b01ecd commit 8713c98
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
cmake_minimum_required(VERSION 3.0)

# Set project name here.
project(Goldfish VERSION 1.7.0 LANGUAGES CXX)
project(Goldfish VERSION 1.7.1 LANGUAGES CXX)


# Include stuff. No change needed.
Expand Down
26 changes: 14 additions & 12 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ void Search::search_root(Depth depth, int alpha, int beta) {
position.make_move(move);
int value;
//
// Principal Variation Search
// Principal Variation Search (or really NegaScout)
//
// Search first move fully, then just check for moves that will
// improve alpha using a 1-point search window. If first move was
Expand All @@ -379,16 +379,17 @@ void Search::search_root(Depth depth, int alpha, int beta) {
// properly to find its value. The idea is that this drawback is smaller than
// the improvements gained.
//
if (depth > 2 and i > 0) {
if (i > 0) {

value = -search(depth - 1, -alpha - 1, -alpha, ply + 1);

if (value >= alpha) {
// PV search failed high, need to do a full search.
value = -search(depth - 1, -beta, -alpha, ply + 1);
if (value > alpha and value < beta and depth > 1) {
// PV search failed high, need to do a research.
int value2 = -search(depth - 1, -beta, -value, ply + 1);
value = std::max(value, value2);
}
}
// First move, or to shallow for PV search - search fully.
// First move - search fully.
else {
value = -search(depth - 1, -beta, -alpha, ply + 1);
}
Expand Down Expand Up @@ -541,18 +542,19 @@ int Search::search(Depth depth, int alpha, int beta, int ply) {
if (!position.is_check(~position.active_color)) {
searched_moves++;
//
// Principal Variation Search (see search_root for details).
// NegaScout Search (see search_root for details).
//
if (depth > 1 and i > 0) {
if (i > 0) {

value = -search(depth - 1, -alpha - 1, -alpha, ply + 1);

if (value >= alpha) {
// PV search failed high, need to do a full search.
value = -search(depth - 1, -beta, -alpha, ply + 1);
if (value > alpha and value < beta and depth > 1) {
// PV search failed high, need to do a research.
int value2 = -search(depth - 1, -beta, -value, ply + 1);
value = std::max(value, value2);
}
} else {
// First move or to shallow - do full search.
// First move - do full search.
value = -search(depth - 1, -beta, -alpha, ply + 1);
}
}
Expand Down

0 comments on commit 8713c98

Please sign in to comment.