mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Implement init_search()
No functional change Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
8261f61964
commit
7ae16a193b
3 changed files with 30 additions and 21 deletions
|
@ -49,6 +49,7 @@ Application::Application() {
|
||||||
Position::init_piece_square_tables();
|
Position::init_piece_square_tables();
|
||||||
init_eval(1);
|
init_eval(1);
|
||||||
init_bitbases();
|
init_bitbases();
|
||||||
|
init_search();
|
||||||
init_threads();
|
init_threads();
|
||||||
|
|
||||||
// Make random number generation less deterministic, for book moves
|
// Make random number generation less deterministic, for book moves
|
||||||
|
|
|
@ -527,6 +527,34 @@ bool think(const Position& pos, bool infinite, bool ponder, int side_to_move,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// init_search() is called during startup. It initializes various
|
||||||
|
/// lookup tables.
|
||||||
|
|
||||||
|
void init_search() {
|
||||||
|
|
||||||
|
// Init our reduction lookup tables
|
||||||
|
for (int i = 1; i < 64; i++) // i == depth (OnePly = 1)
|
||||||
|
for (int j = 1; j < 64; j++) // j == moveNumber
|
||||||
|
{
|
||||||
|
double pvRed = 0.5 + log(double(i)) * log(double(j)) / 6.0;
|
||||||
|
double nonPVRed = 0.5 + log(double(i)) * log(double(j)) / 3.0;
|
||||||
|
PVReductionMatrix[i][j] = (int8_t) ( pvRed >= 1.0 ? floor( pvRed * int(OnePly)) : 0);
|
||||||
|
NonPVReductionMatrix[i][j] = (int8_t) (nonPVRed >= 1.0 ? floor(nonPVRed * int(OnePly)) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init futility margins array
|
||||||
|
for (int i = 0; i < 14; i++) // i == depth (OnePly = 2)
|
||||||
|
for (int j = 0; j < 64; j++) // j == moveNumber
|
||||||
|
{
|
||||||
|
FutilityMarginsMatrix[i][j] = (i < 2 ? 0 : 112 * bitScanReverse32(i * i / 2)) - 8 * j; // FIXME: test using log instead of BSR
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init futility move count array
|
||||||
|
for (int i = 0; i < 32; i++) // i == depth (OnePly = 2)
|
||||||
|
FutilityMoveCountArray[i] = 3 + (1 << (3 * i / 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// init_threads() is called during startup. It launches all helper threads,
|
/// init_threads() is called during startup. It launches all helper threads,
|
||||||
/// and initializes the split point stack and the global locks and condition
|
/// and initializes the split point stack and the global locks and condition
|
||||||
/// objects.
|
/// objects.
|
||||||
|
@ -540,27 +568,6 @@ void init_threads() {
|
||||||
pthread_t pthread[1];
|
pthread_t pthread[1];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Init our reduction lookup tables
|
|
||||||
for (i = 1; i < 64; i++) // i == depth
|
|
||||||
for (int j = 1; j < 64; j++) // j == moveNumber
|
|
||||||
{
|
|
||||||
double pvRed = 0.5 + log(double(i)) * log(double(j)) / 6.0;
|
|
||||||
double nonPVRed = 0.5 + log(double(i)) * log(double(j)) / 3.0;
|
|
||||||
PVReductionMatrix[i][j] = (int8_t) ( pvRed >= 1.0 ? floor( pvRed * int(OnePly)) : 0);
|
|
||||||
NonPVReductionMatrix[i][j] = (int8_t) (nonPVRed >= 1.0 ? floor(nonPVRed * int(OnePly)) : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init futility margins array
|
|
||||||
for (i = 0; i < 14; i++) // i == depth (OnePly = 2)
|
|
||||||
for (int j = 0; j < 64; j++) // j == moveNumber
|
|
||||||
{
|
|
||||||
FutilityMarginsMatrix[i][j] = (i < 2 ? 0 : 112 * bitScanReverse32(i * i / 2)) - 8 * j; // FIXME: test using log instead of BSR
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init futility move count array
|
|
||||||
for (i = 0; i < 32; i++) // i == depth (OnePly = 2)
|
|
||||||
FutilityMoveCountArray[i] = 3 + (1 << (3 * i / 8));
|
|
||||||
|
|
||||||
for (i = 0; i < THREAD_MAX; i++)
|
for (i = 0; i < THREAD_MAX; i++)
|
||||||
Threads[i].activeSplitPoints = 0;
|
Threads[i].activeSplitPoints = 0;
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ struct SearchStack {
|
||||||
//// Prototypes
|
//// Prototypes
|
||||||
////
|
////
|
||||||
|
|
||||||
|
extern void init_search();
|
||||||
extern void init_threads();
|
extern void init_threads();
|
||||||
extern void stop_threads();
|
extern void stop_threads();
|
||||||
extern bool think(const Position &pos, bool infinite, bool ponder, int side_to_move,
|
extern bool think(const Position &pos, bool infinite, bool ponder, int side_to_move,
|
||||||
|
|
Loading…
Add table
Reference in a new issue