Skip to main content
added 2 characters in body
Source Link
ferit
  • 4.5k
  • 1
  • 19
  • 40

I think you are taking it too hard.

Why not simply think like this:

  1. Simulate all possible next moves by same side
  2. If, in any resulting position in simulation, king is missing(captured) go to 4
  3. King is not in check, go to 5
  4. King is in check
  5. End

Why this works? Because if king is in check, it means if the same side plays again(plays double times) it can capture the king. So if it can capture the king by playing double moves, then it means opponent was in check.

For example, assume it's BlacksBlack to move again(plays double move):

rnb1kbnr/pppp1ppp/8/4p3/6Pq/5P2/PPPPP2P/RNBQKBNR w KQkq - 1 3

Enumerate all possible moves. Now check all resulting positions, is White king missing in any position? Then it means White king was in check.

I think you are taking it too hard.

Why not simply think like this:

  1. Simulate all possible next moves by same side
  2. If, in any resulting position in simulation, king is missing(captured) go to 4
  3. King is not in check, go to 5
  4. King is in check
  5. End

Why this works? Because if king is in check, it means if the same side plays again(plays double times) it can capture the king. So if it can capture the king by playing double moves, then it means opponent was in check.

For example, assume it's Blacks move again(plays double move):

rnb1kbnr/pppp1ppp/8/4p3/6Pq/5P2/PPPPP2P/RNBQKBNR w KQkq - 1 3

Enumerate all possible moves. Now check all resulting positions, is White king missing in any position? Then it means White king was in check.

I think you are taking it too hard.

Why not simply think like this:

  1. Simulate all possible next moves by same side
  2. If, in any resulting position in simulation, king is missing(captured) go to 4
  3. King is not in check, go to 5
  4. King is in check
  5. End

Why this works? Because if king is in check, it means if the same side plays again(plays double times) it can capture the king. So if it can capture the king by playing double moves, then it means opponent was in check.

For example, assume it's Black to move again(plays double move):

rnb1kbnr/pppp1ppp/8/4p3/6Pq/5P2/PPPPP2P/RNBQKBNR w KQkq - 1 3

Enumerate all possible moves. Now check all resulting positions, is White king missing in any position? Then it means White king was in check.

added 283 characters in body
Source Link
ferit
  • 4.5k
  • 1
  • 19
  • 40

I think you are taking it too hard.

Why not simply think like this:

  1. Simulate all possible next moves by same side
  2. If, in any resulting position in simulation, king is missing(captured) go to 4
  3. King is not in check, go to 5
  4. King is in check
  5. End

Why this works? Because if king is in check, it means if the same side plays again(plays double times) it can capture the king. So if it can capture the king by playing double moves, then it means opponent was in check.

For example, assume it's Blacks move again(plays double move):

rnb1kbnr/pppp1ppp/8/4p3/6Pq/5P2/PPPPP2P/RNBQKBNR w KQkq - 1 3

Enumerate all possible moves. Now check all resulting positions, is White king missing in any position? Then it means White king was in check.

I think you are taking it too hard.

Why not simply think like this:

  1. Simulate all possible next moves by same side
  2. If, in any resulting position in simulation, king is missing(captured) go to 4
  3. King is not in check
  4. King is in check

Why this works? Because if king is in check, it means if the same side plays again(plays double times) it can capture the king. So if it can capture the king by playing double moves, then it means opponent was in check.

I think you are taking it too hard.

Why not simply think like this:

  1. Simulate all possible next moves by same side
  2. If, in any resulting position in simulation, king is missing(captured) go to 4
  3. King is not in check, go to 5
  4. King is in check
  5. End

Why this works? Because if king is in check, it means if the same side plays again(plays double times) it can capture the king. So if it can capture the king by playing double moves, then it means opponent was in check.

For example, assume it's Blacks move again(plays double move):

rnb1kbnr/pppp1ppp/8/4p3/6Pq/5P2/PPPPP2P/RNBQKBNR w KQkq - 1 3

Enumerate all possible moves. Now check all resulting positions, is White king missing in any position? Then it means White king was in check.

Source Link
ferit
  • 4.5k
  • 1
  • 19
  • 40

I think you are taking it too hard.

Why not simply think like this:

  1. Simulate all possible next moves by same side
  2. If, in any resulting position in simulation, king is missing(captured) go to 4
  3. King is not in check
  4. King is in check

Why this works? Because if king is in check, it means if the same side plays again(plays double times) it can capture the king. So if it can capture the king by playing double moves, then it means opponent was in check.