/// <summary>The central method that is used by the Game Engine to run the bot.</summary> public void Action(Common.Team myTeam, Common.Team enemyTeam, Common.Ball ball, Common.MatchInfo matchInfo) { try { var mapping = PlayerMapping.CreateForOwn(myTeam.Players, enemyTeam.Players); State.Add(myTeam, enemyTeam, ball, matchInfo); var fallen = State.Current.Players.Where(p => p.FallenTimer != 0).ToList(); var tackle = State.Current.Players.Where(p => p.TackleTimer != 0).ToList(); var queue = new PlayerQueue(State.Current.OwnPlayers); foreach (var scenario in Scenarios) { if (scenario.Apply(State, queue)) { break; } } mapping.Apply(queue.Actions); } catch (Exception x) { Log.Error(State.GetErrorMessage(), x); } finally { State.Current.Finish(); } }
public void Add(Common.Team myTeam, Common.Team enemyTeam, Common.Ball ball, Common.MatchInfo matchInfo) { var info = new TurnInfo() { Turn = matchInfo.CurrentTimeStep, OwnScore = matchInfo.MyScore, OwnTeamScored = matchInfo.MyTeamScored, OtherScore = matchInfo.EnemyScore, OtherTeamScored = matchInfo.EnemyTeamScored, }; foreach (var player in myTeam.Players) { info.Players.Add(PlayerInfo.Create(player, ball, TeamType.Own, enemyTeam.Players)); } foreach (var player in enemyTeam.Players) { info.Players.Add(PlayerInfo.Create(player, ball, TeamType.Other, myTeam.Players)); } var owner = ball.Owner == null ? null : info.Players.Single(p => p.IsBallOwner); info.Ball = BallInfo.Create(ball, owner); Add(info); }