private void SearchByCurrSeed_Click(object sender, EventArgs e) { SFMT sfmt = new SFMT((uint)Seed.Value); for (int i = 0; i < Frame_min.Value; i++) { sfmt.NextUInt64(); } if (CurrSeed.Text == "") { return; } for (int i = (int)Frame_min.Value; i < Frame_max.Value; i++) { string tmp = sfmt.NextInt64().ToString("X16"); if (tmp.Contains(CurrSeed.Text)) { Result_Text.Text = $"{i} F"; Frame_min.Value = i; Reset_Click(null, null); CalcList_Click(null, null); return; } } Result_Text.Text = NORESULT_STR[lindex]; }
private int[] CalcFrame(int min, int max) { uint InitialSeed = (uint)Seed.Value; int NPC_n = (int)NPC.Value + 1; SFMT sfmt = new SFMT(InitialSeed); for (int i = 0; i < min; i++) { sfmt.NextUInt64(); } int n_count = 0; int[] remain_frame = new int[NPC_n]; //total_frame[0] Start; total_frame[1] Duration int[] total_frame = new int[2]; bool[] blink_flag = new bool[NPC_n]; int timer = 0; while (min + n_count <= max) { //NPC Loop for (int i = 0; i < NPC_n; i++) { if (remain_frame[i] > 0) { remain_frame[i]--; } if (remain_frame[i] == 0) { //Blinking if (blink_flag[i]) { remain_frame[i] = (int)(sfmt.NextUInt64() % 3) == 0 ? 36 : 30; n_count++; blink_flag[i] = false; } //Not Blinking else { if ((int)(sfmt.NextUInt64() & 0x7F) == 0) { remain_frame[i] = 5; blink_flag[i] = true; } n_count++; } } } total_frame[timer]++; if (min + n_count == max) { timer = 1; } } return(total_frame); }
public static void CreateBuffer(SFMT sfmt) { int RandBuffSize = 200; if (Considerdelay) { RandBuffSize += npcnumber * delaytime; } Rand.Clear(); for (int i = 0; i < RandBuffSize; i++) { Rand.Add(sfmt.NextUInt64()); } }
private void createtimeline() { SFMT sfmt = new SFMT((uint)Seed.Value); bool Isevent = Poke.SelectedIndex == 1; for (int i = 0; i < (int)Frame_min.Value; i++) { sfmt.NextUInt64(); } List <DataGridViewRow> list = new List <DataGridViewRow>(); DGV.Rows.Clear(); var st = CreateNPCStatus(sfmt); var setting = getSettings(); var rng = getRNGSettings(); RNGSearch.ResetNPCStatus(); RNGSearch.CreateBuffer(sfmt); if (Isevent) { e = geteventsetting(); } int totaltime = (int)TimeSpan.Value * 30; int frame = (int)Frame_min.Value; int frameadvance = 0; for (int i = 0; i <= totaltime; i++) { RNGSearch.remain_frame = (int[])st.remain_frame.Clone(); RNGSearch.blink_flag = (bool[])st.blink_flag.Clone(); RNGSearch.RNGResult result = Isevent ? rng.GenerateEvent(e) : rng.Generate(); result.realtime = i; frameadvance = st.NextState(); frame += frameadvance; for (int j = 0; j < frameadvance; j++) { RNGSearch.Rand.RemoveAt(0); RNGSearch.Rand.Add(sfmt.NextUInt64()); } if (!frameMatch(result, setting)) { continue; } list.Add(getRow_Sta(frame - frameadvance, rng, result, DGV)); if (list.Count > 100000) { break; } } DGV.Rows.AddRange(list.ToArray()); DGV.CurrentCell = null; }
private void StationarySearch() { int max, min; if (AroundTarget.Checked) { min = (int)Time_max.Value - 100; max = (int)Time_max.Value + 100; } else { min = (int)Frame_min.Value; max = (int)Frame_max.Value; } bool Isevent = Poke.SelectedIndex == 1; SFMT sfmt = new SFMT((uint)Seed.Value); List <DataGridViewRow> list = new List <DataGridViewRow>(); DGV.Rows.Clear(); var setting = getSettings(); var rng = getRNGSettings(); //Blink flag history int blink_flag = 0; int UnsafeRange = 41 * (int)NPC.Value; if (UnsafeRange == 0) { for (int i = 0; i < min - 2; i++) { sfmt.NextUInt64(); } for (int i = 0; i < 2; i++) { switch (blink_flag) { case 0: if ((sfmt.NextUInt64() & 0x7F) == 0) { blink_flag = 1; } break; case 1: blink_flag = (sfmt.NextUInt64() % 3) == 0 ? 36 : 30; break; } } } else if (!Honey.Checked) { for (int i = 0; i < Math.Max(418, min - UnsafeRange); i++) { sfmt.NextUInt64(); } for (int i = Math.Max(418, min - UnsafeRange); i < min; i++) { if ((sfmt.NextUInt64() & 0x7F) == 0) { blink_flag = UnsafeRange; } else if (blink_flag > 0) { blink_flag--; } } } else { for (int i = 0; i < min; i++) { sfmt.NextUInt64(); } } RNGSearch.CreateBuffer(sfmt); if (Isevent) { e = geteventsetting(); } for (int i = min; i <= max; i++, RNGSearch.Rand.RemoveAt(0), RNGSearch.Rand.Add(sfmt.NextUInt64())) { RNGSearch.RNGResult result = Isevent ? rng.GenerateEvent(e) : rng.Generate(); if (NPC.Value == 0) { switch (blink_flag) { case 0: if (result.Blink == 1) { blink_flag = 1; } break; case 1: blink_flag = (result.row_r % 3) == 0 ? 36 : 30; result.Blink = 5; break; default: result.Blink = blink_flag; blink_flag = 0; break; } } else if (!Honey.Checked) { if (result.Blink == 1) { if (blink_flag > 0) { result.Blink = -2; } blink_flag = UnsafeRange; } else if (blink_flag > 0) { blink_flag--; result.Blink = -1; } } if (!frameMatch(result, setting)) { continue; } list.Add(getRow_Sta(i, rng, result, DGV)); if (list.Count > 100000) { break; } } DGV.Rows.AddRange(list.ToArray()); DGV.CurrentCell = null; }
private void QRSearch_Click(object sender, EventArgs e) { uint InitialSeed = (uint)Seed.Value; int min = (int)Frame_min.Value; int max = (int)Frame_max.Value; if (QRList.Text == "") { return; } string[] str = QRList.Text.Split(','); try { int[] Clock_List = str.Select(s => int.Parse(s)).ToArray(); int[] temp_List = new int[Clock_List.Length]; SFMT sfmt = new SFMT(InitialSeed); SFMT seed = new SFMT(InitialSeed); bool flag = false; QRResult.Items.Clear(); for (int i = 0; i < min; i++) { sfmt.NextUInt64(); } int cnt = 0; int tmp = 0; for (int i = min; i <= max; i++, sfmt.NextUInt64()) { seed = (SFMT)sfmt.DeepCopy(); for (int j = 0; j < Clock_List.Length; j++) { temp_List[j] = (int)(seed.NextUInt64() % 17); } if (temp_List.SequenceEqual(Clock_List)) { flag = true; } if (flag) { flag = false; switch (lindex) { case 0: QRResult.Items.Add($"The last clock is at {i + Clock_List.Length - 1}F, you're at {i + Clock_List.Length + 1}F after quiting QR"); break; case 1: QRResult.Items.Add($"最后的指针在 {i + Clock_List.Length - 1} 帧,退出QR后在 {i + Clock_List.Length + 1} 帧"); break; } cnt++; tmp = i + Clock_List.Length + 1; } } if (cnt == 1) { Time_min.Value = tmp; } } catch { Error(SETTINGERROR_STR[lindex] + L_QRList.Text); } }
private NPCStatus CreateNPCStatus(SFMT sfmt) { NPCStatus.npcnumber = (int)NPC.Value + 1; NPCStatus.smft = (SFMT)sfmt.DeepCopy(); return(new NPCStatus()); }