예제 #1
0
        public static void Write_KP(IEngineConf engineConf, FeatureVector fv, string fvDirectory)
        {
            string filepathW1 = Path.Combine(fvDirectory, engineConf.GetResourceBasename("Fv02n1pKPInFvDir"));
            string filepathW2 = Path.Combine(fvDirectory, engineConf.GetResourceBasename("Fv03n2pKPInFvDir"));
            //----------------------------------------
            // 1P玉
            //----------------------------------------
            {
                File.WriteAllText(filepathW1, Format_FeatureVector_KP.Format_KP(fv, Playerside.P1));
                //sb.AppendLine(filepathW1);
            }

            //----------------------------------------
            // 2p玉
            //----------------------------------------
            {
                File.WriteAllText(filepathW2, Format_FeatureVector_KP.Format_KP(fv, Playerside.P2));
                //sb.AppendLine(filepathW2);
            }
        }
예제 #2
0
        /// <summary>
        /// テキストを作ります。
        /// </summary>
        /// <param name="fv"></param>
        /// <param name="player"></param>
        /// <returns></returns>
        public static string Format_KP(FeatureVector fv, Playerside k_pside)
        {
            StringBuilder sb = new StringBuilder();

            //
            // コメント
            //
            sb.AppendLine("\"#紹介文\",");
            sb.AppendLine("\"#\",");
            sb.AppendLine("\"#ボナンザ6.0アレンジ式きふわらべ2駒関係\",");
            sb.AppendLine("\"#\",");
            sb.AppendLine("\"#----------------------------------------\",");
            sb.AppendLine("\"# ");
            sb.AppendLine(string.Format("{0}P玉 KP表☆", (int)k_pside));
            sb.AppendLine("\",");
            sb.AppendLine("\"#----------------------------------------\",");
            sb.AppendLine("\"#\",");
            sb.AppendLine("\"#常に先手は正の数、後手は負の数の絶対値が大きい方が有利。0は互角。\",");

            //
            // 仕様バージョン
            //
            sb.AppendLine();
            sb.AppendLine("\"Version\",1.0,");
            sb.AppendLine();

            //----------------------------------------
            // vs 1P歩
            // vs 1P香
            // vs 1P桂
            // vs 1P銀
            // vs 1P金
            // vs 1P飛
            // vs 1P角
            // vs 2P歩
            // vs 2P香
            // vs 2P桂
            // vs 2P銀
            // vs 2P金
            // vs 2P飛
            // vs 2P角
            //----------------------------------------
            {
                Kp_P2Item[] kp_p2items = new Kp_P2Item[] {
                    new Kp_P2Item("vs 1P歩", FeatureVectorImpl.CHOSA_KOMOKU_1P + FeatureVectorImpl.CHOSA_KOMOKU_____FU_____),
                    new Kp_P2Item("vs 1P香", FeatureVectorImpl.CHOSA_KOMOKU_1P + FeatureVectorImpl.CHOSA_KOMOKU_____KYO____),
                    new Kp_P2Item("vs 1P桂", FeatureVectorImpl.CHOSA_KOMOKU_1P + FeatureVectorImpl.CHOSA_KOMOKU_____KEI____),
                    new Kp_P2Item("vs 1P銀", FeatureVectorImpl.CHOSA_KOMOKU_1P + FeatureVectorImpl.CHOSA_KOMOKU_____GIN____),
                    new Kp_P2Item("vs 1P金", FeatureVectorImpl.CHOSA_KOMOKU_1P + FeatureVectorImpl.CHOSA_KOMOKU_____KIN____),
                    new Kp_P2Item("vs 1P飛", FeatureVectorImpl.CHOSA_KOMOKU_1P + FeatureVectorImpl.CHOSA_KOMOKU_____HISYA__),
                    new Kp_P2Item("vs 1P角", FeatureVectorImpl.CHOSA_KOMOKU_1P + FeatureVectorImpl.CHOSA_KOMOKU_____KAKU___),
                    new Kp_P2Item("vs 2P歩", FeatureVectorImpl.CHOSA_KOMOKU_2P + FeatureVectorImpl.CHOSA_KOMOKU_____FU_____),
                    new Kp_P2Item("vs 2P香", FeatureVectorImpl.CHOSA_KOMOKU_2P + FeatureVectorImpl.CHOSA_KOMOKU_____KYO____),
                    new Kp_P2Item("vs 2P桂", FeatureVectorImpl.CHOSA_KOMOKU_2P + FeatureVectorImpl.CHOSA_KOMOKU_____KEI____),
                    new Kp_P2Item("vs 2P銀", FeatureVectorImpl.CHOSA_KOMOKU_2P + FeatureVectorImpl.CHOSA_KOMOKU_____GIN____),
                    new Kp_P2Item("vs 2P金", FeatureVectorImpl.CHOSA_KOMOKU_2P + FeatureVectorImpl.CHOSA_KOMOKU_____KIN____),
                    new Kp_P2Item("vs 2P飛", FeatureVectorImpl.CHOSA_KOMOKU_2P + FeatureVectorImpl.CHOSA_KOMOKU_____HISYA__),
                    new Kp_P2Item("vs 2P角", FeatureVectorImpl.CHOSA_KOMOKU_2P + FeatureVectorImpl.CHOSA_KOMOKU_____KAKU___),
                };
                for (int banjo = 0; banjo < kp_p2items.Length; banjo++)
                {
                    sb.Append(Format_FeatureVector_KP.Format_NestedShogiban(fv, k_pside, kp_p2items[banjo]));
                }
            }

            //----------------------------------------
            // vs 1P持ち歩
            // vs 1P持ち香
            // vs 1P持ち桂
            // vs 1P持ち銀
            // vs 1P持ち金
            // vs 1P持ち飛
            // vs 1P持ち角
            // vs 2P持ち歩
            // vs 2P持ち香
            // vs 2P持ち桂
            // vs 2P持ち銀
            // vs 2P持ち金
            // vs 2P持ち飛
            // vs 2P持ち角
            // 計 45項目
            //----------------------------------------
            {
                List <Kp_P2Item> kpList = new List <Kp_P2Item>();

                // pieceの 1Pと2P
                for (int piecePlayer = 1; piecePlayer < 3; piecePlayer++)
                {
                    int koumokuIndex;
                    if (piecePlayer == 1)
                    {
                        koumokuIndex = FeatureVectorImpl.CHOSA_KOMOKU_1P;
                    }
                    else if (piecePlayer == 2)
                    {
                        koumokuIndex = FeatureVectorImpl.CHOSA_KOMOKU_2P;
                    }
                    else
                    {
                        throw new Exception("範囲外");
                    }

                    // vs 持ち駒 1P歩x 0~18
                    for (int maisu = 0; maisu < 19; maisu++)//枚数
                    {
                        kpList.Add(new Kp_P2Item(string.Format("vs 持ち駒 {0}P歩x{1,2}", piecePlayer, maisu), koumokuIndex + FeatureVectorImpl.CHOSA_KOMOKU_MOTIFU_____ + maisu));
                    }

                    // vs 持ち駒 1P香x 0~4
                    for (int maisu = 0; maisu < 5; maisu++)//枚数
                    {
                        kpList.Add(new Kp_P2Item(string.Format("vs 持ち駒 {0}P香x{1,2}", piecePlayer, maisu), koumokuIndex + FeatureVectorImpl.CHOSA_KOMOKU_MOTIKYO____ + maisu));
                    }

                    // vs 持ち駒 1P桂x 0~4
                    for (int maisu = 0; maisu < 5; maisu++)//枚数
                    {
                        kpList.Add(new Kp_P2Item(string.Format("vs 持ち駒 {0}P桂x{1,2}", piecePlayer, maisu), koumokuIndex + FeatureVectorImpl.CHOSA_KOMOKU_MOTIKEI____ + maisu));
                    }

                    // vs 持ち駒 1P銀x 0~4
                    for (int maisu = 0; maisu < 5; maisu++)//枚数
                    {
                        kpList.Add(new Kp_P2Item(string.Format("vs 持ち駒 {0}P銀x{1,2}", piecePlayer, maisu), koumokuIndex + FeatureVectorImpl.CHOSA_KOMOKU_MOTIGIN____ + maisu));
                    }

                    // vs 持ち駒 1P金x 0~4
                    for (int maisu = 0; maisu < 5; maisu++)//枚数
                    {
                        kpList.Add(new Kp_P2Item(string.Format("vs 持ち駒 {0}P金x{1,2}", piecePlayer, maisu), koumokuIndex + FeatureVectorImpl.CHOSA_KOMOKU_MOTIKIN____ + maisu));
                    }

                    // vs 持ち駒 1P飛x 0~4
                    for (int maisu = 0; maisu < 3; maisu++)//枚数
                    {
                        kpList.Add(new Kp_P2Item(string.Format("vs 持ち駒 {0}P飛x{1,2}", piecePlayer, maisu), koumokuIndex + FeatureVectorImpl.CHOSA_KOMOKU_MOTIHISYA__ + maisu));
                    }

                    // vs 持ち駒 1P角x 0~4
                    for (int maisu = 0; maisu < 3; maisu++)//枚数
                    {
                        kpList.Add(new Kp_P2Item(string.Format("vs 持ち駒 {0}P角x{1,2}", piecePlayer, maisu), koumokuIndex + FeatureVectorImpl.CHOSA_KOMOKU_MOTIKAKU___ + maisu));
                    }
                }
                // 計90項目

                for (int moti = 0; moti < kpList.Count; moti++)
                {
                    // サンプルで作るだけ
                    sb.Append(Format_FeatureVector_KP.Format_SingleShogiban(fv, k_pside, kpList[moti]));
                }
            }



            return(sb.ToString());
        }