Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

284
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!