Zarroc2762 / E7-Gear-Optimizer

27 stars 22 forks source link

Crash on optimize #16

Closed Alexkovka closed 5 years ago

Alexkovka commented 5 years ago

** Ausnahmetext ** System.ArgumentOutOfRangeException: Der Wert -1 ist für Value ungültig. Value sollte zwischen 'minimum' und 'maximum' liegen. Parametername: Value bei System.Windows.Forms.ProgressBar.set_Value(Int32 value) bei System.Progress`1.InvokeHandlers(Object state)

** Geladene Assemblys **

Hi, at around 228 Items added to the calculation the optimization crashes right at the start.

thx for reading i love your work.

NietonoZhurah commented 5 years ago

i am getting the same issue as well. it seems to be when using both Equipped items and locked items. Using one or the other does not seem to trigger the crash on optimize. 41 heroes, 236 items in my json for comparison.

Edit: Still happens no matter the way options are selected.... i had to delete some items, and it seemed to help. at 211 items with 43 heroes.

wsauret commented 5 years ago

I've had this happen before, but only once the permutations were more than 1 billion. If I keep the permutations lower than that, then it seems to work just fine. A memory error, perhaps?

Zarroc2762 commented 5 years ago

To put it roughly, this happens when the number of results is so high that one batch of results is like 0.0000001% of that. This crashed the progressbar.

What happens in the code is: I split the calculation into multiple tasks which run at the same time. When a task is finishes, it reports the number of results back, so I can calculate the current progress like this:

calculatedNumberOfResults += numberOfTaskResults; progressInPercent = calculatedNumberOfResults / numberOfResultsOverall * 100;

This is converted to Integer because the progressbar UI element only takes integer values from 0-100 which represent how much of the bar is filled. When numberOfResultsOverall gets too big, these floating point calculations result in a value of -1, which crashes the progressbar.