示例#1
0
 public TedokuHistoryBuffer(
     TedokuHistory src
     )
 {
     this.fu = new List <SyElement>[] {
         src.Fu___[0],
         src.Fu___[1],
         src.Fu___[2],
         src.Fu___[3],
         src.Fu___[4],
         src.Fu___[5],
         src.Fu___[6],
         src.Fu___[7],
         src.Fu___[8],
     };
     this.kyo = new List <SyElement>[] {
         src.Kyo__[0],
         src.Kyo__[1],
         src.Kyo__[2],
         src.Kyo__[3],
     };
     this.kei = new List <SyElement>[] {
         src.Kei__[0],
         src.Kei__[1],
         src.Kei__[2],
         src.Kei__[3],
     };
     this.gin = new List <SyElement>[] {
         src.Gin__[0],
         src.Gin__[1],
         src.Gin__[2],
         src.Gin__[3],
     };
     this.kin = new List <SyElement>[] {
         src.Kin__[0],
         src.Kin__[1],
         src.Kin__[2],
         src.Kin__[3],
     };
     this.gyoku = src.Gyoku;
     this.hisya = new List <SyElement>[] {
         src.Hisya[0],
         src.Hisya[1],
         src.Hisya[2],
         src.Hisya[3],
     };
     this.kaku = new List <SyElement>[] {
         src.Kaku_[0],
         src.Kaku_[1],
         src.Kaku_[2],
         src.Kaku_[3],
     };
 }
示例#2
0
        /// <summary>
        /// 棋譜を新規作成するときに使うコンストラクター。
        /// </summary>
        public SkyBuffer(Playerside kaisiPside, int temezumi)
        {
            switch (kaisiPside)
            {
            case Playerside.P1: this.tedokuHistory = TedokuHistoryConst.New_HirateSyokikyokumen_1P(); break;

            case Playerside.P2: this.tedokuHistory = TedokuHistoryConst.New_HirateSyokikyokumen_2P(); break;

            default: break;
            }

            this.kaisiPside = kaisiPside;
            this.temezumi   = temezumi;
            this.starlights = new List <IMoveHalf>();
        }
示例#3
0
        /// <summary>
        /// クローンを作ります。
        /// </summary>
        /// <param name="src"></param>
        public SkyBuffer(Sky src)
        {
            // 手得ヒストリーのクローン
            this.tedokuHistory = TedokuHistoryConst.New_Clone(src.TedokuHistory);

            // 手番のクローン
            this.kaisiPside = src.KaisiPside;
            this.temezumi   = src.Temezumi;

            // 星々のクローン
            this.starlights = new List <IMoveHalf>();
            src.Foreach_Starlights((Finger finger, IMoveHalf light, ref bool toBreak) =>
            {
                this.starlights.Add(light);
            });
        }
示例#4
0
        /// <summary>
        /// 手得ヒストリーを進めます。
        /// </summary>
        /// <param name="src"></param>
        /// <param name="komasyurui"></param>
        /// <param name="index"></param>
        /// <param name="masu"></param>
        /// <returns></returns>
        public static TedokuHistory NewInstance_AppendSasitamasu(TedokuHistory src, PieceType komasyurui, int index, SyElement masu)
        {
            TedokuHistoryConst result = (TedokuHistoryConst)TedokuHistoryConst.New_Clone(src);

            // 持駒を打った場合はどうする?
            switch (komasyurui)
            {
            case PieceType.PP:                                      //どの歩?
            case PieceType.P: result.Fu___[index].Add(masu); break; //suji-1=index

            case PieceType.PL:
            case PieceType.L: result.Kyo__[index].Add(masu); break;

            case PieceType.PN:
            case PieceType.N: result.Kei__[index].Add(masu); break;

            case PieceType.PS:
            case PieceType.S: result.Gin__[index].Add(masu); break;

            case PieceType.G: result.Kin__[index].Add(masu); break;

            case PieceType.K: result.Gyoku.Add(masu); break;

            case PieceType.PR:
            case PieceType.R: result.Hisya[index].Add(masu); break;

            case PieceType.PB:
            case PieceType.B: result.Kaku_[index].Add(masu); break;

            default: break;
            }

#if DEBUG
            //
            // ログ出力
            //
            Util_TedokuHistory.WriteLog(EngineConf.GetResourceFullPath("N19TedokuKeisanLog"), result);
#endif

            return(result);
        }
示例#5
0
        /// <summary>
        /// クローンを作ります。
        /// </summary>
        /// <param name="src"></param>
        private SkyConst(Sky src, bool toReversePlayerside, int update_temezumi_orMinus1, Finger[] finger1, IMoveHalf[] light1,
                         //
                         // 手得計算
                         //
                         PieceType tedokuKeisan_komasyurui, int tedokukeisan_index, SyElement tedokukeisan_sasitamasu)
        {
            Debug.Assert(src.Count == 40, $"本将棋とみなしてテスト中。sky.Starlights.Count=[{src.Count}]");//将棋の駒の数

            if (tedokuKeisan_komasyurui == PieceType.None)
            {
                //----------------------------------------
                // 手得計算のヒストリーを作らない場合
                //----------------------------------------

                // 手得ヒストリーのクローン
                this.tedokuHistory = TedokuHistoryConst.New_Clone(src.TedokuHistory);
            }
            else
            {
                //----------------------------------------
                // 手得計算のヒストリーを作る場合
                //----------------------------------------

                // 手駒ヒストリーへの追加
                this.tedokuHistory = TedokuHistoryConst.NewInstance_AppendSasitamasu(
                    src.TedokuHistory,
                    tedokuKeisan_komasyurui,
                    tedokukeisan_index,
                    tedokukeisan_sasitamasu
                    );
            }


            // 手番のクローン
            if (toReversePlayerside)
            {
                this.kaisiPside = Conv_Playerside.Reverse(src.KaisiPside);
            }
            else
            {
                this.kaisiPside = src.KaisiPside;
            }

            // 手目済み
            if (-1 == update_temezumi_orMinus1)
            {
                // そのまま
                this.temezumi = src.Temezumi;
            }
            else
            {
                // 上書き更新
                this.temezumi = update_temezumi_orMinus1;
            }

            // 星々のクローン
            this.starlights = new List <IMoveHalf>();
            src.Foreach_Starlights((Finger finger2, IMoveHalf light2, ref bool toBreak2) =>
            {
                this.starlights.Add(light2);
            });

            //
            // 追加分があれば。
            //
            for (int i = 0; i < finger1.Length; i++)
            {
                if (finger1[i] != Fingers.Error_1)
                {
                    if (this.starlights.Count == (int)finger1[i])
                    {
                        // オブジェクトを追加します。
                        this.starlights.Add(light1[i]);
                    }
                    else if (this.starlights.Count + 1 <= (int)finger1[i])
                    {
                        // エラー
                        Debug.Assert((int)finger1[i] < this.starlights.Count, $"要素の個数より2大きいインデックスを指定しました。 インデックス[{(int)finger1[i]}] 要素の個数[{this.starlights.Count}]");

                        throw new Exception($"{this.GetType().Name}#SetStarPos: リストの要素より2多いインデックスを指定されましたので、追加しません。starIndex=[{finger1[i]}] / this.stars.Count=[{this.starlights.Count}]");
                    }
                    else
                    {
                        this.starlights[(int)finger1[i]] = light1[i];
                    }
                }
            }
        }
示例#6
0
        /// <summary>
        /// 平手初期局面、2P(盤の上側)。
        /// </summary>
        /// <returns></returns>
        public static TedokuHistory New_Clone(TedokuHistory src)
        {
            // 歩のリスト配列
            List <SyElement>[] fu = new List <SyElement> [9];
            for (int i = 0; i < 9; i++)
            {
                fu[i] = new List <SyElement>(src.Fu___[i]);
            }

            // 香のリスト配列
            List <SyElement>[] kyo = new List <SyElement> [4];
            for (int i = 0; i < 4; i++)
            {
                kyo[i] = new List <SyElement>(src.Kyo__[i]);
            }

            // 桂のリスト配列
            List <SyElement>[] kei = new List <SyElement> [4];
            for (int i = 0; i < 4; i++)
            {
                kei[i] = new List <SyElement>(src.Kei__[i]);
            }

            // 銀のリスト配列
            List <SyElement>[] gin = new List <SyElement> [4];
            for (int i = 0; i < 4; i++)
            {
                gin[i] = new List <SyElement>(src.Gin__[i]);
            }

            // 金のリスト配列
            List <SyElement>[] kin = new List <SyElement> [4];
            for (int i = 0; i < 4; i++)
            {
                kin[i] = new List <SyElement>(src.Kin__[i]);
            }

            // 飛のリスト配列
            List <SyElement>[] hisya = new List <SyElement> [2];
            for (int i = 0; i < 2; i++)
            {
                hisya[i] = new List <SyElement>(src.Hisya[i]);
            }

            // 角のリスト配列
            List <SyElement>[] kaku = new List <SyElement> [2];
            for (int i = 0; i < 2; i++)
            {
                kaku[i] = new List <SyElement>(src.Kaku_[i]);
            }

            TedokuHistory result = new TedokuHistoryConst(
                fu,        //歩
                kyo,       //香
                kei,       //桂
                gin,       //銀
                kin,       //金
                src.Gyoku, //玉
                hisya,     //飛
                kaku       //角
                );

            return(result);
        }
示例#7
0
        /// <summary>
        /// 作りかけ。
        /// </summary>
        /// <param name="filepath"></param>
        /// <param name="tedokuHistory"></param>
        public static void WriteLog(string filepath, TedokuHistory tedokuHistory)
        {
            StringBuilder sb = new StringBuilder();
            int           i;

            //
            // 歩
            //
            i = 0;
            foreach (List <SyElement> list in tedokuHistory.Fu___)
            {
                sb.Append("Fu___[");
                sb.Append(string.Format("{0,2:0}", i));
                sb.Append("] ");
                foreach (SyElement masu in list)
                {
                    sb.Append(Conv_Sy.Query_Word(masu.Bitfield));
                    sb.Append(",");
                }
                sb.AppendLine();
                i++;
            }

            //
            // 香
            //
            i = 0;
            foreach (List <SyElement> list in tedokuHistory.Kyo__)
            {
                sb.Append("Kyo__[");
                sb.Append(string.Format("{0,2:0}", i));
                sb.Append("] ");
                foreach (SyElement masu in list)
                {
                    sb.Append(Conv_Sy.Query_Word(masu.Bitfield));
                    sb.Append(",");
                }
                sb.AppendLine();
                i++;
            }

            //
            // 桂
            //
            i = 0;
            foreach (List <SyElement> list in tedokuHistory.Kei__)
            {
                sb.Append("Kei__[");
                sb.Append(string.Format("{0,2:0}", i));
                sb.Append("] ");
                foreach (SyElement masu in list)
                {
                    sb.Append(Conv_Sy.Query_Word(masu.Bitfield));
                    sb.Append(",");
                }
                sb.AppendLine();
                i++;
            }


            //
            // 銀
            //
            i = 0;
            foreach (List <SyElement> list in tedokuHistory.Gin__)
            {
                sb.Append("Gin__[");
                sb.Append(string.Format("{0,2:0}", i));
                sb.Append("] ");
                foreach (SyElement masu in list)
                {
                    sb.Append(Conv_Sy.Query_Word(masu.Bitfield));
                    sb.Append(",");
                }
                sb.AppendLine();
                i++;
            }

            //
            // 金
            //
            i = 0;
            foreach (List <SyElement> list in tedokuHistory.Kin__)
            {
                sb.Append("Kin__[");
                sb.Append(string.Format("{0,2:0}", i));
                sb.Append("] ");
                foreach (SyElement masu in list)
                {
                    sb.Append(Conv_Sy.Query_Word(masu.Bitfield));
                    sb.Append(",");
                }
                sb.AppendLine();
                i++;
            }

            //
            // 玉
            //
            {
                sb.Append("Gyoku[--] ");
                foreach (SyElement masu in tedokuHistory.Gyoku)
                {
                    sb.Append(Conv_Sy.Query_Word(masu.Bitfield));
                    sb.Append(",");
                }
                sb.AppendLine();
            }

            //
            // 飛
            //
            i = 0;
            foreach (List <SyElement> list in tedokuHistory.Hisya)
            {
                sb.Append("Hisya[");
                sb.Append(string.Format("{0,2:0}", i));
                sb.Append("] ");
                foreach (SyElement masu in list)
                {
                    sb.Append(Conv_Sy.Query_Word(masu.Bitfield));
                    sb.Append(",");
                }
                sb.AppendLine();
                i++;
            }

            //
            // 角
            //
            i = 0;
            foreach (List <SyElement> list in tedokuHistory.Kaku_)
            {
                sb.Append("Kaku_[");
                sb.Append(string.Format("{0,2:0}", i));
                sb.Append("] ");
                foreach (SyElement masu in list)
                {
                    sb.Append(Conv_Sy.Query_Word(masu.Bitfield));
                    sb.Append(",");
                }
                sb.AppendLine();
                i++;
            }

#if DEBUG
            File.WriteAllText(filepath, sb.ToString());
#endif
        }