/// <summary> /// SPositionからApery用のハッシュキーを取得 /// </summary> /// <param name="position"></param> /// <returns></returns> private static ulong GetKey(SPosition pos) { ulong key = 0; // 盤上の駒 for (AperySquare ap = AperySquare.I9; ap < AperySquare.SquareNum; ap++) { int sq = Square.Make(ap.FileOf(), ap.RankOf()); Piece piece = pos.GetPiece(sq); if (piece != Piece.NoPiece) { int index = (int)piece.ConvAperyPiece(); key ^= AperyBook.ZobPiece[index][(int)ap]; } } // 持ち駒 for (PieceType pt = PieceType.FU; pt < PieceType.King; pt++) { int num = pos.GetHand(pos.Turn, pt); key ^= AperyBook.ZobHand[(int)pt - 1][num]; } if (pos.Turn == PlayerColor.White) { key ^= AperyBook.ZobTurn; } return(key); }
private static int FileOf(this AperySquare sq) { return(8 - ((int)sq / 9)); }
private static int RankOf(this AperySquare sq) { return((int)sq % 9); }