1

So I’m making a chess engine and have an evaluation function that has material as (a large) part of the eval weighting. But the eval function (as if depth is 1) will think that one side is up a piece if a defended piece is taken and hasn’t been taken back yet.

You might think that’s not a problem as this is why we have search depth, but I have the issue that if the search ends with ‘half’ a trade then the program thinks this is a bad move when maybe it isn’t.

How do I implement something in the eval function to let it know the position is still equal.

1 Answer 1

2

What you are looking for is a quiescence search. Chess programming wiki has a helpful guide to it here: https://www.chessprogramming.org/Quiescence_Search. A quiescence search is a search that searches only captures. When depth reaches 0 in your search, instead of returning the static evaluation of a position, return the output from a quiescence search. Here is the pseudocode (assuming a minimax-esque search function)

func quiescence(alpha, beta) // no depth!
    eval = static_eval()
    if eval >= beta : return beta
    else if eval < alpha : alpha = eval
    capture_moves = generate_capture_moves()
    for move in capture_moves:
        push(move)
        eval = -quiescence(-beta, -alpha)
        unpush(move)
        if eval >= beta : return beta
        else if eval < alpha : alpha = eval
    return alpha

If you search until a position with no captures, this problem does not arise.

1
  • Thank you very much @BanjoMan! Jul 23 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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