hahaharry10 / Chess-Game

This project will create a command line chess game that will talk wirelessly to a second device.
0 stars 0 forks source link

Stalemate #16

Open hahaharry10 opened 1 year ago

hahaharry10 commented 1 year ago

Discuss best approaches to scan for a stalemate

hahaharry10 commented 1 year ago

one of the obvious ways of checking for a stalemate is by going through each piece and checking if there is a move that can be made. however, the worst-case scenario (stalemate being reached) means that every piece must be cehcked to be able to move every possible path

hahaharry10 commented 1 year ago

To further show that this approach is inefficient to also check for a stalemate the algorithm must check that the king's move does not lead it to check. Lets hope there is a more efficient algorithm to test for stalemate

hahaharry10 commented 1 year ago

The best approach to test for stalemate Is to create a greedy algorithm that tests for all the possible ways to test for a stalemate

hahaharry10 commented 1 year ago

according to chesswizards (https://chesswizards.com/buzz/stalemate/):

There ways a stalemate is caused through 4 ways:

  1. Insufficient material.
  2. No legal moves.
  3. 3-fold repetition.
  4. 50 king moves with no other legal moves.

Insufficient material:

The minimal number of pieces to execute a checkmate are the king and rook, a pair of a king and either a bishop or knight cannot execute a checkmate and is therefore a stalemate.

No legal moves:

The opponent cannot make a legal move and is currently not in check, the result is a stalemate.

3-fold repetition:

This is a stalemate that can be claimed and isn't automatically called. 3-fold repetition is when the board is in the same state and the same move is played 3 times.

50 king moves with no legal moves:

The king is moved 50 times with no other legal moves. So an opponent cannot just play the king 50 times when other pieces can be played

hahaharry10 commented 1 year ago
  1. Insufficient material.
  2. No legal moves.
  3. 3-fold repetition.
  4. 50 king moves with no other legal moves.

To make this algorithm greedy we will be implementing a stalemate algorithm to test for stalemate in the order of 2,1,3,4. As the most frequent form of stalemate is no legal moves.