Esempio n. 1
0
  // 駒得だけの評価関数
  // 手番側から見た評価値
  Value material(const Position& pos)
  {
    int v = VALUE_ZERO;

    for(auto i : SQ)
      v = v + PieceValue[pos.piece_on(i)];

    // 手駒も足しておく
    for (auto c : COLOR)
      for (auto pc = PAWN; pc < PIECE_HAND_NB; ++pc)
        v += (c == BLACK ? 1 : -1) * Value(hand_count(pos.hand_of(c), pc) * PieceValue[pc]);

    return (Value)v;
  }
Esempio n. 2
0
std::ostream& operator<<(std::ostream& os, Hand hand)
{
  for (Piece pr = PAWN; pr < PIECE_HAND_NB; ++pr)
  {
    int c = hand_count(hand, pr);
    // 0枚ではないなら出力。
    if (c != 0)
    {
      // 1枚なら枚数は出力しない。2枚以上なら枚数を最初に出力
      // PRETTY_JPが指定されているときは、枚数は後ろに表示。
      const std::string cs = (c != 1) ? std::to_string(c) : "";
      std::cout << (pretty_jp ? "" : cs) << pretty(pr) << (pretty_jp ? cs : "");
    }
  }
  return os;
}