public bool Apply(GameState state, PlayerQueue queue) { var current = state.Current; if (current.Ball.IsOther) { var tackle = queue.FirstOrDefault(player => player.CanTackle(current.Ball.Owner)); if (tackle != null) { queue.Dequeue(Actions.Tacle(tackle, current.Ball.Owner)); return(true); } } if (current.Ball.Owner == null && state.CatchUps.Any(cu => cu.Player.Team == TeamType.Other)) { var target = state.CatchUps.FirstOrDefault(); if (target.Player.Team == TeamType.Other) { var tackle = queue.FirstOrDefault(player => player.CanTackle(target.Player)); if (tackle != null) { queue.Dequeue(Actions.Tacle(tackle, target.Player)); return(true); } } } return(false); }
public bool Apply(GameState state, PlayerQueue queue) { var current = state.Current; if (current.Ball.IsOther) { var tackle = queue.FirstOrDefault(player => player.CanTackle(current.Ball.Owner)); if (tackle != null) { queue.Dequeue(Actions.Tacle(tackle, current.Ball.Owner)); return true; } } if (current.Ball.Owner == null && state.CatchUps.Any(cu => cu.Player.Team == TeamType.Other)) { var target = state.CatchUps.FirstOrDefault(); if (target.Player.Team == TeamType.Other) { var tackle = queue.FirstOrDefault(player => player.CanTackle(target.Player)); if (tackle != null) { queue.Dequeue(Actions.Tacle(tackle, target.Player)); return true; } } } return false; }
public bool Apply(GameState state, PlayerQueue queue) { var owner = queue.FirstOrDefault(player => player.IsBallOwner); if (owner == null) { return false; } var candidates = new ActionCandidates(); // Just in case, if we don't find anything better. candidates.Add(-20000, Actions.ShootOnGoal(owner, Power.Maximum)); foreach (var generator in Generators) { generator.Generate(owner, state, candidates); } return queue.Dequeue(candidates.Best.Action); }
public bool Apply(GameState state, PlayerQueue queue) { var current = state.Current; if (current.Ball.IsOwn || // if the other can not pick it up, and it's a goal, just let it go. (state.Path.End == BallPath.Ending.GoalOther && !state.CatchUps.Any(cu => cu.Player.Team == TeamType.Other))) { return false; } var pickup = queue.FirstOrDefault(player => player.CanPickUpBall); if (pickup != null) { queue.Dequeue(Actions.PickUpBall(pickup)); } return pickup != null; }
public bool Apply(GameState state, PlayerQueue queue) { var owner = queue.FirstOrDefault(player => player.IsBallOwner); if (owner == null) { return(false); } var candidates = new ActionCandidates(); // Just in case, if we don't find anything better. candidates.Add(-20000, Actions.ShootOnGoal(owner, Power.Maximum)); foreach (var generator in Generators) { generator.Generate(owner, state, candidates); } return(queue.Dequeue(candidates.Best.Action)); }
public bool Apply(GameState state, PlayerQueue queue) { var current = state.Current; if (current.Ball.IsOwn || // if the other can not pick it up, and it's a goal, just let it go. (state.Path.End == BallPath.Ending.GoalOther && !state.CatchUps.Any(cu => cu.Player.Team == TeamType.Other))) { return(false); } var pickup = queue.FirstOrDefault(player => player.CanPickUpBall); if (pickup != null) { queue.Dequeue(Actions.PickUpBall(pickup)); } return(pickup != null); }