public double Distance(VehicleWrapper unit) { var x = X - unit.X; var y = Y - unit.Y; return(Math.Sqrt(x * x + y * y)); }
public double SqrDistance(VehicleWrapper to) { var x = to.X - X; var y = to.Y - Y; return(x * x + y * y); }
private double SqrDistance(VehicleWrapper from, VehicleWrapper to) { var x = to.X - from.X; var y = to.Y - from.Y; return(x * x + y * y); }
public static Action TacticalNuclearStrike(this VehicleWrapper visitor, VehicleWrapper target) { var action = new Action { ActionType = ActionType.TacticalNuclearStrike, GetX = () => target.X + 30 * target.SpeedX, GetY = () => target.Y + 30 * target.SpeedY, VehicleId = visitor.Id, Priority = ActionPriority.Urgent }; return(action); }
private static void CreateVehicles() { foreach (var newVehicle in Global.World.NewVehicles) { VehicleWrapper wrapper = newVehicle; Global.AllVehicles.Add(wrapper.Id, wrapper); if (wrapper.PlayerId == Global.Me.Id) { Global.MyVehicles.Add(wrapper.Id, wrapper); } else { Global.EnemyVehicles.Add(wrapper.Id, wrapper); } } }
private void NuclearStrike2() { if (_me.RemainingNuclearStrikeCooldownTicks == 0 && _me.NextNuclearStrikeTickIndex == -1 && _world.TickIndex % 59 == 0 && ActionQueue.All(a => a.Action != ActionType.TacticalNuclearStrike)) { VehicleWrapper possibleTarget = null; double bestDeltaDamage = Math.Min(30 * 100, EnemyVehicles.Values.Sum(i => i.Durability) / 5); var sqrNuclearRadius = _game.TacticalNuclearStrikeRadius * _game.TacticalNuclearStrikeRadius; const double visionRangeThreshold = 0.7; foreach (var enemy in EnemyVehicles.Values) { var visors = MyVehicles.Values .Where(i => SqrDistance(i, enemy) < visionRangeThreshold * i.VisionRange * i.VisionRange) .ToList(); if (visors.Count == 0) { continue; } var allDamaged = AllVehicles.Values .Where(i => SqrDistance(i, enemy) < sqrNuclearRadius) .ToList(); var enemyDamaged = allDamaged.Where(i => i.PlayerId != _me.Id).ToList(); var myDamaged = allDamaged.Where(i => i.PlayerId == _me.Id).ToList(); if (enemyDamaged.Count <= Math.Min(30, EnemyVehicles.Count / 2 - 10)) { continue; } var myDamage = myDamaged .Sum(i => Math.Min(i.Durability, _game.MaxTacticalNuclearStrikeDamage * (1 - Math.Sqrt(SqrDistance(i, enemy) / sqrNuclearRadius)))); var enemyDamage = enemyDamaged .Sum(i => Math.Min(i.Durability, _game.MaxTacticalNuclearStrikeDamage * (1 - Math.Sqrt(SqrDistance(i, enemy) / sqrNuclearRadius)))); if (enemyDamage - myDamage > bestDeltaDamage) { bestDeltaDamage = enemyDamage - myDamage; possibleTarget = enemy; } } if (possibleTarget == null) { return; } var visor = MyVehicles.Values .Where(i => SqrDistance(i, possibleTarget) < visionRangeThreshold * i.VisionRange * i.VisionRange) .OrderBy(i => SqrDistance(i, possibleTarget)).First(); ActionQueue.Enqueue(new Move { Action = ActionType.TacticalNuclearStrike, X = possibleTarget.X + 30 * possibleTarget.SpeedX, Y = possibleTarget.Y + 30 * possibleTarget.SpeedY, VehicleId = visor.Id }); } }
public double SqrDistance(VehicleWrapper unit) { return(SqrDistance(unit.X, unit.Y)); }
public void AddEnemy(VehicleWrapper vehicle) { Enemies.Add(vehicle); }
public static void NuclearStrike() { if (Global.Me.RemainingNuclearStrikeCooldownTicks == 0 && Global.Me.NextNuclearStrikeTickIndex == -1 && Global.World.TickIndex % 30 == 25 && !Global.ActionQueue.HasActionsFor(ActionType.TacticalNuclearStrike)) { VehicleWrapper possibleTarget = null; double bestDeltaDamage = Math.Min(30 * 100, Global.EnemyVehicles.Values.Sum(i => i.Durability) / 5); var sqrNuclearRadius = Global.Game.TacticalNuclearStrikeRadius * Global.Game.TacticalNuclearStrikeRadius; const double visionRangeThreshold = 0.7; foreach (var enemy in Global.EnemyVehicles.Values) { var visors = Global.MyVehicles.Values .Where(i => i.SqrDistance(enemy) < visionRangeThreshold * i.VisionRange * i.VisionRange) .ToList(); if (visors.Count == 0) { continue; } var allDamaged = Global.AllVehicles.Values .Where(i => i.SqrDistance(enemy) < sqrNuclearRadius) .ToList(); var enemyDamaged = allDamaged.Where(i => i.PlayerId != Global.Me.Id).ToList(); var myDamaged = allDamaged.Where(i => i.PlayerId == Global.Me.Id).ToList(); if (enemyDamaged.Count <= Math.Min(30, Global.EnemyVehicles.Count / 2 - 10)) { continue; } var myDamage = myDamaged .Sum(i => Math.Min(i.Durability, Global.Game.MaxTacticalNuclearStrikeDamage * (1 - Math.Sqrt(i.SqrDistance(enemy) / sqrNuclearRadius)))); var enemyDamage = enemyDamaged .Sum(i => Math.Min(i.Durability, Global.Game.MaxTacticalNuclearStrikeDamage * (1 - Math.Sqrt(i.SqrDistance(enemy) / sqrNuclearRadius)))); if (enemyDamage - myDamage > bestDeltaDamage) { bestDeltaDamage = enemyDamage - myDamage; possibleTarget = enemy; } } if (possibleTarget == null) { return; } var visor = Global.MyVehicles.Values .Where(i => i.SqrDistance(possibleTarget) < visionRangeThreshold * i.VisionRange * i.VisionRange) .OrderBy(i => i.SqrDistance(possibleTarget)).Last(); var action = visor.TacticalNuclearStrike(possibleTarget); action.Interruptable = false; var newSequence = new ActionSequence(action); Global.ActionQueue.Add(newSequence); } }
public double Distance(VehicleWrapper to) { return(Math.Sqrt(SqrDistance(to))); }
public bool CanSee(VehicleWrapper target, double gap = 1) // 2.4 Типы местности и погоды { return(Position.Distance(target.Position) <= gap * Vehicle.VisionRange * VisionFactor * target.StealthFactor); }
public double Distance(VehicleWrapper target) { return(Position.Distance(target.Position)); }