OSDN Git Service

Merge branch 'feature/37178_プロジェクトとソリューションファイルの英語化' into develop
[dtxmania/dtxmania.git] / DTXCreatorプロジェクト / コード / 05.譜面 / C難易度自動計算マン.cs
diff --git a/DTXCreatorプロジェクト/コード/05.譜面/C難易度自動計算マン.cs b/DTXCreatorプロジェクト/コード/05.譜面/C難易度自動計算マン.cs
deleted file mode 100644 (file)
index c8ba767..0000000
+++ /dev/null
@@ -1,351 +0,0 @@
-using System;\r
-using System.Collections.Generic;\r
-using System.Linq;\r
-using System.Text;\r
-using System.Threading.Tasks;\r
-using DTXCreator.譜面;\r
-\r
-namespace DTXCreator.コード._05.譜面\r
-{\r
-  /// <summary>\r
-  /// 20160216 chnmr0 難易度自動計算を行うためのクラス\r
-  /// \r
-  /// </summary>\r
-  internal class C難易度自動計算マン\r
-  {\r
-    C譜面管理 scoreManager;\r
-    SortedDictionary<int, CPlayState> Drums;\r
-    SortedDictionary<int, CPlayState> Guitar;\r
-    SortedDictionary<int, CPlayState> Bass;\r
-\r
-    public static int GtV; // 譜面管理者必要なため\r
-    public static int BsV;\r
-\r
-    decimal currentBpm;\r
-\r
-    static readonly decimal[] Coefs = new decimal[4] { 0.5m, 1m, 1.1m, 1.2m };\r
-    static readonly int[,] GtQCoefs = new int[4, 4] \r
-        { // v new Release -> newPress \r
-          {0, 2, 2, 1},\r
-          {2, 2, 3, 0},\r
-          {2, 3, 0, 0},\r
-          {1, 0, 0, 0} \r
-        };\r
-    static readonly int[] LvBase = new int[6] { 1, 10, 30, 50, 70, 90 };\r
-\r
-    internal class CPlayState\r
-    {\r
-      List<Cチップ> state;\r
-\r
-      public CPlayState()\r
-      {\r
-        state = new List<Cチップ>();\r
-      }\r
-\r
-      public void AddChip(Cチップ t)\r
-      {\r
-        // 重複しない前提\r
-        state.Add(t);\r
-      }\r
-\r
-      public int Count\r
-      {\r
-        get\r
-        {\r
-          return state.Count;\r
-        }\r
-      }\r
-\r
-      public Cチップ this[int index]\r
-      {\r
-        get\r
-        {\r
-          return state[index];\r
-        }\r
-      }\r
-\r
-      public IEnumerable<Cチップ> State\r
-      {\r
-        get\r
-        {\r
-          return state;\r
-        }\r
-      }\r
-\r
-      /// <summary>\r
-      /// 次の状態で演奏状態が変わる(叩かれる→叩かれない,押されてる→離されるなど)レーンの数\r
-      /// </summary>\r
-      /// <param name="next">次の演奏状態</param>\r
-      /// <param name="chipConv">チップコンバータ。チップがアサインされるレーンを示す IEnumerable へ変換する。\r
-      /// ここでのレーンはみかけのレーンではなく、ドラムはチャンネルと同質。ギターチップ変換のために IEnumerable にしたが、現仕様では不要。</param>\r
-      /// <returns>遷移結果。1が新たに演奏される(叩かれる/押される)。0が状態が変わらない。-1は1の反対。</returns>\r
-      private int[] TransitionDifference(CPlayState next, Converter<Cチップ, IEnumerable<int>> chipConv)\r
-      {\r
-        Converter<CPlayState, int[]> stateConv = (playState) =>\r
-        {\r
-          int[] Q = new int[0xff];\r
-          foreach (var chip in playState.State)\r
-          {\r
-            foreach (var laneIdentity in chipConv(chip))\r
-            {\r
-              Q[laneIdentity]++;\r
-            }\r
-          }\r
-          return Q;\r
-        };\r
-\r
-        int[] Q1 = stateConv(this);\r
-        int[] Q2 = stateConv(next);\r
-\r
-        foreach (var x in Q1.Select((t, index) => { return new { t, index }; }))\r
-        {\r
-          Q1[x.index] = Q2[x.index] - Q1[x.index];\r
-        }\r
-        return Q1;\r
-      }\r
-\r
-      public int TransitionCost(int inst, int ms, CPlayState next)\r
-      {\r
-        int ret = 0;\r
-\r
-        if (inst == 0) // Drums\r
-        {\r
-          ret = TransitionDifference(next, (chip) =>\r
-          {\r
-            List<int> a = new List<int>();\r
-\r
-            if (chip.nチャンネル番号00toFF != 0x13)\r
-            {\r
-              a.Add(chip.nチャンネル番号00toFF);\r
-            }\r
-            return a;\r
-          }).Sum((t) => { return t > 0 ? t : -t; }); // スティックで演奏する楽器のうち演奏状態が変わる楽器の数の半分(以下同様)\r
-          ret += TransitionDifference(next, (chip) =>\r
-          {\r
-            List<int> a = new List<int>();\r
-\r
-            if (chip.nチャンネル番号00toFF == 0x13)\r
-            {\r
-              a.Add(chip.nチャンネル番号00toFF);\r
-            }\r
-            return a;\r
-          }).Sum((t) => { return t > 0 ? t : -t; });\r
-        }\r
-        else if (inst != 0) // Guitars\r
-        {\r
-          int[] Q = TransitionDifference(next, (chip) =>\r
-          {\r
-            List<int> a = new List<int>();\r
-\r
-            if (chip.nレーン番号0to == C難易度自動計算マン.GtV || chip.nレーン番号0to == C難易度自動計算マン.BsV)\r
-            {\r
-            }\r
-            else\r
-            {\r
-              a.Add(chip.nレーン番号0to);\r
-            }\r
-            return a;\r
-          });\r
-\r
-          int newPress = Q.Sum((t) => { return t > 0 ? t : 0; });\r
-          int newRelease = Q.Sum((t) => { return t < 0 ? -t : 0; });\r
-\r
-          ret = GtQCoefs[newRelease, newPress];\r
-        }\r
-\r
-        return ret;\r
-      }\r
-    }\r
-\r
-    public C難易度自動計算マン(Cメインフォーム x)\r
-    {\r
-      scoreManager = x.mgr譜面管理者;\r
-      currentBpm = x.dc現在のBPM;\r
-\r
-      GtV = scoreManager.nレーン名に対応するレーン番号を返す("GtV");\r
-      BsV = scoreManager.nレーン名に対応するレーン番号を返す("BsV");\r
-    }\r
-\r
-    public void Prepare()\r
-    {\r
-      // 時間ごとに楽器の演奏状態を求める。\r
-      Drums = new SortedDictionary<int, CPlayState>();\r
-      Guitar = new SortedDictionary<int, CPlayState>();\r
-      Bass = new SortedDictionary<int, CPlayState>();\r
-\r
-      foreach (var pair in scoreManager.dic小節)\r
-      {\r
-        pair.Value.listチップ.Sort();\r
-      }\r
-\r
-      decimal currentTime = 0;\r
-\r
-      foreach (var pair in scoreManager.dic小節)\r
-      {\r
-        int lastGridInThisPhrase = 0;\r
-\r
-        foreach (Cチップ chip in pair.Value.listチップ)\r
-        {\r
-          currentTime += (chip.n位置grid - lastGridInThisPhrase) * (60m / (48m * currentBpm));\r
-          lastGridInThisPhrase = chip.n位置grid;\r
-\r
-          if (scoreManager.IsPlayableChip(chip))\r
-          {\r
-            int ms = (int)(currentTime * 1000);\r
-\r
-            if (scoreManager.IsDrumsChip(chip))\r
-            {\r
-              if (!Drums.ContainsKey(ms))\r
-              {\r
-                Drums.Add(ms, new CPlayState());\r
-              }\r
-              Drums[ms].AddChip(chip);\r
-            }\r
-            else if (scoreManager.IsGuitarChip(chip))\r
-            {\r
-              if (!Guitar.ContainsKey(ms))\r
-              {\r
-                Guitar.Add(ms, new CPlayState());\r
-              }\r
-              Guitar[ms].AddChip(chip);\r
-            }\r
-            else if (scoreManager.IsBassChip(chip))\r
-            {\r
-              if (!Bass.ContainsKey(ms))\r
-              {\r
-                Bass.Add(ms, new CPlayState());\r
-              }\r
-              Bass[ms].AddChip(chip);\r
-            }\r
-          }\r
-          else\r
-          {\r
-            if (chip.nチャンネル番号00toFF == 0x8)\r
-            {\r
-              currentBpm = (decimal)chip.f値_浮動小数;\r
-            }\r
-          }\r
-        }\r
-        currentTime += (pair.Value.n小節長倍率を考慮した現在の小節の高さgrid - lastGridInThisPhrase) * (60m / (48m * currentBpm));\r
-      }\r
-\r
-      /* debug\r
-       * part -1 のズレがあるので DTXM での再生時間とはすこし違う\r
-       */\r
-      using (System.IO.StringWriter sw = new System.IO.StringWriter())\r
-      {\r
-        foreach (var t in Guitar)\r
-        {\r
-          sw.Write(t.Key + "ms");\r
-          foreach (var c in t.Value.State)\r
-          {\r
-            sw.Write(c.nレーン番号0to + ",");\r
-          }\r
-          sw.WriteLine();\r
-        }\r
-        System.Diagnostics.Debug.WriteLine(sw.ToString());\r
-      }\r
-\r
-    }\r
-\r
-    public int DLevel\r
-    {\r
-      get\r
-      {\r
-        return CalculateLevel(0, Drums);\r
-      }\r
-    }\r
-\r
-    public int GLevel\r
-    {\r
-      get\r
-      {\r
-        return CalculateLevel(1, Guitar);\r
-      }\r
-    }\r
-\r
-    public int BLevel\r
-    {\r
-      get\r
-      {\r
-        return CalculateLevel(1, Bass);\r
-      }\r
-    }\r
-\r
-\r
-\r
-    private int CalculateLevel(int inst, SortedDictionary<int, CPlayState> list)\r
-    {\r
-      int ret = 0;\r
-\r
-      if (list.Count > 0)\r
-      {\r
-        int startMs = list.First().Key;\r
-        int endMs = list.Last().Key;\r
-        int prevms = list.First().Key;\r
-        CPlayState prev = list.First().Value;\r
-\r
-        int totalCost = 0;\r
-\r
-        foreach (var x in list.Select((t, index) => { return new { t, index }; }))\r
-        {\r
-          int idx = x.index;\r
-          int ms = x.t.Key;\r
-          CPlayState state = x.t.Value;\r
-\r
-          if (idx == 0)\r
-          {\r
-            continue;\r
-          }\r
-\r
-          // 遷移難度\r
-          int cost = prev.TransitionCost(inst, ms - prevms, state);\r
-          prevms = ms;\r
-          prev = state;\r
-\r
-          totalCost += cost;\r
-        }\r
-\r
-        if (endMs == startMs)\r
-        {\r
-          endMs = startMs + 1;\r
-        }\r
-        // 1秒間あたりの遷移コスト\r
-        // 1秒間に 14 回をドラムの最大難易度とする\r
-        // 1秒間に 7 回を3弦の最大難易度とする\r
-        decimal lvBase = 1000 * (decimal)totalCost / (endMs - startMs);\r
-        System.Diagnostics.Debug.WriteLine(lvBase);\r
-        decimal lvMax = 14;\r
-\r
-        if (lvBase < 1)\r
-        {\r
-          lvBase = 1;\r
-        }\r
-\r
-        if (inst != 0)\r
-        {\r
-          lvMax = 7;\r
-        }\r
-\r
-        if (lvBase > lvMax)\r
-        {\r
-          lvBase = lvMax;\r
-        }\r
-\r
-        ret = (int)(99m * (lvBase - 1) / (lvMax - 1));\r
-        if (ret < 1)\r
-        {\r
-          ret = 1;\r
-        }\r
-        else if (ret > 99)\r
-        {\r
-          ret = 99;\r
-        }\r
-      }\r
-\r
-\r
-\r
-      return ret;\r
-    }\r
-  }\r
-}\r