public void Defender(Wizard w) { List <Snaffle> toDef = Snaffles.Where(x => x.PrecisionLength(MyGoal) <= 8000).ToList(); Snaffle nearSnaf = GetNearSnuffle(w, toDef); Snaffle acio = AccioOn(w); Snaffle fastSnaf = Snaffles .Where(x => ((x.VX + Math.Abs(x.VY) <= -1200 && myTeamId == 0) || (x.VX + Math.Abs(x.VY) >= 1200 && myTeamId == 1)) && !x.Reserve) .FirstOrDefault(); if (nearSnaf != null) { Snaffle snafToFlip = FlipendoOn(w); if (snafToFlip != null && mana > 20) { snafToFlip.Reserve = true; mana -= 20; Console.Error.WriteLine($"{snafToFlip} {snafToFlip.VX} {snafToFlip.VY}"); Console.WriteLine($"FLIPENDO {snafToFlip.Id}"); } else if (fastSnaf != null && mana > 10) { fastSnaf.Reserve = true; mana -= 10; Console.Error.WriteLine($"{fastSnaf} {fastSnaf.VX} {fastSnaf.VY}"); Console.WriteLine($"PETRIFICUS {fastSnaf.Id}"); } else if (acio != null && mana > 20) { acio.Reserve = true; mana -= 20; Console.Error.WriteLine($"{acio} {acio.VX} {acio.VY}"); Console.WriteLine($"ACCIO {acio.Id}"); } else { nearSnaf.Reserve = true; Point p = nearSnaf; p.X += nearSnaf.VX; p.Y += nearSnaf.VY; Console.Error.WriteLine($"MOVE {p} 150"); Console.WriteLine($"MOVE {p.Pos()} 150"); } } else { Point o = GetNear(OppGoal, new List <Point>(Opponents)); Console.WriteLine($"MOVE {o.Pos()} 150"); } }
public Snaffle AccioOn(Wizard w) { Point w2 = new Point() { X = w.X + w.VX, Y = w.Y + w.VY }; bool op = Opponents.Any(x => Between(x.X + x.VX, w2.X, MyGoal.X)); List <Snaffle> snf = Snaffles.Where(x => Between(x.X, w2.X, MyGoal.X)).ToList(); if (snf.Count > 0 && op) { Snaffle s = GetNearSnuffle(w2, snf); if (w2.PrecisionLength(s) < 2000) { return(s); } } return(null); }
public Snaffle FlipendoOn(Wizard w) { Point w2 = new Point() { X = w.X + (int)(w.VX * 0.75), Y = w.Y + (int)(w.VY * 0.75) }; List <Snaffle> snfls = Snaffles.Where(x => Between((int)(x.X + x.VX * 0.75), w2.X, OppGoal.X)).ToList(); Point s = GetNear(w2, new List <Point>(snfls)); int Y = (int)Fx(OppGoal.X, w2, s); if (Between(Y, OppGoal.YDown, OppGoal.YTop) && w2.PrecisionLength(s) < 2450D) { return(s as Snaffle); } else { return(null); } }