Пример #1
0
 public bool IsValidPosition(BoardPosition position)
 {
     if(!IsInBounds(position))
         return false;
     Key key = GetKeyInternal(position.X, position.Y);
     if (key == Key.Invalid)
         return false;
     return true;
 }
Пример #2
0
 private List<BoardPosition> GetPotentialMoves(BoardPosition cp)
 {
     List<BoardPosition> potentialMoves = new List<BoardPosition>();
     int CX = cp.X; //current X
     int CY = cp.Y; //current Y
     //there are 8 possible knight moves
     potentialMoves.Add(new BoardPosition() { X = CX - 1, Y = CY + 2 });
     potentialMoves.Add(new BoardPosition() { X = CX + 1, Y = CY + 2 });
     potentialMoves.Add(new BoardPosition() { X = CX - 1, Y = CY - 2 });
     potentialMoves.Add(new BoardPosition() { X = CX + 1, Y = CY - 2 });
     potentialMoves.Add(new BoardPosition() { X = CX - 2, Y = CY - 1 });
     potentialMoves.Add(new BoardPosition() { X = CX - 2, Y = CY + 1 });
     potentialMoves.Add(new BoardPosition() { X = CX + 2, Y = CY + 1 });
     potentialMoves.Add(new BoardPosition() { X = CX + 2, Y = CY - 1 });
     return potentialMoves;
 }
Пример #3
0
 private bool IsInBounds(BoardPosition position)
 {
     return IsValidXPosition(position.X) && IsValidYPosition(position.Y);
 }
Пример #4
0
 public Key GetKey(BoardPosition position)
 {
     if(!IsValidPosition(position))
         throw new InvalidPositionException(position.ToString());
     return GetKeyInternal(position.X, position.Y);
 }