Beispiel #1
0
        public void BobMissionaries()
        {
            GetUnits(AI.US, AI.MISSIONARY).ForEach(u => Solver.MoveAndRestAndConvert(u, AI.GAME.Units.Where(n => u.CanConvert(n, false))));

            var first = Solver.GetNearestPair(GetUnits(AI.US, AI.MISSIONARY), g => AI.SPAWN_POINTS.Contains(g));

            if (first != null)
            {
                Act.Move(first.Item1, g => g.ToPoint().IsInStepRange(first.Item2, AI.MISSIONARY.Moves));

                var otherPoint = AI.SPAWN_POINTS.First(p => !p.Equals(first.Item2));
                var second     = Solver.GetNearestPair(GetUnits(AI.US, AI.MISSIONARY).Where(m => m != first.Item1), g => g.Equals(otherPoint));
                if (second != null)
                {
                    Act.Move(second.Item1, g => g.ToPoint().IsInStepRange(second.Item2, AI.MISSIONARY.Moves));
                }
            }

            var remainder = GetUnits(AI.US, AI.MISSIONARY).FirstOrDefault(m => m.Moves > 0);

            if (remainder == null)
            {
                return;
            }
            var brinkOfDeath  = AI.GAME.Units.Where(u => u.Owner != null && u.Energy < 50);
            var smellingDeath = AI.GAME.Tiles.Where(t => brinkOfDeath.Any(b => b.ToPoint().IsInStepRange(t.ToPoint(), AI.MISSIONARY.Moves)));

            Solver.MoveToAndRest(remainder, smellingDeath.Select(s => s.ToPoint()), 100);
        }
Beispiel #2
0
 public static void MoveAndRestAndChangeJob(Unit unit, Job job)
 {
     MoveAndRest(unit, 100);
     Act.Move(unit, unit.Owner.Cat.Tile.GetSquareNeighbors());
     if (unit.CanChangeJob(job))
     {
         unit.ChangeJob(job.Title);
     }
 }
Beispiel #3
0
        public static void MoveToAndRest(Unit unit, IEnumerable <Point> targets, double neededEnergy = 100)
        {
            if (unit.Energy >= neededEnergy)
            {
                return;
            }
            var shelters = AI.GetStructures(unit.Owner, "shelter");

            Act.Move(unit, shelters.SelectMany(s => s.Tile.GetSquareNeighbors()));
            // And
            if (unit.CanRest())
            {
                unit.Rest();
            }
        }
Beispiel #4
0
        public void BobSoldiers()
        {
            if (GetUnits(AI.THEM, AI.SOLDIER).Count(s => s.ToPoint().IsInStepRange(AI.US.Cat.ToPoint(), 12)) > 1)
            {
                Console.WriteLine("DEFEND");
                var first = Solver.GetNearestPair(GetUnits(AI.US, AI.SOLDIER), g => g.IsInStepRange(AI.US.Cat.ToPoint(), 1));
                if (first != null)
                {
                    Act.Move(first.Item1, AI.US.Cat.Tile.GetNeighbors());
                    var second = Solver.GetNearestPair(GetUnits(AI.US, AI.SOLDIER).Where(s => s != first.Item1), g => g.IsInStepRange(AI.US.Cat.ToPoint(), 1));
                    if (second != null)
                    {
                        Act.Move(second.Item1, AI.US.Cat.Tile.GetNeighbors());
                    }
                }
            }

            GetUnits(AI.US, AI.SOLDIER).ForEach(u =>
            {
                if (Act.GetRegenAmount(u) > 0 && u.Energy < 90)
                {
                    u.Rest();
                }
                else if (u.Energy < 50)
                {
                    Solver.MoveAndRest(u);
                }
                else if (ReadyForBumRush())
                {
                    Console.WriteLine("Ready For Bumb Rushhhh!");
                    Solver.MoveAndAttack(u, new List <Tile> {
                        AI.THEM.Cat.ToPoint().ToTile()
                    });
                    Solver.MoveAndAttack(u, GetUnits(AI.THEM).Select(t => t.Tile));
                }
                else
                {
                    var primeThreat = ChoosePrimeThreat();
                    if (primeThreat != null)
                    {
                        Solver.MoveAndAttack(u, new[] { primeThreat.Tile });
                    }
                }
            });
        }
Beispiel #5
0
        public void Uproot()
        {
            // Spawn one build and rest soldiers
            var builder = AI.US.Units.FirstOrDefault(u => u.Job == AI.BUILDER);

            if (builder == null)
            {
                builder = AI.US.Units.FirstOrDefault(u => u.CanChangeJob(AI.BUILDER));
                if (builder != null)
                {
                    builder.ChangeJob(AI.BUILDER.Title);
                }
            }
            AI.US.Units.Where(u => u != builder && u.CanChangeJob(AI.SOLDIER)).ForEach(f => f.ChangeJob(AI.SOLDIER.Title));


            // Choose new home tile in a corner
            var newHome = Act.GetCorners().Where(c => c.ToTile().IsPathable() || c.Equals(AI.US.Cat.ToPoint())).MinByValue(c => c.ManhattanDistance(AI.US.Cat.ToPoint()));

            // Move Overlord to new home
            Act.Move(AI.US.Cat, new[] { newHome.ToTile() });

            // Move and deconstruct if builder has < 50 material
            if (builder != null && builder.Materials < AI.STRUCTURE_COSTS["shelter"])
            {
                Solver.MoveAndRestAndDeconstruct(builder, AI.GAME.Tiles.Where(t => Act.CanDeconstruct(builder, t, false)));
            }

            // Move and construct if builder has >= material
            if (builder != null && builder.Materials >= AI.STRUCTURE_COSTS["shelter"])
            {
                Solver.MoveAndRestAndConstruct(builder, new[] { newHome.ToTile() }, "shelter");
            }

            if (newHome.ToTile().Structure != null)
            {
                this.SoldierZerg();
            }

            // Move soldiers to adj adj around new home if no shelter
            // Move units to sq adj around new home if shelter done
            // Change builder to soldier if shelter done
        }
Beispiel #6
0
 public void ZergBlock()
 {
     AI.US.Units.Where(u => u.CanChangeJob(AI.GATHERER)).ForEach(f => f.ChangeJob(AI.GATHERER.Title));
     AI.US.Units.Where(u => u.Job == AI.GATHERER).ForEach(s => Act.Move(s, AI.US.Cat.Tile.GetNeighbors()));
     AI.US.Units.Where(u => u.Job == AI.GATHERER).ForEach(s => s.Rest());
 }
Beispiel #7
0
 public static void MoveAndAttack(Unit unit, IEnumerable <Tile> targets)
 {
     Act.Move(unit, targets.SelectMany(t => t.GetNeighbors()));
     Act.Attack(unit, targets);
 }
Beispiel #8
0
 public static void MoveAndRestAndHarvest(Unit unit, IEnumerable <Tile> targets)
 {
     MoveAndRest(unit, unit.GetActionCost());
     Act.Move(unit, targets.SelectMany(t => t.GetNeighbors().Concat(t)));
     Act.Harvest(unit, targets);
 }
Beispiel #9
0
 public static void MoveAndRestAndDrop(Unit unit, IEnumerable <Tile> targets, string resource)
 {
     Act.Move(unit, targets.SelectMany(t => t.GetNeighbors().Concat(t)));
     Act.Drop(unit, targets, resource);
 }
Beispiel #10
0
 public static void MoveAndRestAndDeconstruct(Unit unit, IEnumerable <Tile> targets)
 {
     MoveAndRest(unit, unit.GetActionCost());
     Act.Move(unit, targets.SelectMany(t => t.GetNeighbors()));
     Act.Deconstruct(unit, targets);
 }
Beispiel #11
0
 public static void MoveAndRestAndConvert(Unit unit, IEnumerable <Unit> targets)
 {
     MoveAndRest(unit, unit.GetActionCost());
     Act.Move(unit, targets.SelectMany(t => t.Tile.GetNeighbors()));
     Act.Convert(unit, targets);
 }
Beispiel #12
0
 public static void MoveAndRestAndConstruct(Unit unit, IEnumerable <Tile> targets, string type)
 {
     MoveAndRest(unit, unit.GetActionCost());
     Act.Move(unit, targets.SelectMany(t => t.GetNeighbors().Concat(t)));
     Act.Construct(unit, targets, type);
 }