Skip to content

Commit

Permalink
v.0.8.0
Browse files Browse the repository at this point in the history
64-bit mode, x3 speed, bug fixes, pre-OpenCL worker
  • Loading branch information
Prevter committed Jun 30, 2021
1 parent 44b3887 commit 733ade2
Show file tree
Hide file tree
Showing 2,383 changed files with 2,578,750 additions and 935 deletions.
Binary file added .vs/FloatToolGUI/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file modified .vs/FloatToolGUI/v16/.suo
Binary file not shown.
Binary file added .vs/FloatToolGUI/v16/Browse.VC.db
Binary file not shown.
Binary file added .vs/FloatToolGUI/v16/Solution.VC.db
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .vs/FloatToolGUI/v16/ipch/cdff0233cf5f4afa.ipch
Binary file not shown.
22 changes: 10 additions & 12 deletions FloatToolGUI/Benchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,18 @@ public enum SearchMode
SearchMode CurrentSearchMode = SearchMode.Equal;
private Pallete CurrentPallete;

public void parseCraft(List<InputSkin> inputs, List<Skin> outputs, string want)
public void parseCraft(InputSkin[] inputs, Skin[] outputs, string want)
{
decimal wantFloat = 1;
if (CurrentSearchMode != SearchMode.Equal)
decimal.TryParse(want, NumberStyles.Any, CultureInfo.InvariantCulture, out wantFloat);

var inputArr = inputs.ToArray();

for (int i = 0; i < outputs.Count; i++)
for (int i = 0; i < outputs.Length; ++i)
{
decimal flotOrigin = Math.Round(craft(inputArr, outputs[i].MinFloat, outputs[i].FloatRange), 14);
decimal flotOrigin = Math.Round(craft(inputs, outputs[i].MinFloat, outputs[i].FloatRange), 14);

if (
(flotOrigin.ToString(CultureInfo.InvariantCulture).StartsWith(want, StringComparison.Ordinal) && CurrentSearchMode == SearchMode.Equal) ||
flotOrigin.ToString(CultureInfo.InvariantCulture).StartsWith(want, StringComparison.Ordinal) ||
(CurrentSearchMode == SearchMode.Less && (flotOrigin < wantFloat)) ||
(CurrentSearchMode == SearchMode.Greater && (flotOrigin > wantFloat))
)
Expand All @@ -54,11 +52,11 @@ public void parseCraft(List<InputSkin> inputs, List<Skin> outputs, string want)
}
}

public void secndThread(List<Skin> craftList, string wanted, List<InputSkin> pool, int start, int skip)
public void secndThread(Skin[] craftList, string wanted, InputSkin[] pool, int start, int skip)
{
foreach (IEnumerable<InputSkin> pair in Combinations(pool, start, skip))
foreach (InputSkin[] _ in Combinations(pool, start, skip))
{
parseCraft(pair.ToList(), craftList, wanted);
parseCraft(_, craftList, wanted);
Interlocked.Increment(ref currComb);
}
}
Expand Down Expand Up @@ -142,7 +140,7 @@ private void StartCalculation()
for (int i = 0; i < threads; i++)
{
var startIndex = i;
Thread newThread = new Thread(() => secndThread(outcomes, "1", inputSkins, startIndex, threads));
Thread newThread = new Thread(() => secndThread(outcomes.ToArray(), "1", inputSkins.ToArray(), startIndex, threads));
newThread.Start();
t2.Add(newThread);
}
Expand All @@ -168,11 +166,11 @@ private void StartCalculation()

timer.Stop();
TimeSpan timespan = timer.Elapsed;
Logger.Log($"[{DateTime.Now}]: Benchmark ended, speed = {Math.Round(currComb / timespan.TotalSeconds)}");
Logger.Log($"[{DateTime.Now}]: Benchmark ended, speed = {(uint)((double)currComb * (double)Stopwatch.Frequency / timer.ElapsedTicks)}");
Invoke((MethodInvoker)(() =>
{
submitScoreBtn.Enabled = true;
speedLabel.Text = $"{Math.Round(currComb / timespan.TotalSeconds)} к/с";
speedLabel.Text = $"{(uint)((double)currComb * (double)Stopwatch.Frequency / timer.ElapsedTicks)} к/с";
thread1.Abort();
}
));
Expand Down
57 changes: 36 additions & 21 deletions FloatToolGUI/Calculation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace FloatToolGUI
Expand All @@ -30,11 +31,21 @@ static public string GetOutputWearString(float[] floats, float minWear, float ma
static public decimal craft(InputSkin[] ingridients, decimal minFloat, decimal floatRange)
{
decimal avgFloat = ingridients[0].WearValue;
for (int i = 1; i < 10; i++)
avgFloat += ingridients[1].WearValue;
avgFloat += ingridients[2].WearValue;
avgFloat += ingridients[3].WearValue;
avgFloat += ingridients[4].WearValue;
avgFloat += ingridients[5].WearValue;
avgFloat += ingridients[6].WearValue;
avgFloat += ingridients[7].WearValue;
avgFloat += ingridients[8].WearValue;
avgFloat += ingridients[9].WearValue;

/*for (int i = 1; i < 10; ++i)
{
avgFloat += ingridients[i].WearValue;
}
avgFloat /= 10;
}*/
//avgFloat /= 10;
return floatRange * avgFloat + minFloat;
}

Expand All @@ -45,10 +56,10 @@ static public decimal craft(InputSkin[] ingridients, decimal minFloat, decimal f
/// <param name="minFloat">Minimal wear value of skin that is going to be crafted</param>
/// <param name="maxFloat">Maximum wear value of skin that is going to be crafted</param>
/// <returns>Float wear value in string</returns>
static public string craftF(List<InputSkin> ingridients, float minFloat, float maxFloat)
static public string craftF(InputSkin[] ingridients, float minFloat, float maxFloat)
{
float[] arrInput = new float[10];
for (int i = 0; i < 10; i++)
for (int i = 0; i < 10; ++i)
{
arrInput[i] = (float)ingridients[i].WearValue;
}
Expand Down Expand Up @@ -90,37 +101,41 @@ public static List<Skin>[] GroupOutcomes(List<dynamic> skins)
return allList.ToArray();
}

static public bool NextCombination(IList<int> num, int n)
static public bool NextCombination(int[] num, int n)
{
bool finished;
var changed = finished = false;
for (var i = 9; !finished && !changed; i--)
bool finished = false;
bool changed = false;
for (int i = 9; !finished && !changed; --i)
{
if (num[i] < n - 10 + i)
if (num[i] < n + i)
{
num[i]++;
++num[i];
if (i < 9)
for (var j = i + 1; j < 10; j++)
for (int j = i + 1; j < 10; ++j)
num[j] = num[j - 1] + 1;
changed = true;
return true;
}
finished = i == 0;
}
return changed;
}

static public IEnumerable Combinations<T>(IEnumerable<T> elements, int start, int skip)
static public IEnumerable<InputSkin[]> Combinations(InputSkin[] elem, int start, int skip)
{
var elem = elements.ToArray();
var size = elem.Length;
if (10 > size) yield break;
var numbers = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
uint step = 0;
int size = elem.Length - 10;
int[] numbers = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
long step = 0;
InputSkin[] resultList = new InputSkin[10];

do
{
if ((step - start) % skip == 0)
yield return numbers.Select(n => elem[n]);
step++;
{
for (int i = 0; i < 10; ++i) resultList[i] = elem[numbers[i]];
yield return resultList;
}
++step;
//Interlocked.Increment(ref step);
} while (NextCombination(numbers, size));
}
}
Expand Down
6 changes: 3 additions & 3 deletions FloatToolGUI/CustomControls/CustomToggleSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ namespace FloatToolGUI.CustomControls
public partial class CustomToggleSwitch : UserControl
{
private bool check = false;
public bool Checked { get {return check; } set {check = value; Invalidate(); } }
public Color TurnedOffColor { get; set; }
public bool Checked { get { return check; } set { check = value; Invalidate(); } }
public Color TurnedOffColor { get; set; } = Color.FromArgb(44, 44, 44);

public Color TurnedOnColor { get; set; }
public Color TurnedOnColor { get; set; } = Color.Green;

public CustomToggleSwitch()
{
Expand Down
Loading

0 comments on commit 733ade2

Please sign in to comment.