Пример #1
0
        /// <summary>
        /// 定跡局面の中で、勝率が一番高い指し手を返すぜ☆(^▽^)
        /// </summary>
        /// <param name="ky"></param>
        /// <returns>なければ投了☆</returns>
        public Move GetSasite_Winest(Kyokumen ky, out float out_bestSyoritu)
        {
            Move bestSasite = Move.Toryo;

            out_bestSyoritu = float.MinValue;
            int minMake = int.MaxValue;

            //Util_Machine.Assert_KyokumenSeigosei_SabunKosin("ゲット指し手 #鯨",true);
            ulong hash = ky.KyokumenHash.Value;

            if (this.KyItems.ContainsKey(hash))
            {
                SeisekiKyokumen josekyKy = this.KyItems[hash];
                foreach (KeyValuePair <Move, SeisekiMove> entry in josekyKy.SsItems)
                {
                    if (out_bestSyoritu < entry.Value.GetSyoritu())// 勝率が高い指し手を選ぶぜ☆(^▽^)
                    {
                        bestSasite      = entry.Key;
                        out_bestSyoritu = entry.Value.GetSyoritu();
                        minMake         = entry.Value.Make;
                    }
                    else if (out_bestSyoritu == entry.Value.GetSyoritu() && //勝率が同じ場合は、
                             entry.Value.Make < minMake                     //負けが少ない指し手を選ぶぜ☆(^▽^)
                             )
                    {
                        bestSasite      = entry.Key;
                        out_bestSyoritu = entry.Value.GetSyoritu();
                        minMake         = entry.Value.Make;
                    }
                }
            }

            return(bestSasite);
        }
Пример #2
0
        /// <summary>
        /// データを追加するぜ☆(^▽^) 指しながら定跡を追加していくときだぜ☆
        /// </summary>
        /// <param name="ky_before"></param>
        public SeisekiKyokumen AddMove(string kyFen_before, ulong kyHash_before, Option <Phase> optionalPhaseBeforeMove, Move bestSasite, int version, int kati, int hikiwake, int make)
        {
            SeisekiKyokumen josekiKy = this.Parse_AddKyLine(kyFen_before, kyHash_before, optionalPhaseBeforeMove);

            josekiKy.AddSasite(bestSasite, version, kati, hikiwake, make);
            return(josekiKy);
        }
Пример #3
0
        public void Parse(bool isSfen, string[] lines, StringBuilder syuturyoku)
        {
            this.Clear();
            Kyokumen        ky2 = new Kyokumen();
            int             caret;
            SeisekiKyokumen josekiKy = null;

            int gyoBango = 1;

            foreach (string commandline in lines)
            {
                caret = 0;
                if (caret == commandline.IndexOf("fen ", caret))// fen で始まれば局面データ☆(^▽^)
                {
                    // キャレットは進めずに続行だぜ☆(^▽^)
                    if (!ky2.ParsePositionvalue(isSfen, commandline, ref caret, false, false, out string moves, syuturyoku))
                    {
                        string msg = $"パースに失敗だぜ☆(^~^)! #寒鰤 定跡ファイル解析失敗 {gyoBango}]行目";
                        syuturyoku.AppendLine(msg);
                        Logger.Flush(syuturyoku.ToString());
                        syuturyoku.Clear();
                        throw new Exception(msg);
                    }

                    {
                        ky2.Tekiyo(false, syuturyoku); // とりあえず全部作り直し☆(^~^)ルールは変わらないものとするぜ☆(^~^)
                        //ky2.KyokumenHash = ky2.CreateKyokumenHash();//必要最低限、ハッシュだけ適用しておくぜ☆(^▽^)
                    }

                    josekiKy = this.Parse_AddKyLine(commandline, ky2.KyokumenHash.Value, ky2.CurrentOptionalPhase);
                }
                else if (commandline.Trim().Length < 1)
                {
                    // 空行は無視☆
                    // 半角空白とか、全角空白とか、タブとか 入れてるやつは考慮しないぜ☆(^~^)!
                }
                else
                {
                    // それ以外は手筋☆(^▽^)
                    if (null == josekiKy)
                    {
                        throw new Exception("定跡ファイル解析失敗 定跡局面の指定なし☆");
                    }

                    josekiKy.AddSasite(ky2, commandline, syuturyoku);
                }

                gyoBango++;
            }
        }
Пример #4
0
        /// <summary>
        /// データを追加するぜ☆(^▽^)
        /// </summary>
        /// <param name="fen_before">指す前の局面の改造fen</param>
        /// <param name="kyHash_before">指す前の局面のハッシュ</param>
        /// <param name="optionalPhaseBeforeMove">指す前の局面の手番</param>
        /// <returns></returns>
        public SeisekiKyokumen Parse_AddKyLine(string fen_before, ulong kyHash_before, Option <Phase> optionalPhaseBeforeMove)
        {
            SeisekiKyokumen josekiKy;

            if (this.KyItems.ContainsKey(kyHash_before))
            {
                // 既存☆
                josekiKy = this.KyItems[kyHash_before];
            }
            else
            {
                josekiKy = new SeisekiKyokumen(fen_before, optionalPhaseBeforeMove, this);
                this.KyItems.Add(kyHash_before, josekiKy);
                this.Edited = true;
            }

            return(josekiKy);
        }
Пример #5
0
        /// <summary>
        /// 定跡局面の中で、勝率が一番高い指し手を返すぜ☆(^▽^)
        /// </summary>
        /// <param name="ky"></param>
        /// <returns>指し手が登録されていれば真☆</returns>
        public bool GetSasite_Syoritu(Kyokumen ky, Move ss, out float out_syoritu)
        {
            out_syoritu = float.MinValue;

            ulong hash = ky.KyokumenHash.Value;

            if (this.KyItems.ContainsKey(hash))
            {
                SeisekiKyokumen josekyKy = this.KyItems[hash];
                if (josekyKy.SsItems.ContainsKey(ss))
                {
                    SeisekiMove seSs = josekyKy.SsItems[ss];
                    out_syoritu = seSs.GetSyoritu();
                    return(true);
                }
            }

            return(false);
        }
Пример #6
0
        public static bool TryParse(Kyokumen ky, string commandline, ref int caret, out SeisekiMove out_result, SeisekiKyokumen owner, StringBuilder syuturyoku)
        {
            bool successfule = true;

            // 指し手☆
            if (!Med_Parser.TryFenMove(Option_Application.Optionlist.USI, commandline, ref caret, ky.Sindan, out Move ss))
            {
                successfule = false;
            }

            // 応手☆
            if (!Med_Parser.TryFenMove(Option_Application.Optionlist.USI, commandline, ref caret, ky.Sindan, out Move ss2))
            {
                successfule = false;
            }

            // バージョン(これは無いこともある☆ 評価値のパーサーを使いまわし)
            if (!Conv_Hyokati.TryParse(commandline, ref caret, out int version, syuturyoku))
            {
                version = 0;
                //successfule = false;
            }

            // 勝った回数(評価値のパーサーを使いまわし)
            if (!Conv_Hyokati.TryParse(commandline, ref caret, out int kati, syuturyoku))
            {
                successfule = false;
            }

            // 引き分けた回数
            if (!Conv_Hyokati.TryParse(commandline, ref caret, out int hikiwake, syuturyoku))
            {
                successfule = false;
            }

            // 負けた回数
            if (!Conv_Hyokati.TryParse(commandline, ref caret, out int make, syuturyoku))
            {
                successfule = false;
            }

            out_result = new SeisekiMove(ss, ss2, version, kati, hikiwake, make, owner);
            return(successfule);
        }
Пример #7
0
 public SeisekiMove(Move move, Move ousyu, int version, int kati, int hikiwake, int make, SeisekiKyokumen owner)
 {
     this.Owner    = owner;
     this.Move     = move;
     this.Ousyu    = ousyu;
     this.Version  = version;
     this.Kati     = kati;
     this.Hikiwake = hikiwake;
     this.Make     = make;
 }