コード例 #1
0
ファイル: Unit.cs プロジェクト: 01010100b/AoE2Lang
        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);
        }
コード例 #2
0
ファイル: Civilization.cs プロジェクト: 01010100b/AoE2Lang
        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);
        }