Skip to main content
found more mistakes in the code
Source Link
Roland Illig
  • 21.4k
  • 2
  • 34
  • 83

In the chess variant I know best, the rooks are in the corners, not the bishops. Oh, I see. You just confused their names, but the moves are correct. The bishop is the one that moves diagonally.

How can your program ever work correctly if IsGameOver always returns false?

To check the valid knight moves, you can combine all the conditions into one:

var dx = dest.Width - Position.Width;
var dy = dest.Height - Position.Height;
return dx * dx + dy * dy == 5;

You should rename the Position fields to Rank and File since these words are more common in chess.

There are several more mistakes in the code:

  • Both players start with 2 kings in their inventory, but only one on the board (count how often Add(whiteKing) appears in the code).
  • Bishops (what you call rooks) can only move along one of the diagonals, but not the others.
  • Same for the queens.
  • White pawns can move sideways, but only to the right. They capture in the same way as they move, unlike in standard western chess.
  • Pawns cannot move 2 squares with their initial move.
  • Castling is not allowed.
  • Pawns can enter the last rank without being promoted.
  • The queens start in the e file; they should start in the d file.

In the chess variant I know best, the rooks are in the corners, not the bishops. Oh, I see. You just confused their names, but the moves are correct. The bishop is the one that moves diagonally.

How can your program ever work correctly if IsGameOver always returns false?

To check the valid knight moves, you can combine all the conditions into one:

var dx = dest.Width - Position.Width;
var dy = dest.Height - Position.Height;
return dx * dx + dy * dy == 5;

You should rename the Position fields to Rank and File since these words are more common in chess.

In the chess variant I know best, the rooks are in the corners, not the bishops. Oh, I see. You just confused their names, but the moves are correct. The bishop is the one that moves diagonally.

How can your program ever work correctly if IsGameOver always returns false?

To check the valid knight moves, you can combine all the conditions into one:

var dx = dest.Width - Position.Width;
var dy = dest.Height - Position.Height;
return dx * dx + dy * dy == 5;

You should rename the Position fields to Rank and File since these words are more common in chess.

There are several more mistakes in the code:

  • Both players start with 2 kings in their inventory, but only one on the board (count how often Add(whiteKing) appears in the code).
  • Bishops (what you call rooks) can only move along one of the diagonals, but not the others.
  • Same for the queens.
  • White pawns can move sideways, but only to the right. They capture in the same way as they move, unlike in standard western chess.
  • Pawns cannot move 2 squares with their initial move.
  • Castling is not allowed.
  • Pawns can enter the last rank without being promoted.
  • The queens start in the e file; they should start in the d file.
deleted 1 character in body
Source Link
Roland Illig
  • 21.4k
  • 2
  • 34
  • 83

In the chess variant I know best, the rooks are in the corners, not the bishops. Oh, I see. You just confused their names, but the moves are correct. The bishop is the one that moves diagonally.

How can your program ever work correctly if IsGameOver always returns false?

To check the valid knight moves, you can combine all the conditions into one:

var dx = dest.Width - Position.Width;
var dy = dest.Height - Position.Height;
return dx * dx + dy * dy == 5;

You should rename the Position fields to RowRank and ColumnFile since these words are more common in chess.

In the chess variant I know best, the rooks are in the corners, not the bishops. Oh, I see. You just confused their names, but the moves are correct. The bishop is the one that moves diagonally.

How can your program ever work correctly if IsGameOver always returns false?

To check the valid knight moves, you can combine all the conditions into one:

var dx = dest.Width - Position.Width;
var dy = dest.Height - Position.Height;
return dx * dx + dy * dy == 5;

You should rename the Position fields to Row and Column since these words are more common in chess.

In the chess variant I know best, the rooks are in the corners, not the bishops. Oh, I see. You just confused their names, but the moves are correct. The bishop is the one that moves diagonally.

How can your program ever work correctly if IsGameOver always returns false?

To check the valid knight moves, you can combine all the conditions into one:

var dx = dest.Width - Position.Width;
var dy = dest.Height - Position.Height;
return dx * dx + dy * dy == 5;

You should rename the Position fields to Rank and File since these words are more common in chess.

Source Link
Roland Illig
  • 21.4k
  • 2
  • 34
  • 83

In the chess variant I know best, the rooks are in the corners, not the bishops. Oh, I see. You just confused their names, but the moves are correct. The bishop is the one that moves diagonally.

How can your program ever work correctly if IsGameOver always returns false?

To check the valid knight moves, you can combine all the conditions into one:

var dx = dest.Width - Position.Width;
var dy = dest.Height - Position.Height;
return dx * dx + dy * dy == 5;

You should rename the Position fields to Row and Column since these words are more common in chess.