Exemplo n.º 1
0
int MvvLva(POS *p, int move) {

  // Captures

  if (p->pc[Tsq(move)] != NO_PC)
    return TpOnSq(p, Tsq(move)) * 6 + 5 - TpOnSq(p, Fsq(move));

  // Non-capturing promotions
  
  if (IsProm(move)) return PromType(move) - 5;

  return 5;
}
Exemplo n.º 2
0
void UpdateHistory(POS *p, int last_move, int move, int depth, int ply) {

  // Don't update stuff used for move ordering if a move changes material balance

  if (p->pc[Tsq(move)] != NO_PC || IsProm(move) || MoveType(move) == EP_CAP)
    return;

  // Asserts suggested by Ferdinand Mosca because history[] would overflow
  // if p->pc[Fsq(move)] == NO_PC.  If they ever fire, either move or board 
  // data are corrupt.

  assert(p->pc[Fsq(move)] != NO_PC);  // To detect no_pc
  assert(p->pc[Fsq(move)] <= NO_PC);  // To detect beyond no_pc for deeper examination 

  // Increment history counter

  history[p->pc[Fsq(move)]][Tsq(move)] += 2 * depth * depth;

  // Prevent history counters from growing too high

  if (history[p->pc[Fsq(move)]][Tsq(move)] > HIST_LIMIT)
     TrimHistory();

  // Update refutation table, saving new move in the table indexed
  // by the coordinates of last move. last_move == 0 is a null move,
  // special case of last_move == -1 denotes situations when updating
  // refutation table is switched off: at root or in QuiesceFlee()

  if (last_move >= 0)
     refutation[Fsq(last_move)][Tsq(last_move)] = move;

  // Update killer moves, taking care that they are different

  if (move != killer[ply][0]) {
    killer[ply][1] = killer[ply][0];
    killer[ply][0] = move;
  }
}
Exemplo n.º 3
0
int sHistory::MoveChangesMaterialBalance(sPosition *p, int move)
{
    if (p->pc[Tsq(move)] != NO_PC || IsProm(move) || MoveType(move) == EP_CAP) return 1;
	return 0;
}