pawns

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

flok

pawns

Post by flok »

Hi,

I've implemented a pawn hash table, this gave a -12 elo. Not entirely unexpected as the only pawn code is the passed pawn code.
Tried adding countNDoublePawns and countNIsolatedPawns but those gave a -13 elo.

Two questions:
- what is expected to gain from a pawn hash?

- is there anything wrong with those routines?

Code: Select all

int countNIsolatedPawns(const Board *const b, const ChessPiece * const *objs)
{
        int n = 0;

        const PlayerColor col = objs[0] -> getColor();

        for&#40;int i1=0; i1<16; i1++)
        &#123;
                const ChessPiece *const cur = objs&#91;i1&#93;;
                if (!cur -> getAlive&#40;) || cur -> getType&#40;) != PAWN&#41;
                        continue;

                bool protector = false;

                for&#40;int i2=0; i2<16; i2++) &#123;
                        const ChessPiece *const prot = objs&#91;i2&#93;;
                        if &#40;i1 == i2 || !prot -> getAlive&#40;) || prot -> getType&#40;) != PAWN&#41;
                                continue;

                        if &#40;col == WHITE && abs&#40;prot -> getX&#40;) - cur -> getX&#40;)) == 1 && prot -> getY&#40;) < cur -> getY&#40;)) &#123;
                                protector = true;
                                break;
                        &#125;
                        else if &#40;col == BLACK && abs&#40;prot -> getX&#40;) - cur -> getX&#40;)) == 1 && prot -> getY&#40;) > cur -> getY&#40;)) &#123;
                                protector = true;
                                break;
                        &#125;
                &#125;

                n += !protector;
        &#125;

        return n;
&#125;

Code: Select all

void countObjects&#40;const ChessPiece * const *myObjects, int counts&#91;6&#93;&#91;8&#93;)
&#123;
        for&#40;int i=0; i<16; i++) &#123;
                if (!myObjects&#91;i&#93; -> getAlive&#40;))
                        continue;

                counts&#91;myObjects&#91;i&#93; -> getType&#40;)&#93;&#91;myObjects&#91;i&#93; -> getX&#40;)&#93;++;
        &#125;
&#125;

int nDoublePawns&#40;int obCountsMe&#91;6&#93;&#91;8&#93;)
&#123;
        int cnt = 0;

        for&#40;int i=0; i<8; i++)
                cnt += obCountsMe&#91;PAWN&#93;&#91;i&#93; >= 2;

        return cnt;
&#125;

Code: Select all

pawnScore = -15 * &#40;countNIsolatedPawns&#40;b, myObjects&#41; - countNIsolatedPawns&#40;b, hisObjects&#41;);

// ppfc&#58; pawns per file
pawnScore -= 15 * &#40;countNDoublePawns&#40;myPPFC&#41; - countNDoublePawns&#40;hisPPFC&#41;); // MAX 15*4 = 60
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: pawns

Post by cdani »

flok wrote: - what is expected to gain from a pawn hash?
Should be proportional to the number of things that it saves to recalculate. For example I have on it:
* passed
* weak
* pawn attack span
* pawn structure evaluation accelerators
* king safety stuff
* number of pawns in front of the king (also for king safety late calculations)
* various flags like pawn blockade in the center.
A whopping 64 bytes for entry.
I did not count how many elo wins, but should be in the 10-15 or more.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: pawns

Post by hgm »

flok wrote:- what is expected to gain from a pawn hash?
Speed. Nothing else. You should beable osee the Elo gain directly from the NPS. 1Elo ~ 1% speed. So apparently you run 12% slower with the paw hash. If not, the test is flawed.