Example #1
0
        /// <summary>
        /// 移動元の盤の升から、自分の駒を取るぜ☆(^▽^)
        /// </summary>
        /// <returns></returns>
        public static bool TryFail_SrcOff(
            Move ss,
            Masu ms_t0,
            Piece km_t0,
            Motigoma mk_t0,
            Masu ms_t1 // 移動先升
#if DEBUG
            , FenSyurui f
            , IDebugMojiretu dbg_reigai
#endif
            )
        {
            //────────────────────────────────────────
            // T1   [1]  移動元に 手番の駒 が在る
            //────────────────────────────────────────

            //────────────────────────────────────────
            // T1   [遷移]    移動元の 手番の駒 を除外する
            //────────────────────────────────────────
            {
                // TODO: 駒割りを評価値減らすならここだぜ☆(^~^)

                // FIXME: ここに問題のコードがあった★★★★★★★★★★★★★★★★★★★
            }

            //DoMove1( isSfen, ss, ssType, ref konoTeme, syuturyoku, out gt_EndMethod);


            // ローカル変数はグローバル変数に移動した。
            {
                // この下の HerasuBanjoKoma で指し手件数が動くようだ。

                // 盤上はこのステップが多い
                Debug.Assert(Conv_Koma.IsOk(km_t0), "km_t0 can not remove");
                if (PureMemory.gky_ky.shogiban.TryFail_TorinozokuKoma(
                        ms_t0, km_t0,
                        ms_t1, // (2017-05-02 22:19 Add)移動先の升(将来駒を置く升)を指定しておくぜ☆(^~^)
                        true
#if DEBUG
                        , dbg_reigai
#endif
                        ))
                {
                    return(Pure.FailTrue("TryFail_Torinozoku(2)"));
                }
                // 駒が無かった、というキャッシュは取らないぜ☆(^▽^)

                // この上の HerasuBanjoKoma で指し手件数が動くようだ。
            }

            //────────────────────────────────────────
            // T1   [2]      移動元に 手番の駒 が無い
            //────────────────────────────────────────

            return(Pure.SUCCESSFUL_FALSE);
        }
Example #2
0
 public static bool SetSsssMotMks_AndHasMotigoma(MotigomaSyurui val)
 {
     ssss_mot_mks_ = val;
     ssss_mot_mg_  = Med_Koma.MotiKomasyuruiAndTaikyokusyaToMotiKoma(val, kifu_teban);
     if (gky_ky.motigomaItiran.yomiMotigomaItiran.HasMotigoma(ssss_mot_mg_))
     {
         // 持ち駒を持っているときだけセットするぜ☆(^~^)
         ssss_mot_km_ = Med_Koma.MotiKomasyuruiAndTaikyokusyaToKoma(ssss_mot_mks_, kifu_teban);
         ssss_mot_ks_ = Med_Koma.MotiKomasyuruiToKomasyrui(ssss_mot_mks_);
         return(true);
     }
     return(false);
 }
Example #3
0
        /// <summary>
        /// 取った駒を、駒台に置くぜ☆(^▽^)
        /// </summary>
        /// <returns></returns>
        public static bool TryFail_DaiOn(
            Piece km_c,// あれば、移動先の相手の駒(取られる駒; capture)
            Komasyurui ks_c,
            Motigoma mk_c

#if DEBUG
            , FenSyurui f
            , IDebugMojiretu dbg_reigai
#endif
            )
        {
            //────────────────────────────────────────
            // 状況:
            //          移動先に駒があれば……。
            //────────────────────────────────────────
            #region 駒を取る
            if (km_c != Piece.Kuhaku)
            {
                // 駒取るぜ☆(^▽^)!

                // ただし、らいおんを除く
                if (ks_c != Komasyurui.R) // らいおん を取っても、持駒は増えないぜ☆
                {
                    //────────────────────────────────────────
                    // C    [1]     取る前の 持ち駒が増える前の 駒台が在る
                    //────────────────────────────────────────

                    //────────────────────────────────────────
                    //  C    [遷移]    取った持ち駒を増やす
                    //────────────────────────────────────────
                    // 取る前の持ち駒をリカウントする
                    // 増やす
                    PureMemory.gky_ky.motigomaItiran.Fuyasu(mk_c);

                    // TODO: 駒割りを増やすならここだぜ☆(^~^)


                    //────────────────────────────────────────
                    // C   [3]  取った後の 持駒が1つ増えた 駒台が在る
                    //────────────────────────────────────────
                }
            }
            #endregion

            return(Pure.SUCCESSFUL_FALSE);
        }
Example #4
0
        public bool Try_Herasu(out MotigomaItiran out_ret, Motigoma mk
#if DEBUG
                               , IDebugMojiretu reigai1
#endif
                               )
        {
            valueMk[(int)mk]--;
#if DEBUG
            if (valueMk[(int)mk] < 0)
            {
                reigai1.AppendLine("error 持駒の数がマイナス");
                out_ret = null;
                return(false);
            }
#endif
            out_ret = this;
            return(true);
        }
Example #5
0
        /// <summary>
        /// 移動元の自分の駒台から、駒を取るぜ☆(^▽^)
        /// </summary>
        /// <returns></returns>
        public static bool TryFail_DaiOff(
            Masu ms_t0,
            Piece km_t0,
            Motigoma mk_t0,
            Masu ms_t1 // 移動先升

#if DEBUG
            , FenSyurui f
            , IDebugMojiretu dbg_reigai
#endif
            )
        {
            //────────────────────────────────────────
            // T1   [1]  移動元に 手番の駒 が在る
            //────────────────────────────────────────

            //────────────────────────────────────────
            // T1   [遷移]    移動元の 手番の駒 を除外する
            //────────────────────────────────────────
            {
                MotigomaItiran motiKomaItiranImpl;
                if (!PureMemory.gky_ky.motigomaItiran.Try_Herasu(out motiKomaItiranImpl, mk_t0
#if DEBUG
                                                                 , (IDebugMojiretu)dbg_reigai
#endif
                                                                 ))
                {
                    return(Pure.FailTrue("do-tj3u gky.ky.motiKomas.Try_Herasu"));
                }

                // TODO: 駒割り評価値を減らすならここだぜ☆(^~^)

                // 駒台はこのステップが1つ多い
            }

            //DoMove1( isSfen, ss, ssType, ref konoTeme, syuturyoku, out gt_EndMethod);


            //────────────────────────────────────────
            // T1   [2]      移動元に 手番の駒 が無い
            //────────────────────────────────────────
            return(Pure.SUCCESSFUL_FALSE);
        }
Example #6
0
        /// <summary>
        /// 将棋盤を180度ひっくり返すぜ☆(^▽^)
        /// 主にテスト用だぜ☆(^▽^)
        ///
        /// 参考:「ビットの並びを反転する」http://blog.livedoor.jp/techblog1/archives/5365383.html
        /// </summary>
        public static void Hanten()
        {
            // 盤上
            {
                // 左右反転して、先後も入替
                Bitboard tmp_T1 = PureMemory.gky_ky.shogiban.ibashoBan_yk00.CloneBB_KomaZenbu(Taikyokusya.T1);
                Bitboard tmp_T2 = PureMemory.gky_ky.shogiban.ibashoBan_yk00.CloneBB_KomaZenbu(Taikyokusya.T2);
                tmp_T1.Bitflip128();
                tmp_T2.Bitflip128();
                PureMemory.gky_ky.shogiban.ibashoBan_yk00.Set_KomaZenbu(Taikyokusya.T1, tmp_T1);
                PureMemory.gky_ky.shogiban.ibashoBan_yk00.Set_KomaZenbu(Taikyokusya.T2, tmp_T2);

                for (int iKs = 0; iKs < Conv_Komasyurui.itiran.Length; iKs++)
                {
                    Komasyurui ks = Conv_Komasyurui.itiran[iKs];

                    Piece km1 = Med_Koma.KomasyuruiAndTaikyokusyaToKoma(ks, Taikyokusya.T1);
                    tmp_T1 = PureMemory.gky_ky.shogiban.ibashoBan_yk00.CloneBb_Koma(km1);
                    tmp_T1.Bitflip128();
                    PureMemory.gky_ky.shogiban.ibashoBan_yk00.Set_Koma(km1, tmp_T1);

                    Piece km2 = Med_Koma.KomasyuruiAndTaikyokusyaToKoma(ks, Taikyokusya.T2);
                    tmp_T2 = PureMemory.gky_ky.shogiban.ibashoBan_yk00.CloneBb_Koma(km2);
                    tmp_T2.Bitflip128();
                    PureMemory.gky_ky.shogiban.ibashoBan_yk00.Set_Koma(km2, tmp_T2);
                }
                // 盤面反転、駒の先後も反転だぜ☆(^▽^)
            }
            // 持ち駒
            {
                MotigomaItiran tmp = new MotigomaItiran();
                foreach (Motigoma mk in Conv_Motigoma.itiran)
                {
                    MotigomaSyurui mks            = Med_Koma.MotiKomaToMotiKomasyrui(mk);
                    Taikyokusya    tai            = Med_Koma.MotiKomaToTaikyokusya(mk);
                    Motigoma       hantenMotikoma = Med_Koma.MotiKomasyuruiAndTaikyokusyaToMotiKoma(mks, Conv_Taikyokusya.Hanten(tai));
                    tmp.Set(mk, PureMemory.gky_ky.motigomaItiran.yomiMotigomaItiran.Count(hantenMotikoma));
                }
                PureMemory.gky_ky.motigomaItiran.Set(tmp);
            }
        }
Example #7
0
 /// <summary>
 /// 持駒の枚数をセットするぜ☆(^~^)
 /// </summary>
 /// <param name="mk"></param>
 /// <param name="count"></param>
 static void SetMotiKoma(Motigoma mk, int count)
 {
     PureMemory.gky_ky.motigomaItiran.Set(mk, count);
 }
Example #8
0
 /// <summary>
 /// 持ち駒の枚数を取得します
 /// </summary>
 /// <param name="mg"></param>
 /// <returns></returns>
 public static int CountMotigoma(Motigoma mg)
 {
     return(PureMemory.gky_ky.yomiKy.yomiMotigomaItiran.Count(mg));
 }
Example #9
0
        public static bool TryParseFen(FenSyurui f, char moji, out Motigoma out_koma)
        {
            switch (f)
            {
            case FenSyurui.sfe_n:
            {
                switch (moji)
                {
                // 角(対局者1、対局者2)
                case 'B': out_koma = Motigoma.Z; return(true);

                case 'b': out_koma = Motigoma.z; return(true);

                case 'R': out_koma = Motigoma.K; return(true);

                case 'r': out_koma = Motigoma.k; return(true);

                case 'P': out_koma = Motigoma.H; return(true);

                case 'p': out_koma = Motigoma.h; return(true);

                case 'G': out_koma = Motigoma.I; return(true);

                case 'g': out_koma = Motigoma.i; return(true);

                case 'S': out_koma = Motigoma.N; return(true);

                case 's': out_koma = Motigoma.n; return(true);

                case 'N': out_koma = Motigoma.U; return(true);

                case 'n': out_koma = Motigoma.u; return(true);

                case 'L': out_koma = Motigoma.S; return(true);

                case 'l': out_koma = Motigoma.s; return(true);

                default: out_koma = Motigoma.Yososu; return(false);
                }
            }

            case FenSyurui.dfe_n:
            {
                switch (moji)
                {
                // ぞう(対局者1、対局者2)
                case 'Z': out_koma = Motigoma.Z; return(true);

                case 'z': out_koma = Motigoma.z; return(true);

                case 'K': out_koma = Motigoma.K; return(true);

                case 'k': out_koma = Motigoma.k; return(true);

                case 'H': out_koma = Motigoma.H; return(true);

                case 'h': out_koma = Motigoma.h; return(true);

                case 'I': out_koma = Motigoma.I; return(true);

                case 'i': out_koma = Motigoma.i; return(true);

                case 'N': out_koma = Motigoma.N; return(true);

                case 'n': out_koma = Motigoma.n; return(true);

                case 'U': out_koma = Motigoma.U; return(true);

                case 'u': out_koma = Motigoma.u; return(true);

                case 'S': out_koma = Motigoma.S; return(true);

                case 's': out_koma = Motigoma.s; return(true);

                default: out_koma = Motigoma.Yososu; return(false);
                }
            }

            default:
                throw new Exception(string.Format("未定義 {0}", f));
            }
        }
Example #10
0
 public static MotigomaSyurui MotiKomaToMotiKomasyrui(Motigoma mk)
 {
     return(Med_Koma.m_MotiKomaToMotiKomasyurui_[(int)mk]);
 }
Example #11
0
 public static Taikyokusya MotiKomaToTaikyokusya(Motigoma mk)
 {
     return(Med_Koma.m_MotiKomaToTaikyokusya_[(int)mk]);
 }
Example #12
0
 public MotigomaItiran Fuyasu(Motigoma mk)
 {
     valueMk[(int)mk]++;
     return(this);
 }
Example #13
0
 public static Piece MotiKomaToKoma(Motigoma mk)
 {
     return(MotiKomasyuruiAndTaikyokusyaToKoma(MotiKomaToMotiKomasyrui(mk), MotiKomaToTaikyokusya(mk)));
 }
Example #14
0
        /// <summary>
        /// 将棋盤の駒を適当に動かすぜ☆(^▽^)www
        /// 主にテスト用だぜ☆(^▽^)
        /// </summary>
        public static bool TryFail_Mazeru(FenSyurui f
#if DEBUG
                                          , IDebugMojiretu reigai1
#endif
                                          )
        {
            int            r;                  //ランダム値☆
            Piece          tmpKm;
            MotigomaItiran motiKomaItiranImpl; //使わない

            // 盤がでかくなると時間がかかる☆(^~^)最大 1万回で☆(^~^)
            int nokori = 10000;

            // 50回もやれば混ざるだろ☆(^▽^)
            for (int i = 0; i < 50; i++)
            {
                int        kakuritu = PureSettei.banHeimen + Conv_Motigoma.itiran.Length;//適当☆(^~^)
                Komasyurui tmpKs;

                // 盤上にある駒を、別の空き升、あるいは持ち駒に移動するぜ☆(^▽^)
                for (int iMs1 = 0; iMs1 < PureSettei.banHeimen; iMs1++)
                {
                    for (int iMs2 = 0; iMs2 < PureSettei.banHeimen; iMs2++)
                    {
                        r = PureSettei.random.Next(kakuritu);
                        if (3 == r || 4 == r || 5 == r || 6 == r)// 確率
                        {
                            // 位置交換成立☆(^~^)空白同士の交換とか意味ないこともするぜ☆(^▽^)
                            tmpKm = PureMemory.gky_ky.yomiKy.yomiShogiban.yomiIbashoBan.GetBanjoKoma((Masu)iMs1);
                            if (3 == r || 5 == r)
                            {
                                if (PureMemory.gky_ky.shogiban.TryFail_OkuKoma(//混ぜる
                                        (Masu)iMs1, Conv_Koma.Hanten(PureMemory.gky_ky.yomiKy.yomiShogiban.yomiIbashoBan.GetBanjoKoma((Masu)iMs2)),
                                        true
#if DEBUG
                                        , reigai1
#endif
                                        ))
                                {
                                    return(Pure.FailTrue("TryFail_Oku"));
                                }
                            }
                            else
                            {
                                if (PureMemory.gky_ky.shogiban.TryFail_OkuKoma(//混ぜる
                                        (Masu)iMs1, PureMemory.gky_ky.yomiKy.yomiShogiban.yomiIbashoBan.GetBanjoKoma((Masu)iMs2),
                                        true
#if DEBUG
                                        , reigai1
#endif
                                        ))
                                {
                                    return(Pure.FailTrue("Try_Oku"));
                                }
                            }

                            if (4 == r || 5 == r)
                            {
                                if (PureMemory.gky_ky.shogiban.TryFail_OkuKoma(//混ぜる
                                        (Masu)iMs2, Conv_Koma.Hanten(tmpKm), true
#if DEBUG
                                        , reigai1
#endif
                                        ))
                                {
                                    return(Pure.FailTrue("Try_Oku"));
                                }
                            }
                            else
                            {
                                if (PureMemory.gky_ky.shogiban.TryFail_OkuKoma(//混ぜる
                                        (Masu)iMs2, tmpKm, true
#if DEBUG
                                        , reigai1
#endif
                                        ))
                                {
                                    return(Pure.FailTrue("Try_Oku"));
                                }
                            }

                            nokori--;
                        }
                        else if ((1 == r || 2 == r) && PureMemory.gky_ky.shogiban.ibashoBan_yk00.yomiIbashoBan.ExistsKomaZenbu((Masu)iMs1))
                        {
                            // 持駒交換成立☆(^▽^)
                            Piece km_tmp = PureMemory.gky_ky.yomiKy.yomiShogiban.yomiIbashoBan.GetBanjoKoma((Masu)iMs1);
                            tmpKs = Med_Koma.KomaToKomasyurui(km_tmp);

                            //Taikyokusya tai_tmp = Med_Koma.KomaToTaikyokusya(km_tmp);

                            // どちらの持駒にするかはランダムで☆(^~^)
                            Motigoma mk = Med_Koma.KomasyuruiAndTaikyokusyaToMotiKoma(tmpKs, 1 == r ? Taikyokusya.T1 : Taikyokusya.T2);

                            switch (tmpKs)
                            {
                            case Komasyurui.Z:
                            {
                                PureMemory.gky_ky.motigomaItiran.Fuyasu(mk);
                                Piece km_remove = PureMemory.gky_ky.yomiKy.yomiShogiban.yomiIbashoBan.GetBanjoKoma((Masu)iMs1);
                                Debug.Assert(Conv_Koma.IsOk(km_remove), "km_remove can not remove");
                                if (PureMemory.gky_ky.shogiban.TryFail_TorinozokuKoma(
                                        (Masu)iMs1,
                                        km_remove, Conv_Masu.masu_error, true
#if DEBUG
                                        , reigai1
#endif
                                        ))
                                {
                                    return(Pure.FailTrue("TryFail_Torinozoku(4)"));
                                }
                            }
                            break;

                            case Komasyurui.K:
                            {
                                PureMemory.gky_ky.motigomaItiran.Fuyasu(mk);
                                Piece km_remove = PureMemory.gky_ky.yomiKy.yomiShogiban.yomiIbashoBan.GetBanjoKoma((Masu)iMs1);
                                Debug.Assert(Conv_Koma.IsOk(km_remove), "km_remove can not remove");
                                if (PureMemory.gky_ky.shogiban.TryFail_TorinozokuKoma(
                                        (Masu)iMs1,
                                        km_remove,
                                        Conv_Masu.masu_error, true
#if DEBUG
                                        , reigai1
#endif
                                        ))
                                {
                                    return(Pure.FailTrue("TryFail_Torinozoku(5)"));
                                }
                            }
                            break;

                            case Komasyurui.PH:    //thru
                            case Komasyurui.H:
                            {
                                PureMemory.gky_ky.motigomaItiran.Fuyasu(mk);
                                Piece km_remove = PureMemory.gky_ky.yomiKy.yomiShogiban.yomiIbashoBan.GetBanjoKoma((Masu)iMs1);
                                Debug.Assert(Conv_Koma.IsOk(km_remove), "km_remove can not remove");
                                if (PureMemory.gky_ky.shogiban.TryFail_TorinozokuKoma(
                                        (Masu)iMs1,
                                        km_remove,
                                        Conv_Masu.masu_error, true
#if DEBUG
                                        , reigai1
#endif
                                        ))
                                {
                                    return(Pure.FailTrue("TryFail_Torinozoku(6)"));
                                }
                            }
                            break;
                            }

                            nokori--;
                        }
                    }

                    // ひんぱんに、ひよこ/にわとりの入れ替えだぜ☆(^▽^)www
                    {
                        Piece km;
                        r = PureSettei.random.Next(kakuritu);
                        if (r % 5 < 2)
                        {
                            if (PureMemory.gky_ky.shogiban.ibashoBan_yk00.yomiIbashoBan.ExistsKoma(Piece.P1, (Masu)iMs1) || PureMemory.gky_ky.shogiban.ibashoBan_yk00.yomiIbashoBan.ExistsKoma(Piece.P2, (Masu)iMs1))
                            {
                                if (0 == r)
                                {
                                    km = Piece.PP1;
                                }
                                else
                                {
                                    km = Piece.PP2;
                                }
                            }
                            else if (PureMemory.gky_ky.shogiban.yomiIbashoBan_yoko.IsOn(Piece.PP1, (Masu)iMs1) || PureMemory.gky_ky.shogiban.yomiIbashoBan_yoko.IsOn(Piece.PP2, (Masu)iMs1))
                            {
                                if (0 == r)
                                {
                                    km = Piece.P1;
                                }
                                else
                                {
                                    km = Piece.P2;
                                }
                            }
                            else
                            {
                                km = Piece.Yososu;
                            }

                            if (km != Piece.Yososu)
                            {
                                if (PureMemory.gky_ky.shogiban.TryFail_OkuKoma(// 混ぜる
                                        (Masu)iMs1, km, true
#if DEBUG
                                        , reigai1
#endif
                                        ))
                                {
                                    return(Pure.FailTrue("TryFail_Oku"));
                                }
                            }
                        }
                    }

                    for (int iMk2 = 0; iMk2 < Conv_Motigoma.itiran.Length; iMk2++)
                    {
                        Piece km = Piece.Yososu;
                        r = PureSettei.random.Next(kakuritu);
                        if ((1 == r || 2 == r) && PureMemory.gky_ky.shogiban.ibashoBan_yk00.yomiIbashoBan.ExistsKomaZenbu((Masu)iMs1) &&
                            PureMemory.gky_ky.motigomaItiran.yomiMotigomaItiran.HasMotigoma((Motigoma)iMk2))
                        {
                            // 持駒交換成立☆(^▽^)
                            switch ((Motigoma)iMk2)
                            {
                            case Motigoma.Z:

                                if (!PureMemory.gky_ky.motigomaItiran.Try_Herasu(out motiKomaItiranImpl, Motigoma.Z
#if DEBUG
                                                                                 , reigai1
#endif
                                                                                 ))
                                {
                                    return(Pure.FailTrue("Try_Herasu"));
                                }

                                if (1 == r)
                                {
                                    km = Piece.B1;
                                }
                                else
                                {
                                    km = Piece.B2;
                                }
                                break;

                            case Motigoma.K:

                                if (!PureMemory.gky_ky.motigomaItiran.Try_Herasu(out motiKomaItiranImpl, Motigoma.K
#if DEBUG
                                                                                 , reigai1
#endif
                                                                                 ))
                                {
                                    return(Pure.FailTrue("Try_Herasu"));
                                }

                                if (1 == r)
                                {
                                    km = Piece.R1;
                                }
                                else
                                {
                                    km = Piece.R2;
                                }
                                break;

                            case Motigoma.H:
                                if (!PureMemory.gky_ky.motigomaItiran.Try_Herasu(out motiKomaItiranImpl, Motigoma.H
#if DEBUG
                                                                                 , (IDebugMojiretu)reigai1
#endif
                                                                                 ))
                                {
                                    return(Pure.FailTrue("Try_Herasu"));
                                }

                                if (1 == r)
                                {
                                    km = Piece.P1;
                                }
                                else
                                {
                                    km = Piece.P2;
                                }
                                break;

                            case Motigoma.z:
                                if (!PureMemory.gky_ky.motigomaItiran.Try_Herasu(out motiKomaItiranImpl, Motigoma.z
#if DEBUG
                                                                                 , (IDebugMojiretu)reigai1
#endif
                                                                                 ))
                                {
                                    return(Pure.FailTrue("Try_Herasu"));
                                }

                                if (1 == r)
                                {
                                    km = Piece.B2;
                                }
                                else
                                {
                                    km = Piece.B1;
                                }
                                break;

                            case Motigoma.k:
                                if (!PureMemory.gky_ky.motigomaItiran.Try_Herasu(out motiKomaItiranImpl, Motigoma.k
#if DEBUG
                                                                                 , reigai1
#endif
                                                                                 ))
                                {
                                    return(Pure.FailTrue("Try_Herasu"));
                                }

                                if (1 == r)
                                {
                                    km = Piece.R2;
                                }
                                else
                                {
                                    km = Piece.R1;
                                }
                                break;

                            case Motigoma.h:
                                if (!PureMemory.gky_ky.motigomaItiran.Try_Herasu(out motiKomaItiranImpl, Motigoma.h
#if DEBUG
                                                                                 , reigai1
#endif
                                                                                 ))
                                {
                                    return(Pure.FailTrue("Try_Herasu"));
                                }

                                if (1 == r)
                                {
                                    km = Piece.P2;
                                }
                                else
                                {
                                    km = Piece.P1;
                                }
                                break;
                            }

                            if (Piece.Yososu != km)
                            {
                                if (PureMemory.gky_ky.shogiban.TryFail_OkuKoma(//混ぜる
                                        (Masu)iMs1, km, true
#if DEBUG
                                        , reigai1
#endif
                                        ))
                                {
                                    return(Pure.FailTrue("TryFail_Oku"));
                                }
                            }

                            nokori--;
                        }
                    }

                    if (nokori < 0)
                    {
                        break;
                    }
                }

                // FIXME: 手番をひっくり返す機能は無いぜ☆(^~^)

                if (nokori < 0)
                {
                    break;
                }
            }

            // らいおんの先後を調整するぜ☆(^▽^)
            {
                Taikyokusya tb = Taikyokusya.T1;
                r = PureSettei.random.Next(2);
                if (0 == r)
                {
                    tb = Conv_Taikyokusya.Hanten(tb);
                }

                for (int iMs1 = 0; iMs1 < PureSettei.banHeimen; iMs1++)
                {
                    /*
                     * // トライしてたら、位置を変えるぜ☆(^▽^)www
                     * if (Koma.R == this.Komas[iMs1] && Conv_Masu.IsTried(Taikyokusya.T1, (Masu)iMs1))
                     * {
                     *  int iMs2 = iMs1 + 9;//9升足しておくか☆(^▽^)www
                     *  tmpKm = this.Komas[iMs1];
                     *  this.Komas[iMs1] = this.Komas[iMs2];
                     *  this.Komas[iMs2] = tmpKm;
                     * }
                     * else if (Koma.r == this.Komas[iMs1] && Conv_Masu.IsTried(Taikyokusya.T2, (Masu)iMs1))
                     * {
                     *  int iMs2 = iMs1 - 9;//9升引いておくか☆(^▽^)www
                     *  tmpKm = this.Komas[iMs1];
                     *  this.Komas[iMs1] = this.Komas[iMs2];
                     *  this.Komas[iMs2] = tmpKm;
                     * }
                     */

                    if (PureMemory.gky_ky.shogiban.ibashoBan_yk00.yomiIbashoBan.ExistsKoma(Piece.K1, (Masu)iMs1) || PureMemory.gky_ky.shogiban.ibashoBan_yk00.yomiIbashoBan.ExistsKoma(Piece.K2, (Masu)iMs1))
                    {
                        Piece km = Piece.Yososu;
                        if (tb == Taikyokusya.T1)
                        {
                            km = Piece.K1;
                        }
                        else
                        {
                            km = Piece.K2;
                        }

                        if (Piece.Yososu != km)
                        {
                            if (PureMemory.gky_ky.shogiban.TryFail_OkuKoma(//混ぜる
                                    (Masu)iMs1, km, true
#if DEBUG
                                    , reigai1
#endif
                                    ))
                            {
                                return(Pure.FailTrue("TryFail_Oku"));
                            }
                        }

                        tb = Conv_Taikyokusya.Hanten(tb);
                    }
                }
            }

            // 駒を配置したあとで使えだぜ☆(^~^)
            PureMemory.gky_ky.shogiban.Tukurinaosi_RemakeKiki();
            return(Pure.SUCCESSFUL_FALSE);
        }
Example #15
0
 public static bool IsOk(Motigoma mk)
 {
     return(Motigoma.Z <= mk && mk < Motigoma.Yososu);
 }
Example #16
0
 public int Count(Motigoma mg)
 {
     return(hontai_.valueMk[(int)mg]);
 }
Example #17
0
 /// <summary>
 /// 持駒を持っているなら真☆
 /// </summary>
 /// <param name="mk"></param>
 /// <returns></returns>
 public bool HasMotigoma(Motigoma mk)
 {
     return(0 < hontai_.valueMk[(int)mk]);
 }
Example #18
0
 /// <summary>
 /// 持駒の枚数にマイナスを入れてはいけないぜ☆(^~^)
 /// </summary>
 /// <param name="mk"></param>
 /// <param name="count"></param>
 /// <returns></returns>
 public void Set(Motigoma mk, int count)
 {
     Debug.Assert(valueMk[(int)mk] < 0, "error 持駒の数にマイナスをセットした☆");
     valueMk[(int)mk] = count;
 }
Example #19
0
        /// <summary>
        /// 汎用
        /// </summary>
        /// <returns></returns>
        static void Setumei_Hanyo(
            DLGT_dataBu dlgt_dataBu,
            int banYokoHaba_tmp,
            int banTateHaba_tmp,
            int teme,
            StringBuilder hyoji
            )
        {
            #region 盤の上の方
            // 2行目
            {
                // 何手目
                hyoji.Append(string.Format("図は{0,3}手まで ", teme));

                // 手番
                SpkTaikyokusya.AppendSetumeiName(PureMemory.GetTebanByTeme(teme), hyoji);
                hyoji.Append("の番");

                hyoji.AppendLine();
            }

            // 3行目 後手の持ち駒
            {
                // 後手の持ち駒の数
                foreach (MotigomaSyurui mks in Conv_MotigomaSyurui.itiran)
                {
                    Motigoma mk = Med_Koma.MotiKomasyuruiAndTaikyokusyaToMotiKoma(mks, Taikyokusya.T2);
                    if (PureMemory.gky_ky.yomiKy.yomiMotigomaItiran.HasMotigoma(mk))
                    {
                        hyoji.Append(Conv_MotigomaSyurui.GetHyojiName(mks)); hyoji.Append(PureMemory.gky_ky.yomiKy.yomiMotigomaItiran.Count(mk).ToString());
                    }
                }
                hyoji.AppendLine();
            }

            // 4行目
            {
                // A B C D とか
                hyoji.Append("  ");
                SpkBanWaku.AppendLine_SujiFugo(banYokoHaba_tmp, hyoji);
            }

            // 5行目
            {
                hyoji.Append("  ");
                SpkBanWaku.AppendLine_TopBar(1, PureSettei.banYokoHaba, hyoji); // ┌──┬──┬──┐
            }
            #endregion

            // 5行目~13行目
            // 盤上
            for (int dan = 0; dan < PureSettei.banTateHaba; dan++)
            {
                // 6,8,10,12行目
                hyoji.Append(Conv_Kihon.ToZenkakuInteger(dan + 1));

                SpkBanWaku.AppendLine_Record_Cell4Hankakus2(
                    (Masu ms) => {
                    return(dlgt_dataBu(dan, ms));
                },
                    dan, banYokoHaba_tmp, hyoji);

                if (dan + 1 < PureSettei.banTateHaba)
                {
                    // 7,9,11行目
                    hyoji.Append("  ");
                    SpkBanWaku.AppendLine_MiddleBar(1, PureSettei.banYokoHaba, hyoji);//├──┼──┼──┤
                }
            }

            #region 盤の下の方
            // 13行目
            {
                hyoji.Append("  ");
                SpkBanWaku.AppendLine_BottomBar(1, PureSettei.banYokoHaba, hyoji);//└──┴──┴──┘
            }

            // 先手の持ち駒の数
            {
                foreach (MotigomaSyurui mks in Conv_MotigomaSyurui.itiran)
                {
                    Motigoma mk = Med_Koma.MotiKomasyuruiAndTaikyokusyaToMotiKoma(mks, Taikyokusya.T1);
                    if (PureMemory.gky_ky.yomiKy.yomiMotigomaItiran.HasMotigoma(mk))
                    {
                        hyoji.Append(Conv_MotigomaSyurui.GetHyojiName(mks)); hyoji.Append(PureMemory.gky_ky.yomiKy.yomiMotigomaItiran.Count(mk).ToString());
                    }
                }
                hyoji.AppendLine();
            }
            #endregion
        }
Example #20
0
 public static string GetFen(FenSyurui f, Motigoma mk)
 {
     return(f == FenSyurui.sfe_n ? Conv_Motigoma.m_sfen_[(int)mk] : Conv_Motigoma.m_dfen_[(int)mk]);
 }
Example #21
0
 /// <summary>
 /// 目視確認用の文字列を返すぜ☆(^▽^)
 /// </summary>
 /// <param name="mk"></param>
 /// <returns></returns>
 public static void AppendSetumei(Motigoma mk, StringBuilder hyoji)
 {
     hyoji.Append(Conv_Motigoma.m_setumeiMojiretu_[(int)mk]);
 }
Example #22
0
 public MotigomaItiran Add(Motigoma mk, int count)
 {
     valueMk[(int)mk] += count;
     return(this);
 }