From 1d0159075e916c738760b788d605b71b3736cb7c Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Tue, 26 Apr 2011 14:10:02 +0200 Subject: [PATCH] Use probe() as name for looking up into an hash table No functional change. Signed-off-by: Marco Costalba --- src/material.cpp | 2 +- src/pawns.cpp | 2 +- src/search.cpp | 10 +++++----- src/tt.cpp | 4 ++-- src/tt.h | 6 +++--- src/uci.cpp | 12 ++++-------- 6 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/material.cpp b/src/material.cpp index add0f32b..19a334ba 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -98,7 +98,7 @@ MaterialInfoTable::~MaterialInfoTable() { delete funcs; } MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos) const { Key key = pos.get_material_key(); - MaterialInfo* mi = find(key); + MaterialInfo* mi = probe(key); // If mi->key matches the position's material hash key, it means that we // have analysed this material configuration before, and we can simply diff --git a/src/pawns.cpp b/src/pawns.cpp index 59c05c73..587c9b95 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -75,7 +75,7 @@ PawnInfo* PawnInfoTable::get_pawn_info(const Position& pos) const { assert(pos.is_ok()); Key key = pos.get_pawn_key(); - PawnInfo* pi = find(key); + PawnInfo* pi = probe(key); // If pi->key matches the position's pawn hash key, it means that we // have analysed this pawn structure before, and we can simply return diff --git a/src/search.cpp b/src/search.cpp index 0318d631..eb7666af 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -736,7 +736,7 @@ namespace { excludedMove = ss->excludedMove; posKey = excludedMove ? pos.get_exclusion_key() : pos.get_key(); - tte = TT.retrieve(posKey); + tte = TT.probe(posKey); ttMove = tte ? tte->move() : MOVE_NONE; // At PV nodes we check for exact scores, while at non-PV nodes we check for @@ -872,7 +872,7 @@ namespace { ss->skipNullMove = false; ttMove = ss->bestMove; - tte = TT.retrieve(posKey); + tte = TT.probe(posKey); } split_point_start: // At split points actual search starts from here @@ -1277,7 +1277,7 @@ split_point_start: // At split points actual search starts from here // Transposition table lookup. At PV nodes, we don't use the TT for // pruning, but only for move ordering. - tte = TT.retrieve(pos.get_key()); + tte = TT.probe(pos.get_key()); ttMove = (tte ? tte->move() : MOVE_NONE); if (!PvNode && tte && ok_to_use_TT(tte, ttDepth, beta, ss->ply)) @@ -1987,7 +1987,7 @@ split_point_start: // At split points actual search starts from here pos.do_move(pv[0], *st++); - while ( (tte = TT.retrieve(pos.get_key())) != NULL + while ( (tte = TT.probe(pos.get_key())) != NULL && tte->move() != MOVE_NONE && pos.move_is_legal(tte->move()) && ply < PLY_MAX @@ -2017,7 +2017,7 @@ split_point_start: // At split points actual search starts from here do { k = pos.get_key(); - tte = TT.retrieve(k); + tte = TT.probe(k); // Don't overwrite existing correct entries if (!tte || tte->move() != pv[ply]) diff --git a/src/tt.cpp b/src/tt.cpp index d18b512c..14217e8d 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -117,11 +117,11 @@ void TranspositionTable::store(const Key posKey, Value v, ValueType t, Depth d, } -/// TranspositionTable::retrieve() looks up the current position in the +/// TranspositionTable::probe() looks up the current position in the /// transposition table. Returns a pointer to the TTEntry or NULL if /// position is not found. -TTEntry* TranspositionTable::retrieve(const Key posKey) const { +TTEntry* TranspositionTable::probe(const Key posKey) const { uint32_t posKey32 = posKey >> 32; TTEntry* tte = first_entry(posKey); diff --git a/src/tt.h b/src/tt.h index 69cdad0c..03147bf1 100644 --- a/src/tt.h +++ b/src/tt.h @@ -104,7 +104,7 @@ public: void set_size(size_t mbSize); void clear(); void store(const Key posKey, Value v, ValueType type, Depth d, Move m, Value statV, Value kingD); - TTEntry* retrieve(const Key posKey) const; + TTEntry* probe(const Key posKey) const; void new_search(); TTEntry* first_entry(const Key posKey) const; void refresh(const TTEntry* tte) const; @@ -163,8 +163,8 @@ struct SimpleHash { virtual ~SimpleHash() { delete [] entries; } - Entry* find(Key key) const { return entries + ((uint32_t)key & (HashSize - 1)); } - void prefetch(Key key) const { ::prefetch((char*)find(key)); } + Entry* probe(Key key) const { return entries + ((uint32_t)key & (HashSize - 1)); } + void prefetch(Key key) const { ::prefetch((char*)probe(key)); } protected: Entry* entries; diff --git a/src/uci.cpp b/src/uci.cpp index 5a302a8d..39270c6f 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -182,8 +182,7 @@ namespace { string token; SearchLimits limits; - Move searchMoves[MAX_MOVES] = { MOVE_NONE }; - Move* cur = searchMoves; + Move searchMoves[MAX_MOVES], *cur = searchMoves; int time[] = { 0, 0 }, inc[] = { 0, 0 }; while (up >> token) @@ -209,19 +208,16 @@ namespace { else if (token == "movetime") up >> limits.maxTime; else if (token == "searchmoves") - { while (up >> token) *cur++ = move_from_uci(pos, token); - - *cur = MOVE_NONE; - } } - assert(pos.is_ok()); - + *cur = MOVE_NONE; limits.time = time[pos.side_to_move()]; limits.increment = inc[pos.side_to_move()]; + assert(pos.is_ok()); + return think(pos, limits, searchMoves); } -- 2.39.2