public MovingController(List <IGameObject> allObjects, int id) { var player = (Player)allObjects.Find(elem => elem.Type == ObjectType.Player && elem.UniqueId != id); var bot = (Player)allObjects.Find(elem => elem.Type == ObjectType.Player && elem.UniqueId == id); var field = (Field)allObjects.Find(elem => elem.Type == ObjectType.Field); var dist = bot.Radius; lastPlayerPos = new Position(player.Centre.X, player.Centre.Y); greed = new Greed(field.Width, field.Height, bot.Radius, dist);//2 * dist); greed.SetBlocks(CreateBlockedAreas(allObjects, dist)); greed.SetShadows(CreateShadows(allObjects, player.Centre, player.Radius / 2)); currentPath = LeeSearch.FindPath(bot.Centre, greed); }
internal GameActions GetDecision(List <IGameObject> allObjects, int id) { var player = (Player)allObjects.Find(elem => elem.Type == ObjectType.Player && elem.UniqueId != id); var bot = (Player)allObjects.Find(elem => elem.Type == ObjectType.Player && elem.UniqueId == id); var field = (Field)allObjects.Find(elem => elem.Type == ObjectType.Field); var step = GameActions.None; if (!player.Centre.Equal(lastPlayerPos)) { greed.SetShadows(CreateShadows(allObjects, player.Centre, player.Radius / 2)); currentPath = LeeSearch.FindPath(bot.Centre, greed); } if (greed.IsInDestinations(bot.Centre)) { step = Aim(bot, player); } else { step = Go(bot, currentPath); } return(step); }