pawns

Discussion of chess software programming and technical issues.

Moderator: Ras

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(int i1=0; i1<16; i1++)
        {
                const ChessPiece *const cur = objs[i1];
                if (!cur -> getAlive() || cur -> getType() != PAWN)
                        continue;

                bool protector = false;

                for(int i2=0; i2<16; i2++) {
                        const ChessPiece *const prot = objs[i2];
                        if (i1 == i2 || !prot -> getAlive() || prot -> getType() != PAWN)
                                continue;

                        if (col == WHITE && abs(prot -> getX() - cur -> getX()) == 1 && prot -> getY() < cur -> getY()) {
                                protector = true;
                                break;
                        }
                        else if (col == BLACK && abs(prot -> getX() - cur -> getX()) == 1 && prot -> getY() > cur -> getY()) {
                                protector = true;
                                break;
                        }
                }

                n += !protector;
        }

        return n;
}

Code: Select all

void countObjects(const ChessPiece * const *myObjects, int counts[6][8])
{
        for(int i=0; i<16; i++) {
                if (!myObjects[i] -> getAlive())
                        continue;

                counts[myObjects[i] -> getType()][myObjects[i] -> getX()]++;
        }
}

int nDoublePawns(int obCountsMe[6][8])
{
        int cnt = 0;

        for(int i=0; i<8; i++)
                cnt += obCountsMe[PAWN][i] >= 2;

        return cnt;
}

Code: Select all

pawnScore = -15 * (countNIsolatedPawns(b, myObjects) - countNIsolatedPawns(b, hisObjects));

// ppfc: pawns per file
pawnScore -= 15 * (countNDoublePawns(myPPFC) - countNDoublePawns(hisPPFC)); // 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: 28480
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.