public override bool CanMove(Chessboard chessboard) { //Check Square in four adjacent axis Position testPosition = new Position(); testPosition.X = Position.X + 1; testPosition.Y = Position.Y; if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(true); } testPosition.X = Position.X; testPosition.Y = Position.Y + 1; if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(true); } testPosition.X = Position.X - 1; testPosition.Y = Position.Y; if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(true); } testPosition.X = Position.X; testPosition.Y = Position.Y - 1; if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(true); } return(false); }
public override Position LongestPositionToMoveTo(Chessboard chessboard) { Position testPosition = new Position(); testPosition.X = Position.X + 1; testPosition.Y = Position.Y; if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(testPosition); } testPosition.X = Position.X; testPosition.Y = Position.Y + 1; if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(testPosition); } testPosition.X = Position.X - 1; testPosition.Y = Position.Y; if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(testPosition); } testPosition.X = Position.X; testPosition.Y = Position.Y - 1; if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(testPosition); } return(testPosition); }
public override bool CanMove(Chessboard chessboard) { Position testPosition = new Position(); //Check Square in four diagonal axis testPosition.Y = (Position.Y + 1); testPosition.X = (Position.X + 1); if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(true); } testPosition.Y = (Position.Y + 1); testPosition.X = (Position.X - 1); if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(true); } testPosition.Y = (Position.Y - 1); testPosition.X = (Position.X - 1); if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(true); } testPosition.Y = (Position.Y - 1); testPosition.X = (Position.X + 1); if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(true); } return(false); }
public override Position LongestPositionToMoveTo(Chessboard chessboard) { List <Position> _positions = new List <Position>(); Position NewPos = new Position(); for (int i = 0; i < 8; i++) { NewPos.Y = (Position.Y - (Color * i)); NewPos.X = (Position.X); NewPos.Length = i; if (chessboard.SquareOccupied(NewPos) || !NewPos.WithinBounds()) { break; } } Position NewPos2 = new Position(); for (int i = 0; i < 8; i++) { NewPos2.Y = (Position.Y + (Color * i)); NewPos2.X = (Position.X); NewPos2.Length = i; if (chessboard.SquareOccupied(NewPos2) || !NewPos2.WithinBounds()) { break; } } Position NewPos3 = new Position(); for (int i = 0; i < 8; i++) { NewPos3.Y = (Position.Y); NewPos3.X = (Position.X - (Color * i)); NewPos3.Length = i; if (chessboard.SquareOccupied(NewPos3) || !NewPos3.WithinBounds()) { break; } } Position NewPos4 = new Position(); for (int i = 0; i < 8; i++) { NewPos4.Y = (Position.Y); NewPos4.X = (Position.X + (Color * i)); NewPos4.Length = i; if (chessboard.SquareOccupied(NewPos4) || !NewPos4.WithinBounds()) { break; } } List <Position> listOfPos = new List <Position>() { NewPos, NewPos2, NewPos3, NewPos4 }; return(listOfPos.OrderByDescending(x => x.Length).ToList()[0]); }
public override bool CanMove(Chessboard chessboard) { Position testPosition = new Position(); //Check Every Square Possible... Sigh testPosition.X = Position.X + 2; testPosition.Y = Position.Y + 1; if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(true); } testPosition.X = Position.X + 1; testPosition.Y = Position.Y + 2; if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(true); } testPosition.X = Position.X - 1; testPosition.Y = Position.Y - 2; if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(true); } testPosition.X = Position.X - 2; testPosition.Y = Position.Y - 1; if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(true); } testPosition.X = Position.X + 2; testPosition.Y = Position.Y - 1; if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(true); } testPosition.X = Position.X + 1; testPosition.Y = Position.Y - 2; if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(true); } testPosition.X = Position.X - 2; testPosition.Y = Position.Y + 1; if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(true); } testPosition.X = Position.X - 1; testPosition.Y = Position.Y + 2; if (!chessboard.SquareOccupied(testPosition) && testPosition.WithinBounds()) { return(true); } return(false); }
public override Position LongestPositionToMoveTo(Chessboard chessboard) { Position NewPos = new Position(); if (HasNotMoved) { NewPos.Y = (Position.Y - (Color * 2)); NewPos.X = (Position.X); if (!chessboard.SquareOccupied(NewPos) && NewPos.WithinBounds()) { return(NewPos); } } NewPos.Y = (Position.Y - Color); NewPos.X = (Position.X); if (!chessboard.SquareOccupied(NewPos) && NewPos.WithinBounds()) { return(NewPos); } return(new Position()); }
public override bool CanMove(Chessboard chessboard) { Position TestPos = new Position(); TestPos.Y = (Position.Y - Color); TestPos.X = (Position.X); if (chessboard.SquareOccupied(TestPos) && !TestPos.WithinBounds()) { return(false); } return(true); }