{
Square s = pop_lsb(&b);
score += ThreatByRook[type_of(pos.piece_on(s))];
- if (type_of(pos.piece_on(s)) != PAWN)
- score += ThreatByRank * (int)relative_rank(Them, s);
+ if (type_of(pos.piece_on(s)) != PAWN && type_of(pos.piece_on(s)) != SHOGI_PAWN)
+ score += ThreatByRank * (int)relative_rank(Them, s, pos.max_rank());
}
- b = weak & attackedBy[Us][KING];
- if (b)
- score += ThreatByKing[more_than_one(b)];
+ // Bonus for king attacks on pawns or pieces which are not pawn-defended
+ if (weak & attackedBy[Us][KING])
+ score += ThreatByKing;
score += Hanging * popcount(weak & ~attackedBy[Them][ALL_PIECES]);
{
ss->staticEval = eval =
(ss-1)->currentMove != MOVE_NULL ? evaluate(pos)
- : -(ss-1)->staticEval + 2 * Eval::Tempo;
+ : -(ss-1)->staticEval + 2 * Eval::tempo_value(pos);
tte->save(posKey, VALUE_NONE, BOUND_NONE, DEPTH_NONE, MOVE_NONE,
- ss->staticEval, TT.generation());
+ ss->staticEval);
}
// Step 7. Razoring (~2 Elo)
TranspositionTable TT; // Our global transposition table
+ /// TTEntry::save saves a TTEntry
+ void TTEntry::save(Key k, Value v, Bound b, Depth d, Move m, Value ev) {
+
+ assert(d / ONE_PLY * ONE_PLY == d);
+
+ // Preserve any existing move for the same position
+ if (m || (k >> 48) != key16)
- move16 = (uint16_t)m;
++ move32 = (uint32_t)m;
+
+ // Overwrite less valuable entries
+ if ( (k >> 48) != key16
+ || d / ONE_PLY > depth8 - 4
+ || b == BOUND_EXACT)
+ {
+ key16 = (uint16_t)(k >> 48);
+ value16 = (int16_t)v;
+ eval16 = (int16_t)ev;
+ genBound8 = (uint8_t)(TT.generation8 | b);
+ depth8 = (int8_t)(d / ONE_PLY);
+ }
+ }
+
/// TranspositionTable::resize() sets the size of the transposition table,
/// measured in megabytes. Transposition table consists of a power of 2 number