Beispiel #1
0
        /// <summary>
        /// これが通称【水際のいんちきプログラム】なんだぜ☆
        /// 必要により、【成り】の指し手を追加します。
        /// </summary>
        public static void Add_KomaBETUAllNariMoves(
            Maps_OneAndMulti <Finger, IMove> komaBETUAllMoves,
            Finger figKoma,
            RO_Star srcKoma,
            RO_Star dstKoma
            )
        {
            bool isPromotionable;

            if (!Util_Sasu269.IsPromotionable(out isPromotionable, srcKoma, dstKoma))
            {
                goto gt_EndMethod;
            }

            // 成りの資格があれば、成りの指し手を作ります。
            if (isPromotionable)
            {
                //MessageBox.Show($"成りの資格がある駒がありました。 src=[{srcKoma.Masu.Word}][{srcKoma.Syurui}]");

                IMove move = new RO_Starbeam(
                    //figKoma,//駒
                    srcKoma,// 移動元
                    new RO_Star(
                        dstKoma.Pside,
                        dstKoma.Masu,
                        Util_Komasyurui14.ToNariCase(dstKoma.Komasyurui) //強制的に【成り】に駒の種類を変更
                        ),                                               // 移動先
                    PieceType.None                                       //取った駒不明
                    );

                // TODO: 一段目の香車のように、既に駒は成っている場合があります。無い指し手だけ追加するようにします。
                komaBETUAllMoves.AddNotOverwrite(figKoma, move);
            }

gt_EndMethod:
            ;
        }
Beispiel #2
0
        /// <summary>
        /// これが通称【水際のいんちきプログラム】なんだぜ☆
        /// 必要により、【成り】の指し手を追加します。
        /// </summary>
        public static Dictionary <string, SasuEntry> CreateNariMove(
            SkyConst src_Sky,
            Dictionary <string, SasuEntry> a_moveBetuEntry
            )
        {
            //----------------------------------------
            // 『進める駒』と、『移動先升』
            //----------------------------------------
            Dictionary <string, SasuEntry> result_komabetuEntry = new Dictionary <string, SasuEntry>();

            try
            {
                Dictionary <string, IMove> newMoveList = new Dictionary <string, IMove>();

                foreach (KeyValuePair <string, SasuEntry> entry in a_moveBetuEntry)
                {
                    //
                    // ・移動元の駒
                    // ・移動先の駒
                    //
                    RO_Star srcKoma = Util_Starlightable.AsKoma(entry.Value.NewMove.LongTimeAgo);
                    RO_Star dstKoma = Util_Starlightable.AsKoma(entry.Value.NewMove.Now);

                    // 成りができる動きなら真。
                    bool isPromotionable;
                    if (!Util_Sasu269.IsPromotionable(out isPromotionable, srcKoma, dstKoma))
                    {
                        // エラー
                        goto gt_Next1;
                    }

                    if (isPromotionable)
                    {
                        IMove move = new RO_Starbeam(
                            srcKoma,// 移動元
                            new RO_Star(
                                dstKoma.Pside,
                                dstKoma.Masu,
                                Util_Komasyurui14.ToNariCase(dstKoma.Komasyurui) //強制的に【成り】に駒の種類を変更
                                ),                                               // 移動先
                            PieceType.None                                       //取った駒不明
                            );

                        // TODO: 一段目の香車のように、既に駒は成っている場合があります。無い指し手だけ追加するようにします。
                        string moveStr = ConvMoveStrSfen.ToMoveStrSfen(move);//重複防止用のキー
                        if (!newMoveList.ContainsKey(moveStr))
                        {
                            newMoveList.Add(moveStr, move);
                        }
                    }

gt_Next1:
                    ;
                }

                //hubNode.Foreach_ChildNodes((string key, Node<Starbeamable, KyokumenWrapper> nextNode, ref bool toBreak) =>
                //{
                //});


                // 新しく作った【成り】の指し手を追加します。
                foreach (IMove newMove in newMoveList.Values)
                {
                    // 指す前の駒
                    RO_Star sasumaenoKoma = Util_Starlightable.AsKoma(newMove.LongTimeAgo);

                    // 指した駒
                    RO_Star sasitaKoma = Util_Starlightable.AsKoma(newMove.Now);

                    // 指す前の駒を、盤上のマス目で指定
                    Finger figSasumaenoKoma = Util_Sky_FingersQuery.InMasuNow(src_Sky,
                                                                              sasumaenoKoma.Masu).ToFirst();

                    string moveStr = ConvMoveStrSfen.ToMoveStrSfen(newMove);

                    if (!result_komabetuEntry.ContainsKey(moveStr))
                    {
                        // 指し手が既存でない局面だけを追加します。

                        // 『進める駒』と、『移動先升』
                        result_komabetuEntry.Add(moveStr, new SasuEntry(newMove, figSasumaenoKoma, sasitaKoma.Masu, true));
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"Convert04.cs#AddNariMoveでエラー。:{ex.GetType().Name}:{ex.Message}");
            }

            return(result_komabetuEntry);
        }