public static void Main()
Chess chess = new Chess();
Point queen = new Point(4, 0);
Point[] pawns = new Point[] { new Point(1, 3), new Point(3, 1), new Point(3, 4), new Point(3, 7),
new Point(2, 5), new Point(5, 5), new Point(5, 7), new Point(7, 5) };
chess.SetFixedPieces(queen, pawns);
Console.WriteLine("Mov{0} ({1}, {2})", mov, chess.m_queen.X, chess.m_queen.Y);
for(; i < chess.ROWS; i++)
for(; j < chess.COLS; j++)
if(chess.FindPawn(new Point(i, j)))
Console.WriteLine("Mov{0} ({1}, {2}): {3}, {4}", ++mov, chess.m_queen.X, chess.m_queen.Y, i, j);
private const char PAWN = 'P';
private const char QUEEN = 'Q';
private const char EMPTY = '\0';
public readonly int ROWS = 8;
public readonly int COLS = 8;
public char [,] ChessBoard {private set; get;}
ChessBoard = new char [ROWS, COLS];
public void SetFixedPieces(Point queen, Point [] pawns)
ChessBoard [p.X, p.Y] = PAWN;
if (queen.X > ROWS || queen.Y > COLS)
throw new ArgumentException("Invalid queen position.");
ChessBoard [queen.X, queen.Y] = QUEEN;
public bool IsInBoard(Point point)
return (point.X >= 0 && point.X < ROWS) &&
(point.Y >= 0 && point.Y < COLS);
public void QueenEatPaw()
ChessBoard [m_queen.X, m_queen.Y] = QUEEN;
public bool FindPawn(Point offset)
Point result = new Point(m_queen.X, m_queen.Y);
if (IsInBoard(new Point(result.X, result.Y)) && offset.Y == 0 &&
ChessBoard [result.X, result.Y] == PAWN)
if (IsInBoard(new Point(result.X, result.Y)) && offset.Y == 0 &&
ChessBoard [result.X, result.Y] == PAWN)
if (IsInBoard(new Point(result.X, result.Y)) && offset.X == 0 &&
ChessBoard [result.X, result.Y] == PAWN)
if (IsInBoard(new Point(result.X, result.Y)) && offset.X == 0 &&
ChessBoard [result.X, result.Y] == PAWN)
if(offset.X > 0 && offset.X == offset.Y)
if (IsInBoard(new Point(result.X, result.Y)) &&
ChessBoard [result.X, result.Y] == PAWN)
if(offset.X > 0 && offset.X == offset.Y)
if (IsInBoard(new Point(result.X, result.Y)) &&
ChessBoard [result.X, result.Y] == PAWN)
if(offset.X > 0 && offset.X == offset.Y)
if (IsInBoard(new Point(result.X, result.Y)) &&
ChessBoard [result.X, result.Y] == PAWN)
if(offset.X > 0 && offset.X == offset.Y)
if (IsInBoard(new Point(result.X, result.Y)) &&
ChessBoard [result.X, result.Y] == PAWN)