Computer Chess Club Archives


Search

Terms

Messages

Subject: My algorithm for KBN vs. K

Author: Alessandro Scotti

Date: 14:54:25 09/05/04


First, thanks to all who sent suggestions for playing the KBNK endgame: they
have been very helpful! Today I could finally do some tests and the following
has been working quite well so far:

        // bk=black king square, wk=white king square, wn=white knight square

        int res = materialScore;

        res += 5000; // Bonus for won position

        // note: evaluation scaffolded for light squared bishop
        int distance_from_bishop_corner = imin(
            KingDistance[bk][H1],
            KingDistance[bk][A8] );

        int b_distance_from_center = imin(
            KingDistance[bk][D4],
            KingDistance[bk][E4],
            KingDistance[bk][D5],
            KingDistance[bk][E5] );

        int w_distance_from_center = imin(
            KingDistance[wk][D4],
            KingDistance[wk][E4],
            KingDistance[wk][D5],
            KingDistance[wk][E5] );

        int distance_of_opposition = Distance[bk][wk]; // Taxicab distance

        int distance_from_knight = KingDistance[bk][wn];

        res -= 50 * distance_from_bishop_corner;

        res -=  5 * distance_of_opposition;

        res -=  5 * distance_from_knight;

        // centralization: make sure white king is closer to the
        // center than the black king
        if( b_distance_from_center <= w_distance_from_center )
            res -= 100;

In the test position I posted earlier (black king centralized and white king in
the corner), I was getting very long sequences, sometimes long enough to make
the position a draw by the 50 moves rule. When I added the last "centralization"
factor, I got the mate in 30-35 moves on average.
I must also add that pruning doesn't work well in this kind of position for me,
so I had to add a guard or two. Without them, I have often seen my engine
playing moves that do not make any real progress towards the mate.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.