public static PlayerInfo Create(Common.Player player, Common.Ball ball, TeamType team, IEnumerable <Common.Player> other) { Guard.NotNull(player, "player"); Guard.NotNull(ball, "ball"); var tackled = other.Where(o => player.CanTackle(o)).ToList(); if (tackled.Count > 0) { } var info = new PlayerInfo() { Id = PlayerMapping.GetId(player.PlayerType, team), Position = player.Position, Velocity = player.Velocity, IsBallOwner = player == ball.Owner, CanPickUpBall = player.CanPickUpBall(ball), CanBeTackled = tackled.Select(p => PlayerMapping.GetId(p.PlayerType, TeamType.Other)).ToList(), FallenTimer = player.FallenTimer, TackleTimer = player.TackleTimer, }; info.DistanceToOwnGoal = Goal.Own.GetDistance(info); info.DistanceToOtherGoal = Goal.Other.GetDistance(info); return(info); }
/// <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); }
public static BallInfo Create(Common.Ball ball, PlayerInfo owner) { Guard.NotNull(ball, "ball"); return(new BallInfo(ball.Position, ball.Velocity, ball.PickUpTimer, owner)); }