Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

292
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda