Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

285
Vistas
How do I detect a stalemate in checkers?

For my school project I am creating a game of checkers. I have managed to make the all of it work properly until just now I realized it's possible to have a stalemate where one player is unable to move any pieces. I'm not sure if I'm supposed to post my code here or anything but if I have to please let me know and I will. Thanks!

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You have to have some way of analyzing the board and knowing possible legal moves (e.g. pawn can move one forward unless it is blocked by another piece, bishop goes diagonally until it is blocked by piece of same color or enemy piece and so on; keep in mind that you have to filter these in a way to not allow moves which would put you in a check). I assume you have it anyway, because you can't allow player to take illegal move.

When you have list of possible legal moves, just check to see if it is empty (no possible moves) and at the same time player is not in a check (because being in a check without any legal move to make means being in check-mate). And that's all

EDIT:

just now I realized it's possible to have a stalemate

It seems to me that you may have forgotten some other "uncommon" chess rules. Here is a list of what you might want to look at:

  • Fifty-move rule
  • Three fold repetition
  • Insufficient material (Situation where there are not enough pieces to put enemy in check mate, while assuming neither of you will make a colosal mistake. When one gets into this situation it is considered a draw)
  • Castling rules while in check (You cannot castle if king would be in check while castling, even if at the start and at the end of castling he wouldn't be in check
  • Pawn promotion and En passant, but those are quite obvious rules and you probably have them implemented already
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda