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) { if (state.Opposition != TeamType.Other) { return false; } var other = state.Current.OtherPlayers.OrderBy(player => player.DistanceToOwnGoal).ToList(); if(Role.Tackler.Apply(state, queue)) { other.Remove(other.FirstOrDefault(item=> item.Id == ((Tackle)queue.Actions[0]).Target)); } if(Role.Sweeper.Apply(state, queue)) { other.Remove(state.Current.Ball.Owner); } Role.BallCatcher.Apply(state, queue); Role.Keeper.Apply(state, queue); foreach (var target in other) { if (queue.Count < 3) { break; } var defender = target.GetClosestBy(queue); queue.Dequeue(Actions.Move(defender, target)); } return true; }
public bool Apply(GameState state, PlayerQueue queue) { if (state.Opposition != TeamType.Other) { return(false); } var other = state.Current.OtherPlayers.OrderBy(player => player.DistanceToOwnGoal).ToList(); if (Role.Tackler.Apply(state, queue)) { other.Remove(other.FirstOrDefault(item => item.Id == ((Tackle)queue.Actions[0]).Target)); } if (Role.Sweeper.Apply(state, queue)) { other.Remove(state.Current.Ball.Owner); } Role.BallCatcher.Apply(state, queue); Role.Keeper.Apply(state, queue); foreach (var target in other) { if (queue.Count < 3) { break; } var defender = target.GetClosestBy(queue); queue.Dequeue(Actions.Move(defender, target)); } return(true); }
public void Dequeue_ActionsNone_NothingChanges() { var player = new PlayerInfo() { Id = 4 }; var queue = new PlayerQueue(player); Assert.IsFalse(queue.Dequeue(Actions.None), "Nothing should be de-queued."); Assert.AreEqual(1, queue.Count, "number of elements should still be 1."); Assert.AreEqual(0, queue.Actions.Count, "Should contain no actions."); }
public void Dequeue_ActionsWait4_AddsOneAction() { var player = new PlayerInfo() { Id = 4 }; var queue = new PlayerQueue(player); Assert.IsTrue(queue.Dequeue(Actions.Wait(player)), "Player 4 should be de-queued."); Assert.AreEqual(0, queue.Count, "number of elements should be 0."); Assert.AreEqual(1, queue.Actions.Count, "Should contain 1 action."); }
public bool Apply(GameState state, PlayerQueue queue) { foreach (var role in Roles) { role.Apply(state, queue); } var zones = Zones.Create(state); foreach (var zone in zones.SingleOccupiedByOwn) { var player = zone.Own.FirstOrDefault(); if (queue.Contains(player)) { queue.Dequeue(Actions.Move(player, zone.Target)); } } foreach (var zone in zones.NotOccupiedByOwn) { var closedBy = zone.Target.GetClosestBy(queue); if (closedBy != null) { queue.Dequeue(Actions.Move(closedBy, zone.Target)); } } if (zones.BallOwnerZone != null) { var closedBy = zones.BallOwnerZone.Target.GetClosestBy(queue); if (closedBy != null) { queue.Dequeue(Actions.Move(closedBy, zones.BallOwnerZone.Target)); } } foreach (var player in queue.ToList()) { queue.Dequeue(Actions.Wait(player)); } return(true); }
public bool Apply(GameState state, PlayerQueue queue) { foreach (var role in Roles) { role.Apply(state, queue); } var zones = Zones.Create(state); foreach (var zone in zones.SingleOccupiedByOwn) { var player = zone.Own.FirstOrDefault(); if (queue.Contains(player)) { queue.Dequeue(Actions.Move(player, zone.Target)); } } foreach (var zone in zones.NotOccupiedByOwn) { var closedBy = zone.Target.GetClosestBy(queue); if (closedBy != null) { queue.Dequeue(Actions.Move(closedBy, zone.Target)); } } if (zones.BallOwnerZone != null) { var closedBy = zones.BallOwnerZone.Target.GetClosestBy(queue); if (closedBy != null) { queue.Dequeue(Actions.Move(closedBy, zones.BallOwnerZone.Target)); } } foreach (var player in queue.ToList()) { queue.Dequeue(Actions.Wait(player)); } return true; }
public bool Apply(GameState state, PlayerQueue queue) { var ball = state.Current.Ball; if (ball.HasOwner || state.Current.OwnPlayers.Any(player => player.CanPickUpBall)) { return false; } var catchUp = state.CatchUps.FirstOrDefault(c => queue.Contains(c.Player)); if (catchUp != null) { queue.Dequeue(Actions.Move(catchUp.Player, catchUp.Position)); } return catchUp != 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) { if (state.Current.Ball.IsOther) { var path = PlayerPath.Create(state.Current.Ball.Owner, Goal.Own.Center, 400, 40f); var sweeper = path.GetCatchUps(queue).FirstOrDefault(); if (sweeper != null) { return queue.Dequeue(Actions.Move(sweeper.Player, sweeper.Position)); } } return false; }
public bool Apply(GameState state, PlayerQueue queue) { if (state.Current.Ball.IsOther) { var path = PlayerPath.Create(state.Current.Ball.Owner, Goal.Own.Center, 400, 40f); var sweeper = path.GetCatchUps(queue).FirstOrDefault(); if (sweeper != null) { return(queue.Dequeue(Actions.Move(sweeper.Player, sweeper.Position))); } } return(false); }
public bool Apply(GameState state, PlayerQueue queue) { var ball = state.Current.Ball; if (ball.HasOwner || state.Current.OwnPlayers.Any(player => player.CanPickUpBall)) { return(false); } var catchUp = state.CatchUps.FirstOrDefault(c => queue.Contains(c.Player)); if (catchUp != null) { queue.Dequeue(Actions.Move(catchUp.Player, catchUp.Position)); } return(catchUp != null); }
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 ERoomUser PopPlayer(PlayerStauts playerStatus) { if (PlayerQueue.Count != 0) { var Player = PlayerQueue.Dequeue(); if (playerStatus == PlayerStauts.OffLine || playerStatus == PlayerStauts.GiveUp) { PlayerQuitQueue.Enqueue(Player); } else { PlayerDoneQueue.Enqueue(Player); } return(Player); } return(null); }
public bool Apply(GameState state, PlayerQueue queue) { if (queue.IsEmty) { return false; } var ball = state.Current.Ball.Position; if (!state.Current.Ball.HasOwner && state.CatchUps.Count > 0) { ball = state.CatchUps[0].Position; } var target = GetTarget(ball); var keeper = target.GetClosestBy(queue); queue.Dequeue(Actions.Move(keeper, target)); return true; }
public bool Apply(GameState state, PlayerQueue queue) { if (!state.Current.Ball.IsOther || !queue.Any()) { return false; } var owner = state.Current.Ball.Owner; var target = owner.Position + owner.Velocity; // if the owner is moving away. if (owner.DistanceToOwnGoal > Goal.Own.GetDistance(target)) { // The sandwich can only work if the sandwicher is coming from the other side. var sandwicher = owner.GetClosestBy(queue.Where(player => player.DistanceToOwnGoal > owner.DistanceToOwnGoal)); if(sandwicher != null) { return queue.Dequeue(Actions.Move(sandwicher, owner)); } } 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) { if (state.Current.Ball.IsOther) { var freeMan = state.Current.Ball.Owner.GetOther(state.Current.OtherPlayers) .OrderBy(player => player.DistanceToOwnGoal) .Skip(Rank).FirstOrDefault(); var path = PlayerPath.Create(freeMan, Goal.Own.Center, 400, 40f); var manMarker = path.GetCatchUps(queue).FirstOrDefault(); if (manMarker != null) { return(queue.Dequeue(Actions.Move(manMarker.Player, manMarker.Position))); } } return(false); }
public bool Apply(GameState state, PlayerQueue queue) { if (state.Current.Ball.IsOther) { var freeMan = state.Current.Ball.Owner.GetOther(state.Current.OtherPlayers) .OrderBy(player => player.DistanceToOwnGoal) .Skip(Rank).FirstOrDefault(); var path = PlayerPath.Create(freeMan, Goal.Own.Center, 400, 40f); var manMarker = path.GetCatchUps(queue).FirstOrDefault(); if (manMarker != null) { return queue.Dequeue(Actions.Move(manMarker.Player, manMarker.Position)); } } return false; }
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); }
private List <Player> GetNPlayers(int n) { List <Player> players = new List <Player>(); for (int i = 0; i < n; i++) { PlayerCreationData data = playerQueue.Dequeue(); if (data != null) { Player player = new Player(); player.Initialize(data, data.name); player.stats.ApplyStatsBasedOnLevel(GameManager.Instance.gameState.playerParty.GetHeroFighter().stats.level); OutOfJuiceAilment outOfJuicePrefab = (OutOfJuiceAilment)GameManager.Instance.models.GetCommonStatusAilment("Out of Juice"); player.ailmentController.AddStatusAilment(Instantiate(outOfJuicePrefab)); //player.stats.ApplyStatsBasedOnLevel(1); players.Add(player); } } return(players); }
public bool Apply(GameState state, PlayerQueue queue) { if (!state.Current.Ball.IsOther || !queue.Any()) { return(false); } var owner = state.Current.Ball.Owner; var target = owner.Position + owner.Velocity; // if the owner is moving away. if (owner.DistanceToOwnGoal > Goal.Own.GetDistance(target)) { // The sandwich can only work if the sandwicher is coming from the other side. var sandwicher = owner.GetClosestBy(queue.Where(player => player.DistanceToOwnGoal > owner.DistanceToOwnGoal)); if (sandwicher != null) { return(queue.Dequeue(Actions.Move(sandwicher, owner))); } } return(false); }
public bool Apply(GameState state, PlayerQueue queue) { if (queue.IsEmty) { return(false); } var ball = state.Current.Ball.Position; if (!state.Current.Ball.HasOwner && state.CatchUps.Count > 0) { ball = state.CatchUps[0].Position; } var target = GetTarget(ball); var keeper = target.GetClosestBy(queue); queue.Dequeue(Actions.Move(keeper, target)); return(true); }