public int GetAge(Civilization civilization) { var bo = new OldBuildOrder(civilization, this); if (bo.Elements == null) { return(-1); } var age = 1; if (bo.Elements.Count(be => be.Gatherers == false && be.Research == true && be.Technology == civilization.Age2Tech) > 0) { age = 2; } if (bo.Elements.Count(be => be.Gatherers == false && be.Research == true && be.Technology == civilization.Age3Tech) > 0) { age = 3; } if (bo.Elements.Count(be => be.Gatherers == false && be.Research == true && be.Technology == civilization.Age4Tech) > 0) { age = 4; } return(age); }
public OldBuildOrder GetBuildOrder(Unit unit, int iterations = 1000) { var bo = new OldBuildOrder(this, unit); if (bo.Elements == null) { return(null); } bo.AddUpgrades(); bo.AddEcoUpgrades(); bo.Sort(); var rng = new Random(); Parallel.For(0, iterations, i => { int seed = -1; lock (rng) { seed = Math.Abs(rng.Next() ^ rng.Next() ^ rng.Next()); } var nbo = new OldBuildOrder(this, unit, false, seed); nbo.AddUpgrades(); nbo.AddEcoUpgrades(); nbo.Sort(); lock (rng) { if (nbo.Score > bo.Score) { bo = nbo; } } }); bo.Sort(); bo.Sort(); bo.InsertGatherers(); return(bo); }