mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
Small cleanups.
closes https://github.com/official-stockfish/Stockfish/pull/2532 Bench: 4869669
This commit is contained in:
parent
ddd4224640
commit
0c878adb36
11 changed files with 22 additions and 27 deletions
|
@ -19,7 +19,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <numeric>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,10 @@
|
||||||
#ifndef ENDGAME_H_INCLUDED
|
#ifndef ENDGAME_H_INCLUDED
|
||||||
#define ENDGAME_H_INCLUDED
|
#define ENDGAME_H_INCLUDED
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "position.h"
|
#include "position.h"
|
||||||
|
|
|
@ -520,7 +520,6 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bonus for restricting their piece moves
|
// Bonus for restricting their piece moves
|
||||||
// Greater bonus when landing square is occupied
|
|
||||||
b = attackedBy[Them][ALL_PIECES]
|
b = attackedBy[Them][ALL_PIECES]
|
||||||
& ~stronglyProtected
|
& ~stronglyProtected
|
||||||
& attackedBy[Us][ALL_PIECES];
|
& attackedBy[Us][ALL_PIECES];
|
||||||
|
@ -721,7 +720,6 @@ namespace {
|
||||||
- 43 * almostUnwinnable
|
- 43 * almostUnwinnable
|
||||||
-110 ;
|
-110 ;
|
||||||
|
|
||||||
// Give more importance to non-material score
|
|
||||||
Value mg = mg_value(score);
|
Value mg = mg_value(score);
|
||||||
Value eg = eg_value(score);
|
Value eg = eg_value(score);
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,12 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "bitboard.h"
|
#include "bitboard.h"
|
||||||
|
#include "endgame.h"
|
||||||
#include "position.h"
|
#include "position.h"
|
||||||
#include "search.h"
|
#include "search.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "tt.h"
|
#include "tt.h"
|
||||||
#include "uci.h"
|
#include "uci.h"
|
||||||
#include "endgame.h"
|
|
||||||
#include "syzygy/tbprobe.h"
|
#include "syzygy/tbprobe.h"
|
||||||
|
|
||||||
namespace PSQT {
|
namespace PSQT {
|
||||||
|
|
14
src/misc.cpp
14
src/misc.cpp
|
@ -299,23 +299,23 @@ void prefetch(void* addr) {
|
||||||
/// With c++17 some of this functionality can be simplified.
|
/// With c++17 some of this functionality can be simplified.
|
||||||
#if defined(__linux__) && !defined(__ANDROID__)
|
#if defined(__linux__) && !defined(__ANDROID__)
|
||||||
|
|
||||||
void* aligned_ttmem_alloc(size_t allocSize, void** mem) {
|
void* aligned_ttmem_alloc(size_t allocSize, void*& mem) {
|
||||||
|
|
||||||
constexpr size_t alignment = 2 * 1024 * 1024; // assumed 2MB page sizes
|
constexpr size_t alignment = 2 * 1024 * 1024; // assumed 2MB page sizes
|
||||||
size_t size = ((allocSize + alignment - 1) / alignment) * alignment; // multiple of alignment
|
size_t size = ((allocSize + alignment - 1) / alignment) * alignment; // multiple of alignment
|
||||||
*mem = aligned_alloc(alignment, size);
|
mem = aligned_alloc(alignment, size);
|
||||||
madvise(*mem, allocSize, MADV_HUGEPAGE);
|
madvise(mem, allocSize, MADV_HUGEPAGE);
|
||||||
return *mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
void* aligned_ttmem_alloc(size_t allocSize, void** mem) {
|
void* aligned_ttmem_alloc(size_t allocSize, void*& mem) {
|
||||||
|
|
||||||
constexpr size_t alignment = 64; // assumed cache line size
|
constexpr size_t alignment = 64; // assumed cache line size
|
||||||
size_t size = allocSize + alignment - 1; // allocate some extra space
|
size_t size = allocSize + alignment - 1; // allocate some extra space
|
||||||
*mem = malloc(size);
|
mem = malloc(size);
|
||||||
void* ret = reinterpret_cast<void*>((uintptr_t(*mem) + alignment - 1) & ~uintptr_t(alignment - 1));
|
void* ret = reinterpret_cast<void*>((uintptr_t(mem) + alignment - 1) & ~uintptr_t(alignment - 1));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ const std::string engine_info(bool to_uci = false);
|
||||||
const std::string compiler_info();
|
const std::string compiler_info();
|
||||||
void prefetch(void* addr);
|
void prefetch(void* addr);
|
||||||
void start_logger(const std::string& fname);
|
void start_logger(const std::string& fname);
|
||||||
void* aligned_ttmem_alloc(size_t size, void** mem);
|
void* aligned_ttmem_alloc(size_t size, void*& mem);
|
||||||
|
|
||||||
void dbg_hit_on(bool b);
|
void dbg_hit_on(bool b);
|
||||||
void dbg_hit_on(bool c, bool b);
|
void dbg_hit_on(bool c, bool b);
|
||||||
|
|
|
@ -52,7 +52,6 @@ namespace {
|
||||||
template<Color Us, GenType Type>
|
template<Color Us, GenType Type>
|
||||||
ExtMove* generate_pawn_moves(const Position& pos, ExtMove* moveList, Bitboard target) {
|
ExtMove* generate_pawn_moves(const Position& pos, ExtMove* moveList, Bitboard target) {
|
||||||
|
|
||||||
// Compute some compile time parameters relative to the white side
|
|
||||||
constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
|
constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
|
||||||
constexpr Bitboard TRank7BB = (Us == WHITE ? Rank7BB : Rank2BB);
|
constexpr Bitboard TRank7BB = (Us == WHITE ? Rank7BB : Rank2BB);
|
||||||
constexpr Bitboard TRank3BB = (Us == WHITE ? Rank3BB : Rank6BB);
|
constexpr Bitboard TRank3BB = (Us == WHITE ? Rank3BB : Rank6BB);
|
||||||
|
|
|
@ -633,11 +633,11 @@ bool Position::gives_check(Move m) const {
|
||||||
Square to = to_sq(m);
|
Square to = to_sq(m);
|
||||||
|
|
||||||
// Is there a direct check?
|
// Is there a direct check?
|
||||||
if (st->checkSquares[type_of(piece_on(from))] & to)
|
if (check_squares(type_of(piece_on(from))) & to)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Is there a discovered check?
|
// Is there a discovered check?
|
||||||
if ( (st->blockersForKing[~sideToMove] & from)
|
if ( (blockers_for_king(~sideToMove) & from)
|
||||||
&& !aligned(from, to, square<KING>(~sideToMove)))
|
&& !aligned(from, to, square<KING>(~sideToMove)))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ Thread::~Thread() {
|
||||||
|
|
||||||
/// Thread::bestMoveCount(Move move) return best move counter for the given root move
|
/// Thread::bestMoveCount(Move move) return best move counter for the given root move
|
||||||
|
|
||||||
int Thread::best_move_count(Move move) {
|
int Thread::best_move_count(Move move) const {
|
||||||
|
|
||||||
auto rm = std::find(rootMoves.begin() + pvIdx,
|
auto rm = std::find(rootMoves.begin() + pvIdx,
|
||||||
rootMoves.begin() + pvLast, move);
|
rootMoves.begin() + pvLast, move);
|
||||||
|
@ -71,14 +71,13 @@ void Thread::clear() {
|
||||||
captureHistory.fill(0);
|
captureHistory.fill(0);
|
||||||
|
|
||||||
for (bool inCheck : { false, true })
|
for (bool inCheck : { false, true })
|
||||||
for (StatsType c : { NoCaptures, Captures })
|
for (StatsType c : { NoCaptures, Captures })
|
||||||
for (auto& to : continuationHistory[inCheck][c])
|
{
|
||||||
for (auto& h : to)
|
for (auto& to : continuationHistory[inCheck][c])
|
||||||
h->fill(0);
|
for (auto& h : to)
|
||||||
|
h->fill(0);
|
||||||
for (bool inCheck : { false, true })
|
continuationHistory[inCheck][c][NO_PIECE][0]->fill(Search::CounterMovePruneThreshold - 1);
|
||||||
for (StatsType c : { NoCaptures, Captures })
|
}
|
||||||
continuationHistory[inCheck][c][NO_PIECE][0]->fill(Search::CounterMovePruneThreshold - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Thread::start_searching() wakes up the thread that will start the search
|
/// Thread::start_searching() wakes up the thread that will start the search
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
void idle_loop();
|
void idle_loop();
|
||||||
void start_searching();
|
void start_searching();
|
||||||
void wait_for_search_finished();
|
void wait_for_search_finished();
|
||||||
int best_move_count(Move move);
|
int best_move_count(Move move) const;
|
||||||
|
|
||||||
Pawns::Table pawnsTable;
|
Pawns::Table pawnsTable;
|
||||||
Material::Table materialTable;
|
Material::Table materialTable;
|
||||||
|
|
|
@ -66,7 +66,7 @@ void TranspositionTable::resize(size_t mbSize) {
|
||||||
free(mem);
|
free(mem);
|
||||||
|
|
||||||
clusterCount = mbSize * 1024 * 1024 / sizeof(Cluster);
|
clusterCount = mbSize * 1024 * 1024 / sizeof(Cluster);
|
||||||
table = static_cast<Cluster*>(aligned_ttmem_alloc(clusterCount * sizeof(Cluster), &mem));
|
table = static_cast<Cluster*>(aligned_ttmem_alloc(clusterCount * sizeof(Cluster), mem));
|
||||||
if (!mem)
|
if (!mem)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to allocate " << mbSize
|
std::cerr << "Failed to allocate " << mbSize
|
||||||
|
|
Loading…
Add table
Reference in a new issue