/// <summary> /// Gikouの指し手に変換する /// </summary> /// <param name="move"></param> /// <returns></returns> private static GikouMove ConvertGikouMove(this SBookMove move) { GikouMove gikouMove = new GikouMove(); if (move.Turn == PlayerColor.White) { gikouMove.to = (uint)((move.To.FileOf() * 9) + (8 - move.To.RankOf())); gikouMove.from = (uint)((move.From.FileOf() * 9) + (8 - move.From.RankOf())); gikouMove.promotion = move.Promotion ? 1U : 0; gikouMove.drop = move.MoveType.HasFlag(MoveType.DropFlag) ? 1U : 0; gikouMove.piece = (uint)move.Piece.Opp(); gikouMove.capture = (uint)move.CapturePiece.Opp(); } else { gikouMove.to = (uint)((8 - move.To.FileOf()) * 9 + move.To.RankOf()); gikouMove.from = (uint)((8 - move.From.FileOf()) * 9 + move.From.RankOf()); gikouMove.promotion = move.Promotion ? 1U : 0; gikouMove.drop = move.MoveType.HasFlag(MoveType.DropFlag) ? 1U : 0; gikouMove.piece = (uint)move.Piece; gikouMove.capture = (uint)move.CapturePiece; } return(gikouMove); }
/// <summary> /// 追加 /// </summary> public void Add(long key, uint frequency, uint win_count, int score, GikouMove move) { GikouBookEntry entry = new GikouBookEntry() { Key = key, Move = move, Frequency = frequency, WinCount = win_count, Score = score, }; if (!this.entries.ContainsKey(key)) { // ない場合 this.entries.Add(key, new List <GikouBookEntry>()); } this.entries[key].Add(entry); }
/// <summary> /// 内部指し手に変換 /// </summary> /// <param name="gmove"></param> /// <returns></returns> private static MoveData ConvertMove(PlayerColor color, GikouMove gmove) { MoveData move = new MoveData(); if (color == PlayerColor.White) { move.ToSquare = Square.Make((int)(gmove.to / 9), (int)(8 - (gmove.to % 9))); move.FromSquare = Square.Make((int)(gmove.from / 9), (int)(8 - (gmove.from % 9))); move.MoveType = gmove.promotion == 1 ? MoveType.Promotion : MoveType.Normal; if (gmove.drop == 1) { move.MoveType |= MoveType.DropFlag; } move.Piece = (Piece)gmove.piece | Piece.WhiteFlag; move.CapturePiece = ((Piece)gmove.capture).Opp(); } else { move.ToSquare = Square.Make((int)(8 - (gmove.to / 9)), (int)gmove.to % 9); move.FromSquare = Square.Make((int)(8 - (gmove.from / 9)), (int)gmove.from % 9); move.MoveType = gmove.promotion == 1 ? MoveType.Promotion : MoveType.Normal; if (gmove.drop == 1) { move.MoveType |= MoveType.DropFlag; } move.Piece = (Piece)gmove.piece; move.CapturePiece = (Piece)gmove.capture; } if (move.ToSquare < 0 || move.FromSquare < 0) { Console.WriteLine("???"); } return(move); }