Beispiel #1
0
        internal Position Check(GridSize gridSize)
        {
            if (_xCoordinate > -1 &&
                _yCoordinate > -1 &&
                gridSize.IsValid(_xCoordinate, _yCoordinate))
            {
                return(this);
            }

            return(Invalid);
        }
Beispiel #2
0
 internal Position Apply(GridSize gridSize, Position position)
 {
     foreach (var routeStep in _routeSteps)
     {
         position = position.Apply(routeStep)
                    .Check(gridSize);
         if (position.Equals(Position.Invalid))
         {
             throw new InvalidRouteException();
         }
     }
     return(position);
 }
Beispiel #3
0
 public static Arena From(GridSize gridSize, IEnumerable <Robot> robots)
 {
     return(new Arena(gridSize, robots));
 }
Beispiel #4
0
 private Arena(GridSize gridSize, IEnumerable <Robot> robots)
 {
     _gridSize = gridSize;
     _robots   = robots;
 }
Beispiel #5
0
 internal Position FollowRoute(GridSize gridSize)
 {
     return(_route.Apply(gridSize, _position));
 }