public static void DefendMother(Point defender, IEnumerable <Point> targets) { Bb.readBoard(); if (!targets.Any() || !Bb.plantLookup.ContainsKey(defender)) { return; } var mother = Bb.ourMother.First(); var plant = defender.GetPlant(); var nearestTarget = targets.MinByValue(t => Trig.Distance(defender, t)); var nearestDistance = Trig.Distance(defender, nearestTarget); switch (plant.Mutation) { case AI.ARALIA: case AI.CHOKER: if (plant.RadiatesLeft > 0) { if (plant.UprootsLeft > 0 && nearestDistance > plant.Range && nearestDistance <= plant.Range + Bb.GetUprootRange(plant.Mutation)) { var astar = Search(defender.Single(), Bb.GetUprootRange(plant.Mutation), nearestTarget, plant.Range); if (astar.Path.Count() == 2) { var step = astar.Path.ElementAt(1); plant.uproot(step.x, step.y); } } if (Trig.Distance(plant.ToPoint(), nearestTarget) <= plant.Range) { plant.radiate(nearestTarget.x, nearestTarget.y); } } if (plant.UprootsLeft > 0 && Trig.Distance(mother, defender) > 75) { Uproot(defender, mother, 75); } break; case AI.TITAN: if (plant.UprootsLeft > 0 && Trig.Distance(mother, defender) > 75) { Uproot(defender, mother, 75); } if (plant.UprootsLeft > 0) { var dest = Trig.CalcPointsInCircle(plant.ToUprootCircle()).Where(p => IsPassable(p)).MaxByValue(d => targets.Count(t => Trig.Distance(d, t) <= plant.Range)); if (!dest.Equals(defender)) { plant.uproot(dest.x, dest.y); } } break; } }
public static void PreCalc() { poolPoints = Bb.pools.SelectMany(p => Trig.CalcPointsInCircle(new Circle(p, 100))).ToHashSet(); }
public static void Main(string[] args) { if (args.Length < 1) { var c = new Circle(1, 1, 1); Console.WriteLine("IN"); var ps = Trig.CalcPointsInCircle(c); ps.ForEach(p => Console.WriteLine(p)); Console.WriteLine("OUTER EDGE"); ps = Trig.CalcOuterEdgeOfCircle(c); ps.ForEach(p => Console.WriteLine(p)); Console.WriteLine("INNER EDGE"); ps = Trig.CalcInnerEdgeOfCircle(c); ps.ForEach(p => Console.WriteLine(p)); /* * var ps = Solver.FindPointsInCirclesNearestTargets( * 2, * new Circle(1, 1, 5).Single(), * new Point(20, 1).Single(), * new Circle(5, 1, 5).Single()); * ps.ForEach(p => Console.WriteLine(p)); */ System.Console.WriteLine("Please enter a hostname"); return; } IntPtr connection = Client.createConnection(); AI ai = new AI(connection); if (Client.serverConnect(connection, args[0], "19000") == 0) { System.Console.WriteLine("Unable to connect to server"); return; } if (Client.serverLogin(connection, ai.username(), ai.password()) == 0) { return; } if (args.Length < 2) { Client.createGame(connection); } else { Client.joinGame(connection, Int32.Parse(args[1]), "player"); } while (Client.networkLoop(connection) != 0) { if (ai.startTurn()) { Client.endTurn(connection); } else { Client.getStatus(connection); } } Client.networkLoop(connection); //Grab end game state Client.networkLoop(connection); //Grab log ai.end(); }