Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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;
        }