Exemple #1
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>();
        }
Exemple #2
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);
            });
        }
Exemple #3
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);
        }
Exemple #4
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];
                    }
                }
            }
        }
Exemple #5
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);
        }
Exemple #6
0
        /// <summary>
        /// 平手初期局面、2P(盤の上側)。
        /// </summary>
        /// <returns></returns>
        public static TedokuHistory New_HirateSyokikyokumen_2P()
        {
            TedokuHistory result = new TedokuHistoryConst(
                new List <SyElement>[] {//歩
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban13_1三)
                },                                                                           //1三
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban23_2三)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban33_3三)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban43_4三)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban53_5三)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban63_6三)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban73_7三)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban83_8三)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban93_9三)
                },
            },
                new List <SyElement>[] {//香
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban11_1一)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban91_9一)
                },
                new List <SyElement> {
                },
                new List <SyElement> {
                },
            },
                new List <SyElement>[] {//桂
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban21_2一)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban81_8一)
                },
                new List <SyElement> {
                },
                new List <SyElement> {
                },
            },
                new List <SyElement>[] {//銀
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban31_3一)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban71_7一)
                },
                new List <SyElement> {
                },
                new List <SyElement> {
                },
            },
                new List <SyElement>[] {//金
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban41_4一)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban61_6一)
                },
                new List <SyElement> {
                },
                new List <SyElement> {
                },
            },
                new List <SyElement> {//玉
                Masu_Honshogi.Query_Basho(Masu_Honshogi.nban51_5一)
            },
                new List <SyElement>[] {//飛
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban82_8二)
                },
                new List <SyElement> {
                },
            },
                new List <SyElement>[] {//角
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban22_2二)
                },
                new List <SyElement> {
                },
            }
                );

            return(result);
        }
Exemple #7
0
        /// <summary>
        /// 平手初期局面、1P(盤の下側)。
        /// </summary>
        /// <returns></returns>
        public static TedokuHistory New_HirateSyokikyokumen_1P()
        {
            TedokuHistory result = new TedokuHistoryConst(
                new List <SyElement>[] {//歩
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban17_1七)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban27_2七)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban37_3七)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban47_4七)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban57_5七)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban67_6七)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban77_7七)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban87_8七)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban97_9七)
                },
            },
                new List <SyElement>[] {//香
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban19_1九)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban99_9九)
                },
                new List <SyElement> {
                },
                new List <SyElement> {
                },
            },
                new List <SyElement>[] {//桂
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban29_2九)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban89_8九)
                },
                new List <SyElement> {
                },
                new List <SyElement> {
                },
            },
                new List <SyElement>[] {//銀
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban39_3九)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban79_7九)
                },
                new List <SyElement> {
                },
                new List <SyElement> {
                },
            },
                new List <SyElement>[] {//金
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban49_4九)
                },
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban69_6九)
                },
                new List <SyElement> {
                },
                new List <SyElement> {
                },
            },
                new List <SyElement> {//玉
                Masu_Honshogi.Query_Basho(Masu_Honshogi.nban59_5九)
            },
                new List <SyElement>[] {//飛
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban28_2八)
                },
                new List <SyElement> {
                },
            },
                new List <SyElement>[] {//角
                new List <SyElement> {
                    Masu_Honshogi.Query_Basho(Masu_Honshogi.nban88_8八)
                },
                new List <SyElement> {
                },
            }
                );

            return(result);
        }