Exemple #1
0
        public MazeObservation GetWallConfiguration(MazeState s)
        {
            MazeState.Direction d = s.CurrentDirection;
            int iObservation      = 0;
            int iDirection        = 0;

            for (iDirection = 0; iDirection < 4; iDirection++)
            {
                iObservation *= 2;
                if (WallInDirection(s.X, s.Y, d))
                {
                    iObservation++;
                }
                d = s.TurnRight(d);
            }
            return(new MazeObservation(iObservation));
        }
Exemple #2
0
 private bool WallInDirection(int iX, int iY, MazeState.Direction d)
 {
     if (d == MazeState.Direction.South)
     {
         return(BlockedSquare(iX, iY + 1));
     }
     if (d == MazeState.Direction.North)
     {
         return(BlockedSquare(iX, iY - 1));
     }
     if (d == MazeState.Direction.East)
     {
         return(BlockedSquare(iX + 1, iY));
     }
     if (d == MazeState.Direction.West)
     {
         return(BlockedSquare(iX - 1, iY));
     }
     return(false);
 }