You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have catched a moment when on initialising automine one mine is shown as 'next mine' but few moments later another mine is started - here is the reason:
Inside function GetNextMineToBuild there is following code:
Dictionary<Buildables, float> dic = new();
............. get a dictionary of possible mines to be built into 'dic'
dic = dic.OrderBy(m => m.Value)
ToDictionary(m => m.Key, m => m.Value);
var bestMine = dic.FirstOrDefault().Key;
What it does?
checkes what mines can be build and puts them into 'dic'.
orders possible mines by their ROI and put them into ordereddictionary (to keep the order)
converts ordereddictionary back into dictionary, loosing the order and puts them back into 'dic'
gets first of mines from 'dic' (not ordered dictionary) and says it should be built.
Obviously correct code would skip step 3, so it should look something like this:
Dictionary<Buildables, float> dic = new();
............. get a dictionary of possible mines to be built into 'dic'
var orderedDic = dic.OrderBy(m => m.Value);
var bestMine = orderedDic.FirstOrDefault().Key;
In fact current internal implementation of dictionary usually keeps the order or entered elements, so it usually works. But only usually.
Btw similar code appears in two copies of GetNextMineToBuild and in GetNextResearchToBuild too.
The text was updated successfully, but these errors were encountered:
If you have catched a moment when on initialising automine one mine is shown as 'next mine' but few moments later another mine is started - here is the reason:
Inside function GetNextMineToBuild there is following code:
What it does?
Obviously correct code would skip step 3, so it should look something like this:
In fact current internal implementation of dictionary usually keeps the order or entered elements, so it usually works. But only usually.
Btw similar code appears in two copies of GetNextMineToBuild and in GetNextResearchToBuild too.
The text was updated successfully, but these errors were encountered: