public static void CalculateAiTanks() { var aiTanks = State.ThisRound.AiTanks; if (!State.ThisRound.AiPrizeTanks.Any() && State.HasPrevRound) { foreach (var aiTank in aiTanks) { var nearPoints = aiTank.Point.GetNearPoints(includeThis: true); var prevRoundNearPrizeTanks = State.PrevRound.AiPrizeTanks.Where(t => nearPoints.Contains(t.Point)).ToList(); var foundPrevRoundNearPrizeTank = prevRoundNearPrizeTanks.Count == 1 ? prevRoundNearPrizeTanks.First() : prevRoundNearPrizeTanks.FirstOrDefault(p => p.GetNextPoints(p.Point).First() == aiTank.Point); if (foundPrevRoundNearPrizeTank != null) { State.ThisRound.AddAiPrizeTank(aiTank, foundPrevRoundNearPrizeTank); } } } PredictionLogic.CalculateMobilePredictions(State.ThisRound.AiTanks, PredictionType.AiMove, x => x.CanMove); CalculateStuckAiMovePredictions(); PredictionLogic.CalculateTanksShotPredictions(State.ThisRound.AiTanks, PredictionType.AiShot, AppSettings.MyShotPredictionDepth); }
public static void CalculateEnemyTanks() { foreach (var enemyTank in State.ThisRound.EnemyTanks) { CalculateEnemyTankShotPredictions(enemyTank); } PredictionLogic.CalculateMobilePredictions(State.ThisRound.EnemyTanks, PredictionType.EnemyMove, x => x.CanMove, depthRestriction: AppSettings.EnemyTankMovePredictionDepth); var stuckEnemyTanks = State.ThisRound.EnemyTanks.Where(x => x.IsStuck).ToList(); PredictionLogic.CalculateStuckPosition(stuckEnemyTanks, PredictionType.EnemyMove, AppSettings.StuckEnemyPredictionDepth); }
private static void CalculateEnemyTankShotPredictions(BaseTank tank) { if (tank.CurrentDirection.HasValue) { PredictionLogic.CalculateTankShotPredictions(tank.Point, PredictionType.EnemyShot, tank.CurrentDirection.Value, tank, AppSettings.EnemyTankShotPredictionDepth); } var directions = BaseMobile.ValidDirections; foreach (var direction in directions) { var point = tank.Point.Shift(direction); var cell = Field.GetCell(point); if (cell.CanMove) { PredictionLogic.CalculateTankShotPredictions(point, PredictionType.EnemyShot, direction, tank, AppSettings.EnemyTankShotPredictionDepth); } } }
public static void CalculateBullets() { var bullets = State.ThisRound.Bullets; if (!bullets.Any()) { return; } foreach (var bullet in bullets) { var prevRoundNearBullet = CalculateNearestBullet(bullet); if (prevRoundNearBullet != null) { if (prevRoundNearBullet.CurrentDirection.HasValue) { bullet.CurrentDirection = prevRoundNearBullet.CurrentDirection; } else { bullet.CurrentDirection = CalculateDirection(prevRoundNearBullet.Point, bullet.Point); } continue; } var currentRoundNearTank = CalculateNearestTank(bullet); if (currentRoundNearTank == null) { currentRoundNearTank = CalculateNearestTank(bullet, 2); } if (currentRoundNearTank != null) { bullet.CurrentDirection = currentRoundNearTank.CurrentDirection; currentRoundNearTank.Shot(); continue; } } PredictionLogic.CalculateMobilePredictions(State.ThisRound.Bullets, PredictionType.Bullet, x => x.CanShootThrough, true); }
private static void CalculateStuckAiMovePredictions() { var stuckAiTanks = State.ThisRound.AiTanks.Where(x => x.IsStuck).ToList(); PredictionLogic.CalculateStuckPosition(stuckAiTanks, PredictionType.AiMove, AppSettings.StuckAiPredictionDepth); }