static void Main(string[] args) { // 適当に計算したりするテスト用コンソールです SeedSearcher searcher = new SeedSearcher(SeedSearcher.Mode.Cuda35); SeedSearcher.CudaInitialize(); SeedSearcher.SetCudaCondition(0, 31, 27, 3, 19, 18, 31, 1, 15, 3, false, 3, 2); SeedSearcher.SetCudaCondition(1, 31, 9, 31, 31, 15, 31, 1, 18, 2, false, 3, 4); SeedSearcher.SetCudaCondition(2, 31, 31, 31, 1, 31, 27, 1, 6, 2, true, 4, 4); SeedSearcher.SetCudaCondition(3, 31, 2, 23, 31, 31, 31, 1, 15, 2, true, 4, 4); SeedSearcher.SetCudaTargetCondition6(27, 3, 19, 18, 9, 15); searcher.CudaLoopPartition = 8; Console.WriteLine("計算中..."); // 時間計測 var sw = new System.Diagnostics.Stopwatch(); sw.Start(); // 計算 searcher.Calculate(false, 0, 0, null); sw.Stop(); Console.WriteLine($"{searcher.Result.Count} results"); foreach (ulong result in searcher.Result) { Console.WriteLine($"0x{result:X}"); } Console.WriteLine($"{sw.ElapsedMilliseconds}[ms]"); }
static void Main(string[] args) { // 適当に計算したりするテスト用コンソールです SeedSearcher searcher = new SeedSearcher(SeedSearcher.Mode.Star35_6); // パラメータを設定 /* * Console.WriteLine("1匹目: "); * string[] str = Console.ReadLine().Split(' '); * SeedSearcher.SetFirstCondition(int.Parse(str[0]), int.Parse(str[1]), int.Parse(str[2]), int.Parse(str[3]), int.Parse(str[4]), int.Parse(str[5]), int.Parse(str[6]), int.Parse(str[7])); * * Console.WriteLine("2匹目: "); * string[] str2 = Console.ReadLine().Split(' '); * SeedSearcher.SetNextCondition(int.Parse(str2[0]), int.Parse(str2[1]), int.Parse(str2[2]), int.Parse(str2[3]), int.Parse(str2[4]), int.Parse(str2[5]), int.Parse(str2[6]), int.Parse(str2[7]), false); * * Console.WriteLine("計算中..."); * */ Console.WriteLine("1匹目: "); string[] str = Console.ReadLine().Split(' '); // SeedSearcher.SetSixCondition(int.Parse(str[0]), int.Parse(str[1]), int.Parse(str[2]), int.Parse(str[3]), int.Parse(str[4]), int.Parse(str[5]), int.Parse(str[6]), int.Parse(str[7]), int.Parse(str[8])); Console.WriteLine("2匹目: "); string[] str2 = Console.ReadLine().Split(' '); Console.WriteLine("計算中..."); // 時間計測 var sw = new System.Diagnostics.Stopwatch(); sw.Start(); // 計算 // searcher.CalculateSix(); sw.Stop(); Console.WriteLine($"{searcher.Result.Count} results"); foreach (ulong result in searcher.Result) { Console.WriteLine($"0x{result:X}"); } Console.WriteLine($"{sw.ElapsedMilliseconds}[ms]"); }
static void Main(string[] args) { // 適当に計算したりするテスト用コンソールです // 0x123イベントレイド // マホミル★3 // 4匹目3V 31 28 31 4 31 11 うっかりや 夢 ♀固定 個性1 うたれづよい // マホミル★4 // 4匹目4V 31 10 31 31 31 27 ひかえめ 特性1 ♀固定 個性1 うたれづよい // マホミル★3 // 5匹目3V 27 21 31 31 18 31 のうてんき 特性1 ♀固定 個性2 うたれづよい // マホミル★3 // 6匹目3V 31 31 3 17 31 6 さみしがり 特性1 ♀固定 個性3 みえっぱり SeedSearcher searcher = new SeedSearcher(SeedSearcher.Mode.Cuda35); SeedSearcher.CudaInitialize(); SeedSearcher.SetCudaCondition(0, 31, 28, 31, 4, 31, 11, 2, 19, 2, true, 4, 3); SeedSearcher.SetCudaCondition(1, 31, 10, 31, 31, 31, 27, 0, 15, 2, true, 4, 4); SeedSearcher.SetCudaCondition(2, 27, 21, 31, 31, 18, 31, 0, 9, 2, true, 4, 3); SeedSearcher.SetCudaCondition(3, 31, 31, 3, 17, 31, 6, 0, 1, 5, true, 4, 3); SeedSearcher.SetCudaTargetCondition5(28, 4, 11, 10, 27); searcher.CudaLoopPartition = 0; Console.WriteLine("計算中..."); // 時間計測 var sw = new System.Diagnostics.Stopwatch(); sw.Start(); // 計算 searcher.Calculate(false, 0, 0, null); sw.Stop(); Console.WriteLine($"{searcher.Result.Count} results"); foreach (ulong result in searcher.Result) { Console.WriteLine($"0x{result:X}"); } Console.WriteLine($"{sw.ElapsedMilliseconds}[ms]"); }
// 検索処理共通 async void SearchImpl(SeedSearcher searcher) { int maxRerolls = 0; try { maxRerolls = int.Parse(f_TextBoxRerolls.Text); } catch (Exception) { } bool isEnableStop = f_CheckBoxStop.Checked; // ボタンを無効化 f_ButtonStartSearch.Enabled = false; f_ButtonStartSearch.Text = Messages.Instance.SystemLabel["Searching"]; f_ButtonStartSearch.BackColor = System.Drawing.Color.WhiteSmoke; // 時間計測 bool isShowResultTime = f_CheckBoxShowResultTime.Checked; System.Diagnostics.Stopwatch stopWatch = null; if (isShowResultTime) { stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); } await Task.Run(() => { searcher.Calculate(isEnableStop, maxRerolls); }); if (isShowResultTime && stopWatch != null) { stopWatch.Stop(); MessageBox.Show($"{stopWatch.ElapsedMilliseconds}[ms]"); } f_ButtonStartSearch.Enabled = true; f_ButtonStartSearch.Text = Messages.Instance.SystemLabel["StartSearch"]; f_ButtonStartSearch.BackColor = System.Drawing.Color.GreenYellow; // 結果が見つからなかったらエラー if (searcher.Result.Count == 0) { // エラー CreateErrorDialog(Messages.Instance.ErrorMessage["NotFound"]); return; } else { if (searcher.Result.Count > 1) { using (StreamWriter sw = new StreamWriter("seeds.txt")) { foreach (var t in searcher.Result) { sw.WriteLine($"{t:X}"); } } MessageBox.Show(Messages.Instance.SystemMessage["FindManySeeds"], Messages.Instance.SystemMessage["ResultDialogTitle"], MessageBoxButtons.OK, MessageBoxIcon.Information); } f_TextBoxResultSeed.Text = $"{searcher.Result[0]:X}"; f_TabControlMain.SelectedIndex = 2; // 見つかったらリスト出力 ListGenerate(); } }
// ★3~5検索 void SeedSearch35() { bool isCheckFailed = false; string errorText = ""; // フォームから必要な情報を取得 int[] ivs = new int[18]; for (int i = 0; i < 18; ++i) { try { ivs[i] = int.Parse(m_TextBoxIvsList35[i].Text); } catch (Exception) { // エラー errorText = Messages.Instance.ErrorMessage["IvsFormat"]; isCheckFailed = true; } if (ivs[i] < 0 || ivs[i] > 31) { // エラー errorText = Messages.Instance.ErrorMessage["IvsFormat"]; isCheckFailed = true; } } if (isCheckFailed) { CreateErrorDialog(errorText); return; } // 1匹目はVが2or3箇所じゃないとエラー int strict = (Get35Mode() == Star35PanelMode.From3V ? 3 : 2); int c = 0; for (int i = 0; i < 6; ++i) { if (ivs[i] == 31) { ++c; } } if (c != strict) { // エラー if (strict == 3) { CreateErrorDialog(Messages.Instance.ErrorMessage["IvsStrict351_3V"]); return; } else { CreateErrorDialog(Messages.Instance.ErrorMessage["IvsStrict351_2V"]); return; } } int ability1 = f_ComboBoxAbility_351.SelectedIndex; int ability2 = f_ComboBoxAbility_352.SelectedIndex; int ability3 = f_ComboBoxAbility_353.SelectedIndex; if (ability1 >= 2) { ability1 = ability1 * 3 - 7; } if (ability2 >= 2) { ability2 = ability2 * 3 - 7; } if (ability3 >= 2) { ability3 = ability3 * 3 - 7; } int nature1 = Messages.Instance.Nature[f_ComboBoxNature_351.Text]; int nature2 = Messages.Instance.Nature[f_ComboBoxNature_352.Text]; int nature3 = Messages.Instance.Nature[f_ComboBoxNature_353.Text]; bool noGender1 = f_CheckBoxNoGender_351.Checked; bool noGender2 = f_CheckBoxNoGender_352.Checked; bool noGender3 = f_CheckBoxNoGender_353.Checked; bool isDream1 = f_CheckBoxDream_351.Checked; bool isDream2 = f_CheckBoxDream_352.Checked; bool isDream3 = f_CheckBoxDream_353.Checked; int characteristic1 = Messages.Instance.Characteristic[f_ComboBoxCharacteristic_351.Text]; int characteristic2 = Messages.Instance.Characteristic[f_ComboBoxCharacteristic_352.Text]; int characteristic3 = Messages.Instance.Characteristic[f_ComboBoxCharacteristic_353.Text]; var mode = Get35Mode(); // 計算開始 SeedSearcher searcher = new SeedSearcher(mode == Star35PanelMode.From2V ? SeedSearcher.Mode.Star35_6 : SeedSearcher.Mode.Star35_5); SeedSearcher.SetSixFirstCondition(ivs[0], ivs[1], ivs[2], ivs[3], ivs[4], ivs[5], ability1, nature1, characteristic1, noGender1, isDream1); SeedSearcher.SetSixSecondCondition(ivs[6], ivs[7], ivs[8], ivs[9], ivs[10], ivs[11], ability2, nature2, characteristic2, noGender2, isDream2); SeedSearcher.SetSixThirdCondition(ivs[12], ivs[13], ivs[14], ivs[15], ivs[16], ivs[17], ability3, nature3, characteristic3, noGender3, isDream3); int vCount = 0; for (int i = 0; i < 6; ++i) { if (ivs[6 + i] == 31) { ++vCount; } } // 3V+自然発生の4Vは考慮しない if (vCount > 4) { vCount = 4; } // 遺伝箇所チェック bool[] vFlag = { false, false, false, false, false, false }; for (int i = 0; i < 6; ++i) { if (ivs[i] == 31) { vFlag[i] = true; } } c = (mode == Star35PanelMode.From3V ? 3 : 2); int[] conditionIv = new int[6]; int cursor = 0; for (int i = 0; i < 6; ++i) { if (ivs[i] != 31) { conditionIv[cursor++] = ivs[i]; int vPos = ivs[i] % 8; if (vPos < 6 && vFlag[vPos] == false) { vFlag[vPos] = true; ++c; if (c == vCount) // 遺伝終わり { break; } } } } // 条件ベクトルを求める c = 0; for (int i = 0; i < 6; ++i) { if (vFlag[i] == false) { conditionIv[cursor++] = ivs[i + 6]; if (cursor == 6) { break; } } } if (mode == Star35PanelMode.From2V) { SeedSearcher.SetTargetCondition6(conditionIv[0], conditionIv[1], conditionIv[2], conditionIv[3], conditionIv[4], conditionIv[5]); } else if (mode == Star35PanelMode.From3V) { SeedSearcher.SetTargetCondition5(conditionIv[0], conditionIv[1], conditionIv[2], conditionIv[3], conditionIv[4]); } SearchImpl(searcher); }
// ★1~2検索 void SeedSearch12() { bool isCheckFailed = false; string errorText = ""; // フォームから必要な情報を取得 int[] ivs = new int[12]; for (int i = 0; i < 12; ++i) { try { ivs[i] = int.Parse(m_TextBoxIvsList12[i].Text); } catch (Exception) { // エラー errorText = Messages.Instance.ErrorMessage["IvsFormat"]; isCheckFailed = true; } if (ivs[i] < 0 || ivs[i] > 31) { // エラー errorText = Messages.Instance.ErrorMessage["IvsFormat"]; isCheckFailed = true; } } if (isCheckFailed) { CreateErrorDialog(errorText); return; } // 1匹目はVが1箇所じゃないとエラー int c = 0; for (int i = 0; i < 6; ++i) { if (ivs[i] == 31) { ++c; } } if (c != 1) { // エラー CreateErrorDialog(Messages.Instance.ErrorMessage["IvsStrict1"]); return; } // 2匹目はVが1箇所以上じゃないとエラー c = 0; for (int i = 6; i < 12; ++i) { if (ivs[i] == 31) { ++c; } } if (c < 1) { // エラー CreateErrorDialog(Messages.Instance.ErrorMessage["IvsStrict2"]); return; } int ability1 = f_ComboBoxAbility_1.SelectedIndex; int ability2 = f_ComboBoxAbility_2.SelectedIndex; if (ability1 >= 2) { ability1 = ability1 * 3 - 7; } if (ability2 >= 2) { ability2 = ability2 * 3 - 7; } int nature1 = Messages.Instance.Nature[f_ComboBoxNature_1.Text]; int nature2 = Messages.Instance.Nature[f_ComboBoxNature_2.Text]; bool noGender1 = f_CheckBoxNoGender_1.Checked; bool noGender2 = f_CheckBoxNoGender_2.Checked; bool isDream1 = f_CheckBoxDream_1.Checked; bool isDream2 = f_CheckBoxDream_2.Checked; // 計算開始 SeedSearcher searcher = new SeedSearcher(SeedSearcher.Mode.Star12); SeedSearcher.SetFirstCondition(ivs[0], ivs[1], ivs[2], ivs[3], ivs[4], ivs[5], ability1, nature1, noGender1, isDream1); SeedSearcher.SetNextCondition(ivs[6], ivs[7], ivs[8], ivs[9], ivs[10], ivs[11], ability2, nature2, noGender2, isDream2); SearchImpl(searcher); }