public Map(int width, int height, int worldTick, SnakePlayer mySnake, IEnumerable <SnakePlayer> snakeInfos, IEnumerable <MapCoordinate> foodPositions, IEnumerable <MapCoordinate> obstaclePositions) { Tick = worldTick; MySnake = mySnake; FoodPositions = foodPositions.ToList(); ObstaclePositions = obstaclePositions.ToList(); Snakes = snakeInfos.ToList(); Width = width; Height = height; }
public TileGridBuilder WithMySnake(SnakePlayer mySnake) { foreach (var position in mySnake.Positions) { _tileGrid[position] = TileType.MyBody; } _tileGrid[mySnake.HeadPosition] = TileType.MyHead; _tileGrid[mySnake.TailPosition] = TileType.MyTail; return(this); }
public Map(int width, int height, int worldTick, SnakePlayer mySnake, IEnumerable <SnakePlayer> snakeInfos, IEnumerable <MapCoordinate> foodPositions, IEnumerable <MapCoordinate> obstaclePositions) { Tick = worldTick; MySnake = mySnake; FoodPositions = new HashSet <MapCoordinate>(foodPositions); ObstaclePositions = new HashSet <MapCoordinate>(obstaclePositions); Snakes = snakeInfos.ToList(); OpponentSnakes = Snakes.Where(s => s.Id != MySnake.Id).ToList(); TileGrid = new TileGridBuilder(width, height) .WithFood(FoodPositions) .WithObstacles(ObstaclePositions) .WithMySnake(MySnake) .WithOpponentSnakes(OpponentSnakes) .WithOpponentHeadNeighbors(OpponentSnakes) .Build(); OpponentsTailsPositions = OpponentSnakes.Where(s => s.IsAlive) .ToDictionary(s => s.TailPosition, s => s); Width = width; Height = height; }