Ejemplo n.º 1
0
        /// <summary>
        /// 1P玉KP書出しボタン。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_1pKP_Write_Click(object sender, EventArgs e)
        {
            FeatureVector fv = new FeatureVectorImpl();

            Util_FeatureVectorInput.Make_FromFile_Komawari(fv, EngineConf.GetResourceFullPath("Fv00Komawari"));

            Util_FeatureVectorOutput.Write_KP(EngineConf, fv, EngineConf.DataDirectory);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// FVの保存。
        /// </summary>
        /// <param name="uc_Main"></param>
        public static void Do_Save(Uc_Main uc_Main)
        {
            FeatureVector fv = uc_Main.LearningData.Fv;


            // ファイルチューザーで指定された、fvフォルダーのパス
            string fvFolderPath = Path.GetDirectoryName(uc_Main.TxtFvFilepath.Text);

            // ファイルチューザーで指定された、Dataフォルダーのパス(fvフォルダーの親)
            string dataFolderPath = Directory.GetParent(fvFolderPath).FullName;

            //----------------------------------------
            // 時間
            //----------------------------------------
            string ymd;
            string hms;

            {
                DateTime dt = DateTime.Now;

                // 年月日
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append(dt.Year);
                    sb.Append("-");
                    sb.Append(dt.Month);
                    sb.Append("-");
                    sb.Append(dt.Day);
                    ymd = sb.ToString();
                    uc_Main.TxtAutosaveYMD.Text = ymd;
                }

                // 時分秒
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append(dt.Hour);
                    sb.Append("-");
                    sb.Append(dt.Minute);
                    sb.Append("-");
                    sb.Append(dt.Second);
                    hms = sb.ToString();
                    uc_Main.TxtAutosaveHMS.Text = hms;
                }
            }

            //----------------------------------------
            // バックアップ
            //----------------------------------------
            //
            // 失敗した場合、バックアップせず続行します
            //
            {
                // バックアップの失敗判定
                bool backup_failuer = false;

                // フォルダーのリネーム
                try
                {
                    string srcPath = Path.Combine(dataFolderPath, "fv");
                    string dstPath = Path.Combine(dataFolderPath, $"fv_{ymd}_{hms}");

                    Directory.Move(srcPath, dstPath);
                }
                catch (IOException)
                {
                    // フォルダーを、Windowsのファイル・エクスプローラーで開いているなどすると、失敗します。
                    backup_failuer = true;
                }

                if (!backup_failuer)
                {
                    // fvフォルダーの新規作成
                    Directory.CreateDirectory(fvFolderPath);
                }
            }

            //----------------------------------------
            // -999~999 に調整
            //----------------------------------------
            Util_LearnFunctions.FvParamRange_PP(uc_Main.LearningData.Fv);// 自動で -999~999(*bairitu) に矯正。


            // 駒割
            File.WriteAllText(uc_Main.TxtFvFilepath.Text, Format_FeatureVector_Komawari.Format_Text(fv));
            // スケール
            Util_FeatureVectorOutput.Write_Scale(uc_Main.EngineConf, fv, fvFolderPath);
            // KK
            Util_FeatureVectorOutput.Write_KK(uc_Main.EngineConf, fv, fvFolderPath);
            // 1pKP,2pKP
            Util_FeatureVectorOutput.Write_KP(uc_Main.EngineConf, fv, fvFolderPath);
            // PP 盤上
            Util_FeatureVectorOutput.Write_PP_Banjo(uc_Main.EngineConf, fv, fvFolderPath);
            // PP 19枚の持駒
            Util_FeatureVectorOutput.Write_PP_19Mai(uc_Main.EngineConf, fv, fvFolderPath);
            // PP 5枚の持駒、3枚の持駒
            Util_FeatureVectorOutput.Write_PP_5Mai(uc_Main.EngineConf, fv, fvFolderPath);
            Util_FeatureVectorOutput.Write_PP_3Mai(uc_Main.EngineConf, fv, fvFolderPath);
        }