예제 #1
0
        public ReportArgsImpl(
            ISfenPosition1 ro_Kyokumen1,
            string outFileFullName,
            ReportEnvironment reportEnvironment)
        {
            this.ro_Kyokumen1 = ro_Kyokumen1;

            // デバッグ
            {
                Debug.Assert(this.ro_Kyokumen1.Ban.Length == 10, "サイズ違反");
                Debug.Assert(this.ro_Kyokumen1.Ban[0].Length == 10, "サイズ違反");
                Debug.Assert(this.ro_Kyokumen1.Ban[1].Length == 10, "サイズ違反");
                Debug.Assert(this.ro_Kyokumen1.Ban[2].Length == 10, "サイズ違反");
                Debug.Assert(this.ro_Kyokumen1.Ban[3].Length == 10, "サイズ違反");
                Debug.Assert(this.ro_Kyokumen1.Ban[4].Length == 10, "サイズ違反");
                Debug.Assert(this.ro_Kyokumen1.Ban[5].Length == 10, "サイズ違反");
                Debug.Assert(this.ro_Kyokumen1.Ban[6].Length == 10, "サイズ違反");
                Debug.Assert(this.ro_Kyokumen1.Ban[7].Length == 10, "サイズ違反");
                Debug.Assert(this.ro_Kyokumen1.Ban[8].Length == 10, "サイズ違反");
                Debug.Assert(this.ro_Kyokumen1.Ban[9].Length == 10, "サイズ違反");
            }

            this.OutFileFullName = outFileFullName;
            this.env             = reportEnvironment;
        }
예제 #2
0
        public KyokumenPngArgsImpl(
            ISfenPosition1 ro_Kyokumen1,
            int srcMasu_orMinusOne,
            int dstMasu_orMinusOne,
            KyokumenPngArgs_FoodOrDropKoma foodKoma,
            KyokumenPngArgs_FoodOrDropKoma dropKoma,
            string outFile,
            KyokumenPngEnvironment reportEnvironment)
        {
            this.ro_Kyokumen1       = ro_Kyokumen1;
            this.srcMasu_orMinusOne = srcMasu_orMinusOne;
            this.dstMasu_orMinusOne = dstMasu_orMinusOne;
            this.foodKoma           = foodKoma;
            this.dropKoma           = dropKoma;

            //// デバッグ
            //{
            //    Debug.Assert(this.ro_Kyokumen1.Ban.Length == 10, "サイズ違反");
            //    Debug.Assert(this.ro_Kyokumen1.Ban[0].Length == 10, "サイズ違反");
            //    Debug.Assert(this.ro_Kyokumen1.Ban[1].Length == 10, "サイズ違反");
            //    Debug.Assert(this.ro_Kyokumen1.Ban[2].Length == 10, "サイズ違反");
            //    Debug.Assert(this.ro_Kyokumen1.Ban[3].Length == 10, "サイズ違反");
            //    Debug.Assert(this.ro_Kyokumen1.Ban[4].Length == 10, "サイズ違反");
            //    Debug.Assert(this.ro_Kyokumen1.Ban[5].Length == 10, "サイズ違反");
            //    Debug.Assert(this.ro_Kyokumen1.Ban[6].Length == 10, "サイズ違反");
            //    Debug.Assert(this.ro_Kyokumen1.Ban[7].Length == 10, "サイズ違反");
            //    Debug.Assert(this.ro_Kyokumen1.Ban[8].Length == 10, "サイズ違反");
            //    Debug.Assert(this.ro_Kyokumen1.Ban[9].Length == 10, "サイズ違反");
            //}

            this.outFile = outFile;
            this.env     = reportEnvironment;
        }
예제 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <param name="save_node_OrNull"></param>
 /// <param name="owner"></param>
 /// <param name="scoreKeisu">評価値に掛け算します。通常、1.0d を指定してください。</param>
 public TenonagareImpl(
     ISfenPosition1 ro_Kyokumen1ForKioku_OrNull,
     TenonagareName name, double scoreKeisu, RO_Star_Koma koma1, RO_Star_Koma koma2, Basho masu
     )
     : base(name, scoreKeisu, koma1, koma2, masu)
 {
     if (null != ro_Kyokumen1ForKioku_OrNull)
     {
         this.ResultKioku = new ResultKioku(ro_Kyokumen1ForKioku_OrNull.ToSfenstring(true));
     }
     else
     {
         this.ResultKioku = new ResultKioku(null);
     }
 }
예제 #4
0
        /// <summary>
        /// SFEN文字列と、出力ファイル名を指定することで、局面の画像ログを出力します。
        /// </summary>
        /// <param name="sfenstring"></param>
        /// <param name="outFileFullName"></param>
        /// <param name="reportEnvironment"></param>
        /// <returns></returns>
        public static bool Write1(
            IEngineConf engineConf,
            ISfenPosition1 ro_Kyokumen1,
            string outFileFullName,
            ReportEnvironment reportEnvironment
            )
        {
            bool successful = true;

            KyokumenPngWriter repWriter = new KyokumenPngWriterImpl(engineConf);
            ReportArgs        args      = new ReportArgsImpl(
                ro_Kyokumen1,
                outFileFullName,
                reportEnvironment
                );

            // 局面画像を描きだします。
            Bitmap bmp = new Bitmap(
                2 * (args.Env.KmW + 2 * args.Env.SjW) + BN_SUJIS * args.Env.KmW + BN_BRD_R_W,
                BN_DANS * args.Env.KmH + BN_BRD_B_W
                );


            repWriter.Paint(Graphics.FromImage(bmp), args);


            //System.Windows.Forms.MessageBox.Show(args.Env.OutFolder + args.OutFile, "bmp.Save");
            // フォルダーが無ければ、作る必要があります。
            {
                DirectoryInfo dirInfo = Directory.GetParent(args.OutFileFullName);
                if (!Directory.Exists(dirInfo.FullName))
                {
                    Directory.CreateDirectory(dirInfo.FullName);
                }
            }
            bmp.Save(args.OutFileFullName);

            return(successful);
        }
예제 #5
0
        public static string ToSfenstring(ISfenPosition1 ro_kyokumen1, bool white)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("sfen ");

            for (int dan = 1; dan <= 9; dan++)
            {
                int spaceCount = 0;

                for (int suji = 9; suji >= 1; suji--)
                {
                    // 将棋盤上のどこかにある駒?
                    string koma0 = ro_kyokumen1.Ban[suji, dan];

                    if ("" != koma0)
                    {
                        if (0 < spaceCount)
                        {
                            sb.Append(spaceCount);
                            spaceCount = 0;
                        }

                        sb.Append(koma0);
                    }
                    else
                    {
                        spaceCount++;
                    }
                }

                if (0 < spaceCount)
                {
                    sb.Append(spaceCount);
                    spaceCount = 0;
                }

                if (dan != 9)
                {
                    sb.Append("/");
                }
            }

            sb.Append(" ");

            //------------------------------------------------------------
            // 先後
            //------------------------------------------------------------
            if (white)
            {
                sb.Append("w");
            }
            else
            {
                sb.Append("b");
            }

            sb.Append(" ");

            //------------------------------------------------------------
            // 持ち駒
            //------------------------------------------------------------
            {
                int mK = 0;
                int mR = 0;
                int mB = 0;
                int mG = 0;
                int mS = 0;
                int mN = 0;
                int mL = 0;
                int mP = 0;

                int mk = 0;
                int mr = 0;
                int mb = 0;
                int mg = 0;
                int ms = 0;
                int mn = 0;
                int ml = 0;
                int mp = 0;
                ro_kyokumen1.GetMoti(
                    out mK,
                    out mR,
                    out mB,
                    out mG,
                    out mS,
                    out mN,
                    out mL,
                    out mP,

                    out mk,
                    out mr,
                    out mb,
                    out mg,
                    out ms,
                    out mn,
                    out ml,
                    out mp
                    );



                if (0 == mK + mR + mB + mG + mS + mN + mL + mP + mk + mr + mb + mg + ms + mn + ml + mp)
                {
                    sb.Append("-");
                }
                else
                {
                    if (0 < mK)
                    {
                        if (1 < mK)
                        {
                            sb.Append(mK);
                        }
                        sb.Append("K");
                    }

                    if (0 < mR)
                    {
                        if (1 < mR)
                        {
                            sb.Append(mR);
                        }
                        sb.Append("R");
                    }

                    if (0 < mB)
                    {
                        if (1 < mB)
                        {
                            sb.Append(mB);
                        }
                        sb.Append("B");
                    }

                    if (0 < mG)
                    {
                        if (1 < mG)
                        {
                            sb.Append(mG);
                        }
                        sb.Append("G");
                    }

                    if (0 < mS)
                    {
                        if (1 < mS)
                        {
                            sb.Append(mS);
                        }
                        sb.Append("S");
                    }

                    if (0 < mN)
                    {
                        if (1 < mN)
                        {
                            sb.Append(mN);
                        }
                        sb.Append("N");
                    }

                    if (0 < mL)
                    {
                        if (1 < mL)
                        {
                            sb.Append(mL);
                        }
                        sb.Append("L");
                    }

                    if (0 < mP)
                    {
                        if (1 < mP)
                        {
                            sb.Append(mP);
                        }
                        sb.Append("P");
                    }

                    if (0 < mk)
                    {
                        if (1 < mk)
                        {
                            sb.Append(mk);
                        }
                        sb.Append("k");
                    }

                    if (0 < mr)
                    {
                        if (1 < mr)
                        {
                            sb.Append(mr);
                        }
                        sb.Append("r");
                    }

                    if (0 < mb)
                    {
                        if (1 < mb)
                        {
                            sb.Append(mb);
                        }
                        sb.Append("b");
                    }

                    if (0 < mg)
                    {
                        if (1 < mg)
                        {
                            sb.Append(mg);
                        }
                        sb.Append("g");
                    }

                    if (0 < ms)
                    {
                        if (1 < ms)
                        {
                            sb.Append(ms);
                        }
                        sb.Append("s");
                    }

                    if (0 < mn)
                    {
                        if (1 < mn)
                        {
                            sb.Append(mn);
                        }
                        sb.Append("n");
                    }

                    if (0 < ml)
                    {
                        if (1 < ml)
                        {
                            sb.Append(ml);
                        }
                        sb.Append("l");
                    }

                    if (0 < mp)
                    {
                        if (1 < mp)
                        {
                            sb.Append(mp);
                        }
                        sb.Append("p");
                    }
                }
            }

            // 手目
            sb.Append(" ");
            sb.Append(ro_kyokumen1.Temezumi);

            return(sb.ToString());
        }
예제 #6
0
        /// <summary>
        /// 局面データと、出力ファイル名を指定することで、局面の画像ログを出力します。
        /// </summary>
        /// <param name="ro_Kyokumen1"></param>
        /// <param name="dstMasu_orMinusOne">あれば、移動先升番号。なければ -1。</param>
        /// <param name="appendFilepath"></param>
        /// <param name="outFile"></param>
        /// <param name="reportEnvironment"></param>
        /// <returns></returns>
        public static bool Write1(
            ISfenPosition1 ro_Kyokumen1,
            int srcMasu_orMinusOne,
            int dstMasu_orMinusOne,
            KyokumenPngArgs_FoodOrDropKoma foodKoma,
            string sfenMoveStrOrEmpty,
            string appendFilepath,
            string outFile,
            KyokumenPngEnvironment reportEnvironment
            )
        {
            bool successful = true;


            //----------------------------------------
            // 打った駒を調べる
            //----------------------------------------
            KyokumenPngArgs_FoodOrDropKoma dropKoma;

            {
                dropKoma = KyokumenPngArgs_FoodOrDropKoma.UNKNOWN;
                if ("" != sfenMoveStrOrEmpty)
                {
                    string moji1;
                    string moji2;
                    string moji3;
                    string moji4;
                    string moji5;
                    string rest;
                    SfenMovesTextConv.ToTokens(
                        sfenMoveStrOrEmpty,
                        out moji1,
                        out moji2,
                        out moji3,
                        out moji4,
                        out moji5,
                        out rest
                        );

                    if (moji2 == "*")
                    {
                        switch (moji1)
                        {
                        case SfenWord.P_PAWN__: dropKoma = KyokumenPngArgs_FoodOrDropKoma.FU__; break;

                        case SfenWord.L_LANCE_: dropKoma = KyokumenPngArgs_FoodOrDropKoma.KYO_; break;

                        case SfenWord.N_KNIGHT: dropKoma = KyokumenPngArgs_FoodOrDropKoma.KEI_; break;

                        case SfenWord.S_SILVER: dropKoma = KyokumenPngArgs_FoodOrDropKoma.GIN_; break;

                        case SfenWord.G_GOLD__: dropKoma = KyokumenPngArgs_FoodOrDropKoma.KIN_; break;

                        case SfenWord.B_BISHOP: dropKoma = KyokumenPngArgs_FoodOrDropKoma.KAKU; break;

                        case SfenWord.R_ROOK__: dropKoma = KyokumenPngArgs_FoodOrDropKoma.HI__; break;

                        default: break;
                        }
                    }
                    else
                    {
                        dropKoma = KyokumenPngArgs_FoodOrDropKoma.NONE;
                    }
                }
            }


            //----------------------------------------
            // ファイルに使える文字に変換
            //----------------------------------------
            appendFilepath = appendFilepath.Replace('*', '*');
            outFile        = outFile.Replace('*', '*');

            KyokumenPngArgs args = new KyokumenPngArgsImpl(
                ro_Kyokumen1,
                srcMasu_orMinusOne,
                dstMasu_orMinusOne,
                foodKoma,
                dropKoma,
                outFile,
                reportEnvironment
                );

            // 局面画像を描きだします。
            Bitmap bmp = new Bitmap(
                2 * (args.Env.KmW + 2 * args.Env.SjW) + Util_KyokumenPngPainter.BN_SUJIS * args.Env.KmW + Util_KyokumenPngPainter.BN_BRD_R_W,
                Util_KyokumenPngPainter.BN_DANS * args.Env.KmH + Util_KyokumenPngPainter.BN_BRD_B_W
                );


            Util_KyokumenPngPainter.Paint(Graphics.FromImage(bmp), args);


            //args.Env.OutFolder + args.OutFile, "bmp.Save"
            string filepath = args.Env.OutFolder + appendFilepath + args.OutFile;

            // フォルダーが無ければ、作る必要があります。
            {
                DirectoryInfo dirInfo = Directory.GetParent(filepath);
                if (!Directory.Exists(dirInfo.FullName))
                {
                    Directory.CreateDirectory(dirInfo.FullName);
                }
            }

            bmp.Save(filepath);

            return(successful);
        }