diff --git a/FloatTool/Common/Calculations.cs b/FloatTool/Common/Calculations.cs index 5006a97..1296ca0 100644 --- a/FloatTool/Common/Calculations.cs +++ b/FloatTool/Common/Calculations.cs @@ -53,28 +53,7 @@ public static bool NextCombination(int[] num, int n) } return false; } - - public static IEnumerable Combinations(InputSkin[] elem, int start, int skip) - { - int size = elem.Length - 10; - int[] numbers = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - InputSkin[] resultList = new InputSkin[10]; - bool running = true; - - for (int i = 0; i < start; i++) - running = NextCombination(numbers, size); - - while (running) - { - for (int i = 0; i < 10; ++i) - resultList[i] = elem[numbers[i]]; - yield return resultList; - - for (int i = 0; i < skip; i++) - running = NextCombination(numbers, size); - } - } - + public static long GetCombinationsCount(int poolSize) { BigInteger fact1 = poolSize; diff --git a/FloatTool/Views/BenchmarkWindow.xaml.cs b/FloatTool/Views/BenchmarkWindow.xaml.cs index 6e7fb50..47d4f81 100644 --- a/FloatTool/Views/BenchmarkWindow.xaml.cs +++ b/FloatTool/Views/BenchmarkWindow.xaml.cs @@ -79,8 +79,21 @@ private void PublishResult_Click(object sender, RoutedEventArgs e) private static void FloatCraftWorkerThread(CraftSearchSetup options) { - foreach (InputSkin[] resultList in Calculations.Combinations(options.SkinPool, options.ThreadID, options.ThreadCount)) + int size = options.SkinPool.Length - 10; + int[] numbers = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + InputSkin[] resultList = new InputSkin[10]; + bool running = true; + + for (int i = 0; i < options.ThreadID; i++) + running = Calculations.NextCombination(numbers, size); + + while (running) { + for (int i = 0; i < 10; ++i) + resultList[i] = options.SkinPool[numbers[i]]; + + // Check if the combination is valid + for (int i = 0; i < options.Outcomes.Length; ++i) { double resultFloat = Calculations.Craft( @@ -115,7 +128,12 @@ private static void FloatCraftWorkerThread(CraftSearchSetup options) } Interlocked.Increment(ref PassedCombinations); + + // Get next combination + for (int i = 0; i < options.ThreadCount; i++) + running = Calculations.NextCombination(numbers, size); } + } private void StartBenchmark_Click(object sender, RoutedEventArgs e) diff --git a/FloatTool/Views/MainWindow.xaml.cs b/FloatTool/Views/MainWindow.xaml.cs index 29ea6ec..5809eba 100644 --- a/FloatTool/Views/MainWindow.xaml.cs +++ b/FloatTool/Views/MainWindow.xaml.cs @@ -186,8 +186,21 @@ private void SetStatus(string stringCode) private void FloatCraftWorkerThread(CraftSearchSetup options) { - foreach (InputSkin[] resultList in Calculations.Combinations(options.SkinPool, options.ThreadID, options.ThreadCount)) + int size = options.SkinPool.Length - 10; + int[] numbers = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + InputSkin[] resultList = new InputSkin[10]; + bool running = true; + + for (int i = 0; i < options.ThreadID; i++) + running = Calculations.NextCombination(numbers, size); + + while (running) { + for (int i = 0; i < 10; ++i) + resultList[i] = options.SkinPool[numbers[i]]; + + // Check if the combination is valid + for (int i = 0; i < options.Outcomes.Length; ++i) { double resultFloat = Calculations.Craft( @@ -249,6 +262,11 @@ private void FloatCraftWorkerThread(CraftSearchSetup options) if (CancellationToken.IsCancellationRequested) break; + + // Get next combination + + for (int i = 0; i < options.ThreadCount; i++) + running = Calculations.NextCombination(numbers, size); } }