1

I have made a chess engine that can play a decent game of chess. Like a lot of engines it uses a minimax search algorithm with alpha-beta pruning. It uses this simple evaluation function to assign a score. The problem I have is that the engine does not attempt to go for checkmate. Against Stockfish, it will attempt to capture all the enemy pieces and then get a queen via pawn promotion, presumably to maximize its score. It sometimes stumbles upon a mate position, but it is more common to result in stalemate even with multiple pieces (queen, rooks, bishops) vs a lone king. I think this is because my algorithm currently only encourages maximizing the difference in score (white vs black) and has no concept of mate. One idea I had is increasing the piece value of the king to encourage mate. Are there any methods to encourage the engine to go for mate rather than a massive material imbalance?

3

Are there any methods to encourage the engine to go for mate rather than a massive material imbalance?

Any reasonably sophisticated position evaluation function is going to give extra points for certain positional elements (passed pawns, advanced pawns, bishop pair, etc.) and deduct points for other negative positional elements (doubled pawns, isolated pawns, bad bishop, unsafe king, etc)

Obviously any halfway decent evaluation function is also going to handle positional elements like checkmate (add MAXINT), stalemate (assign 0.0), 3-fold repetition (0.0), 50 move rule (0.0), insufficient material (0.0), etc.

If all your evaluation function does is use piece values and nothing else then you still have a lot of work to do to have an engine that is any good.

2
  • 1
    Yep- to solve this precise issue, what you'd want to do is have any position with mate have an evaluation of the maximum value your language allows (generally there'll be some environment constant like MAXINT or math.MAXINT or whatever) – pulsar512b Dec 17 '20 at 0:04
  • Thank you for the MAXINT tip it appears to work (makes engine go for mate). However, is there a method to efficiently determine if a position is mate. I implemented the obvious way, finding zero legal moves, but this if of course extremely slow. – operator Dec 17 '20 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.