public UnitAction GetAction(Unit unit, Game game, AiCup2019.Debug debug) { if (m_lastTick >= game.CurrentTick) // Verify this number { //TODO: Check number of bullets LogService.WriteLine("Cached choice"); return(CreateAction(m_lastGame.Units.First(u => u.unit.Id == unit.Id), m_lastGame)); } Const.Reset(game.Properties, game); Debug = debug; var myGame = new MyGame(game, unit); var sim = m_lastGame = new SimGame(myGame, unit); m_lastTick = game.CurrentTick; DistService.CalcDists(sim); ShootService.Initialize(sim); foreach (var b in sim.Bullets) { b.CalcCollisionTime(sim); } foreach (var u in sim.Units) { u.WalkTarget = WalkService.FindWalkTarget(sim, u); u.AimTarget = AimService.GetAimTarget(sim, u); u.Shoot = ShootService.ShouldShoot(sim, u); if (u.Player.Id == unit.PlayerId) { u.IsMine = true; } } LogService.WriteLine("FIRETIMER: " + m_lastGame.Units.First(u => u.unit.Id == unit.Id).FireTimer); MCTSService.Search(sim); //foreach (var u in sim.Units) u.debug = true; MCTSService.DoOneRound(sim, true); //foreach (var u in sim.Units) u.debug = false; if (game.CurrentTick % 300 == 10) { Console.Error.WriteLine("Time: " + Const.GetTime + " Evals: " + Const.Evals + " Sims: " + Const.Sims); } var targetUnit = m_lastGame.Units.First(u => u.unit.Id == unit.Id); DistService.DrawPath(targetUnit.Position, targetUnit.WalkTarget); return(CreateAction(targetUnit, m_lastGame)); }