Somethings wrong but where (lol)

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Daniel Anulliero
Posts: 759
Joined: Fri Jan 04, 2013 4:55 pm
Location: Nice

Somethings wrong but where (lol)

Post by Daniel Anulliero »

good evening all
Well , Isa , my chess engine is a (weak) classical mailbox engine
It has hashtables, quiescence (MVV LVA) and pvs with nullmove and LMR
Yesterday I decided to apply the henk's idea in Isa , just to see
(henk's idea is : only material in eval )
Here is the result from the start position (tc = 5'+1"):

Code: Select all

1 0 20 0 a2a3
2 0 63 0 a2a3 b8a6
3 0 527 0 a2a3 b8a6 a3a4
4 0 1142 0 a2a3 b8a6 a3a4 a8b8
5 0 1953 0 a2a3 b8a6 a3a4 a8b8 a4a5
6 0 2563 0 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4
7 0 5166 0 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3
8 0 13827 0 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5
9 0 25079 0 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5 a1a2
10 0 42608 0 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5 a1a2 g8h6
11 0 72171 0 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5 a1a2 g8h6 f2f3
12 0 180827 1 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5 a1a2 g8h6 f2f3 b8a8
13 0 283651 3 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5 a1a2 g8h6 f2f3 b8a8 g2g3
14 0 504724 5 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5 a1a2 g8h6 f2f3 b8a8 g2g3 f7f6
15 0 1480829 14 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5 a1a2 g8h6 f2f3 b8a8 g2g3 f7f6 d2d4
16 0 2071862 24 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5 a1a2 g8h6 f2f3 b8a8 g2g3 f7f6 d2d4 g7g6
My first question : do you think depth 16 is normal for a mailbox program ?

Now I just added some pst (for all pieces) in Isa :

Code: Select all

1 50 20 0 b1c3
2 0 60 0 b1c3 b8c6
3 50 534 0 b1c3 b8c6 g1f3
4 0 1270 0 b1c3 b8c6 g1f3 g8f6
5 40 1842 0 b1c3 b8c6 g1f3 g8f6 d2d4
6 0 6588 0 b1c3 b8c6 g1f3 g8f6 d2d4 d7d5
7 20 12428 0 b1c3 b8c6 g1f3 g8f6 d2d4 d7d5 e2e3
8 10 104642 1 e2e4 b8c6 g1f3 g8f6 e4e5 f6e4 d2d3 e4c5
9 20 165613 2 e2e4 b8c6 b1c3 g8f6 g1f3 d7d5 e4d5
10 15 642893 7 e2e4 e7e5 b1c3 b8c6 g1f3 g8f6 d2d4 f8b4 c1g5 b4c3 b2c3
11 15 843620 13 e2e4 e7e5 b1c3 g8f6 g1f3 f8b4 f3e5 d7d6 e5c4 b4c3 d2c3 f6e4
12 10 3363525 39 e2e4 e7e5 b1c3 g8f6 g1f3 b8c6 d2d4 f8b4 d4d5 b4c3
Now Isa lost 4 depths with only psts added , is it normal?
And look at the pv's :
-at depth 9 pv have 7moves
-at depth 12 pv have 10 moves
I don't think it's very logic
I read in the forum " The PV line must be superior or equal to the depth"

Now I'm lost ...
So , I decided to post my horrible PVS function :

Code: Select all

//----------------------------------------------------------------------------------------------------------------
//                                         alpha beta + PVS
//----------------------------------------------------------------------------------------------------------------
int pvs(int alpha, int beta, int depth, MOVE * pBestMove, bool nulmove)
{
    int i,j;
    int value;
    int havemove;
    int movecnt;
    int hashf = hashfALPHA;
    int rep;
    bool echec = FAUX;
    bool echec2 = FAUX;
    bool ext = FAUX;
    int ply = 0;
    MOVE moveBuf[200];
    MOVE tmpMove;

    //-----------------------------------------------------------------
    //          controle temps depasse ou non (jeu au temps)
    //-----------------------------------------------------------------
    fin_recherche = controle_si_temps_depasse();
    if(fin_recherche)
        return 0;
    //-----------------------------------------------------------------
    //                          longueur pv
    //-----------------------------------------------------------------
    long_pv[prof] = prof;
    //-----------------------------------------------------------------
    //               profondeur limite ateinte : retourne eval()
    //-----------------------------------------------------------------
    if(prof >= MAXPLY-1)
        return eval();
    //-----------------------------------------------------------------
    //                  nulle règle des 50 coups? ?
    //-----------------------------------------------------------------
    if(cinquante == 100)
    {
        return 0;
    }
    //-----------------------------------------------------------------
    //             nulle règle des triples répétitions ?
    //-----------------------------------------------------------------
    rep = triple_repetition();
    if(prof && rep)
    {
        return 0;
    }
    //-----------------------------------------------------------------
    //               position dans la table de hashage ?
    //-----------------------------------------------------------------
    if(hash_ok)
    {
        if(prof)
        {
        	value = probe_hash(depth, alpha, beta);
        	if(value != valINCONNUE)
        	{
            	return value;
        	}
		}
    }

    //-----------------------------------------------------------------
    // on ateint la profondeur en cours , on lance le quiescent search
    //-----------------------------------------------------------------
    if&#40;depth <= 0&#41;
    &#123;
        value =  quiesce&#40;alpha, beta, &tmpMove&#41;;
        return value;
    &#125;
    //-----------------------------------------------------------------
    // extension d'une profondeur si la couleur en cours est en échec
    //-----------------------------------------------------------------
    echec = roi_attaque&#40;pos_roi&#91;side&#93;, side&#41;;
    if&#40;echec&#41;
    &#123;
        depth++;
    &#125;
    //-----------------------------------------------------------------
    //              test si on peut lancer le nulmove
    //              conditions &#58;    pas de finale de pion
    //                              pas en échec
    //                              profondeur > 4
    //-----------------------------------------------------------------
    if&#40;nm_ok&#41;
    &#123;
        if&#40;(!echec&#41; && &#40;ok_pour_nul_move&#40;)) && &#40;depth >= 2&#41; && &#40;nulmove&#41; && (!follow_pv&#41;)
        &#123;
            ++ctr_nm;
            jouer_coup_nul&#40;);
            nodes++;
            value = -pvs&#40;-beta, -&#40;beta-1&#41;, depth - NULL_DEPTH - 1, &tmpMove, NO_NULL&#41;;
            dejouer_coup_nul&#40;);
            if &#40;value >= beta&#41;
            &#123;
                return beta;
            &#125;
        &#125;
    &#125;
    //-----------------------------------------------------------------
    //     init du pointeur et flag "au moins un coup jouable"
    //-----------------------------------------------------------------
    havemove = 0;
    pBestMove->type = COUP_VIDE;
    //-----------------------------------------------------------------
    //              génération des coups pseudo-légaux
    //-----------------------------------------------------------------
    movecnt = gen_coups&#40;side, moveBuf&#41;;
    if&#40;follow_pv&#41;
        tri_pv&#40;moveBuf, movecnt&#41;;
    //-----------------------------------------------------------------
    //                      boucle coups normaux
    //-----------------------------------------------------------------
    for &#40;i = 0; i < movecnt; ++i&#41;
    &#123;
        ext = FAUX;
        meilleur_coup_suivant&#40;moveBuf, movecnt, i&#41;;

        if &#40;jouer_coup&#40;moveBuf&#91;i&#93;))
        &#123;
            continue;
        &#125;

        havemove++;
        nodes++;
        //extension si pion avance a la 7eme rangée &#40;et coup non réduit lmr&#41;
        if&#40;moveBuf&#91;i&#93;.piece_from == PION && &#40;ROW&#40;moveBuf&#91;i&#93;.dest&#41; <= 1 || ROW&#40;moveBuf&#91;i&#93;.dest&#41; >= 6&#41;)
        &#123;
            ext = VRAI;
        &#125;

        if&#40;havemove == 1&#41;
        &#123;
            value = -pvs&#40;-beta, -alpha, depth - 1, &tmpMove, OK_NULL&#41;;
        &#125;
        else
        &#123;
            //------------------------------------------------------
            //                      lmr possible?
            //------------------------------------------------------
            echec2 = roi_attaque&#40;pos_roi&#91;side&#93;, side&#41;;
            if&#40;lmr_ok&#41;
            &#123;
                if&#40;&#40;prof >= START_PROF&#41; && (!echec&#41; && (!echec2&#41; && (!ext&#41; &&
                   (!follow_pv&#41; && &#40;moveBuf&#91;i&#93;.type == NORMAL&#41;)
                &#123;
                    if&#40;havemove > 5&#41;
                        value = -pvs&#40;-&#40;alpha+1&#41;, -alpha, &#40;depth - 2&#41; , &tmpMove, OK_NULL&#41;;
                    else
                        value = -pvs&#40;-&#40;alpha+1&#41;, -alpha, &#40;depth - 1&#41; , &tmpMove, OK_NULL&#41;;
                &#125;
                else
                &#123;
                    value = alpha + 1;
                &#125;
                if&#40;value > alpha&#41;
                &#123;
                    ++ctr_pvs;
                    value = -pvs&#40;-&#40;alpha+1&#41;, -alpha, depth - 1, &tmpMove, NO_NULL&#41;;
                    if&#40;value > alpha && value < beta&#41;
                    &#123;
                        value = -pvs&#40;-beta, -alpha, depth - 1, &tmpMove, OK_NULL&#41;;
                    &#125;
                &#125;
            &#125;
            else
            &#123;
                ++ctr_pvs;
                value = -pvs&#40;-&#40;alpha+1&#41;, -alpha, depth - 1, &tmpMove, NO_NULL&#41;;
                if&#40;value > alpha && value < beta&#41;
                &#123;
                    value = -pvs&#40;-beta, -alpha, depth - 1, &tmpMove, OK_NULL&#41;;
                &#125;
            &#125;
        &#125;

        dejouer_coup&#40;);

        if &#40;value > alpha&#41;
        &#123;
            history&#91;moveBuf&#91;i&#93;.from&#93;&#91;moveBuf&#91;i&#93;.dest&#93; += &#40;prof * prof&#41;;
            if&#40;history&#91;moveBuf&#91;i&#93;.from&#93;&#91;moveBuf&#91;i&#93;.dest&#93; >= 999999&#41;
                history&#91;moveBuf&#91;i&#93;.from&#93;&#91;moveBuf&#91;i&#93;.dest&#93; = 999999;
            if&#40;max_hh < history&#91;moveBuf&#91;i&#93;.from&#93;&#91;moveBuf&#91;i&#93;.dest&#93;)
            &#123;
                max_hh = history&#91;moveBuf&#91;i&#93;.from&#93;&#91;moveBuf&#91;i&#93;.dest&#93;;
            &#125;
            *pBestMove = moveBuf&#91;i&#93;;
            if &#40;value >= beta&#41;     //" cutoff "
            &#123;
                save_hash&#40;depth, beta, hashfBETA, pBestMove&#41;;

                if&#40;moveBuf&#91;i&#93;.type < PROMO_CAVALIER&#41;
                &#123;
                    killer2&#91;prof&#93; = killer1&#91;prof&#93;;
                    killer1&#91;prof&#93; = moveBuf&#91;i&#93;;
                &#125;
                return beta;
            &#125;
            hashf = hashfEXACT;
            alpha = value;

            //-----------------------------------------------------------------
            //                       mise a jour pv
            //-----------------------------------------------------------------
            pv&#91;prof&#93;&#91;prof&#93; = *pBestMove;
            for &#40;j = prof + 1; j < long_pv&#91;prof + 1&#93;; ++j&#41;
            &#123;
                pv&#91;prof&#93;&#91;j&#93; = pv&#91;prof + 1&#93;&#91;j&#93;;
            &#125;
            long_pv&#91;prof&#93; = long_pv&#91;prof + 1&#93;;
        &#125;
    &#125;
    //-----------------------------------------------------------------
    //              si aucun coups , situation de MAT ou de PAT
    //-----------------------------------------------------------------
    if (!havemove&#41;
    &#123;
        if &#40;roi_attaque&#40;pos_roi&#91;side&#93;, side&#41;)
        &#123;
            save_hash&#40;depth, -MATE + prof, hashf, pBestMove&#41;;
            return -MATE + prof;
        &#125;

        else
        &#123;
            save_hash&#40;depth, 0, hashf, pBestMove&#41;;
            return 0;
        &#125;
    &#125;
    save_hash&#40;depth, alpha, hashf, pBestMove&#41;;
    return alpha;
&#125;
Some help is welcome
bests
dany
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Somethings wrong but where (lol)

Post by hgm »

This is normal. Without positional evaluation all moves that do not give away material get exactly the same score. That means that even if you pick the moves randomly, there is a very large chance you picked the 'best' move, as all moves are equally good. So move ordering gets very good, and you will almost always have a beta cutoff with the first move you try. That helps to increase depth.
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: Somethings wrong but where (lol)

Post by Henk »

It's not my idea. I think it was an advice from Sven giving search highest priority.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Somethings wrong but where (lol)

Post by Sven »

Henk wrote:It's not my idea. I think it was an advice from Sven giving search highest priority.
Yes, I make that suggestion once in a while but it was also definitely not "my idea" ... Actually I would not (and did not, to my knowledge) recommend "material only" in its purest form (i.e. without PST). Even a very simple PST will already lead to better play, and there is almost zero runtime cost of using a PST when incrementally updating the score in make/unmake.
Dann Corbit
Posts: 12541
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Somethings wrong but where (lol)

Post by Dann Corbit »

A similar simple approach is used by Olithink.
Wood + Mobility + pawnprogressing + pawnhanging
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
mar
Posts: 2559
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Somethings wrong but where (lol)

Post by mar »

Sven Schüle wrote:Even a very simple PST will already lead to better play, and there is almost zero runtime cost of using a PST when incrementally updating the score in make/unmake.
Yes, absolutely. Even basic PSQ will already make your program "play chess".
Pure material eval will play weird nonsense moves like a4/a5 (basically anything random that gets searched first that doesn't lose material)
so using PSQ is already a huge improvement over material only (from human point of view).
Karlo Bala
Posts: 373
Joined: Wed Mar 22, 2006 10:17 am
Location: Novi Sad, Serbia
Full name: Karlo Balla

Re: Somethings wrong but where (lol)

Post by Karlo Bala »

Daniel Anulliero wrote:good evening all
Well , Isa , my chess engine is a (weak) classical mailbox engine
It has hashtables, quiescence (MVV LVA) and pvs with nullmove and LMR
Yesterday I decided to apply the henk's idea in Isa , just to see
(henk's idea is : only material in eval )
Here is the result from the start position (tc = 5'+1"):

Code: Select all

1 0 20 0 a2a3
2 0 63 0 a2a3 b8a6
3 0 527 0 a2a3 b8a6 a3a4
4 0 1142 0 a2a3 b8a6 a3a4 a8b8
5 0 1953 0 a2a3 b8a6 a3a4 a8b8 a4a5
6 0 2563 0 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4
7 0 5166 0 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3
8 0 13827 0 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5
9 0 25079 0 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5 a1a2
10 0 42608 0 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5 a1a2 g8h6
11 0 72171 0 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5 a1a2 g8h6 f2f3
12 0 180827 1 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5 a1a2 g8h6 f2f3 b8a8
13 0 283651 3 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5 a1a2 g8h6 f2f3 b8a8 g2g3
14 0 504724 5 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5 a1a2 g8h6 f2f3 b8a8 g2g3 f7f6
15 0 1480829 14 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5 a1a2 g8h6 f2f3 b8a8 g2g3 f7f6 d2d4
16 0 2071862 24 a2a3 b8a6 a3a4 a8b8 a4a5 a6b4 b2b3 b4d5 a1a2 g8h6 f2f3 b8a8 g2g3 f7f6 d2d4 g7g6
My first question : do you think depth 16 is normal for a mailbox program ?

Now I just added some pst (for all pieces) in Isa :

Code: Select all

1 50 20 0 b1c3
2 0 60 0 b1c3 b8c6
3 50 534 0 b1c3 b8c6 g1f3
4 0 1270 0 b1c3 b8c6 g1f3 g8f6
5 40 1842 0 b1c3 b8c6 g1f3 g8f6 d2d4
6 0 6588 0 b1c3 b8c6 g1f3 g8f6 d2d4 d7d5
7 20 12428 0 b1c3 b8c6 g1f3 g8f6 d2d4 d7d5 e2e3
8 10 104642 1 e2e4 b8c6 g1f3 g8f6 e4e5 f6e4 d2d3 e4c5
9 20 165613 2 e2e4 b8c6 b1c3 g8f6 g1f3 d7d5 e4d5
10 15 642893 7 e2e4 e7e5 b1c3 b8c6 g1f3 g8f6 d2d4 f8b4 c1g5 b4c3 b2c3
11 15 843620 13 e2e4 e7e5 b1c3 g8f6 g1f3 f8b4 f3e5 d7d6 e5c4 b4c3 d2c3 f6e4
12 10 3363525 39 e2e4 e7e5 b1c3 g8f6 g1f3 b8c6 d2d4 f8b4 d4d5 b4c3
Now Isa lost 4 depths with only psts added , is it normal?
And look at the pv's :
-at depth 9 pv have 7moves
-at depth 12 pv have 10 moves
I don't think it's very logic
I read in the forum " The PV line must be superior or equal to the depth"

Now I'm lost ...
So , I decided to post my horrible PVS function :

Code: Select all

//----------------------------------------------------------------------------------------------------------------
//                                         alpha beta + PVS
//----------------------------------------------------------------------------------------------------------------
int pvs&#40;int alpha, int beta, int depth, MOVE * pBestMove, bool nulmove&#41;
&#123;
    int i,j;
    int value;
    int havemove;
    int movecnt;
    int hashf = hashfALPHA;
    int rep;
    bool echec = FAUX;
    bool echec2 = FAUX;
    bool ext = FAUX;
    int ply = 0;
    MOVE moveBuf&#91;200&#93;;
    MOVE tmpMove;

    //-----------------------------------------------------------------
    //          controle temps depasse ou non &#40;jeu au temps&#41;
    //-----------------------------------------------------------------
    fin_recherche = controle_si_temps_depasse&#40;);
    if&#40;fin_recherche&#41;
        return 0;
    //-----------------------------------------------------------------
    //                          longueur pv
    //-----------------------------------------------------------------
    long_pv&#91;prof&#93; = prof;
    //-----------------------------------------------------------------
    //               profondeur limite ateinte &#58; retourne eval&#40;)
    //-----------------------------------------------------------------
    if&#40;prof >= MAXPLY-1&#41;
        return eval&#40;);
    //-----------------------------------------------------------------
    //                  nulle règle des 50 coups? ?
    //-----------------------------------------------------------------
    if&#40;cinquante == 100&#41;
    &#123;
        return 0;
    &#125;
    //-----------------------------------------------------------------
    //             nulle règle des triples répétitions ?
    //-----------------------------------------------------------------
    rep = triple_repetition&#40;);
    if&#40;prof && rep&#41;
    &#123;
        return 0;
    &#125;
    //-----------------------------------------------------------------
    //               position dans la table de hashage ?
    //-----------------------------------------------------------------
    if&#40;hash_ok&#41;
    &#123;
        if&#40;prof&#41;
        &#123;
        	value = probe_hash&#40;depth, alpha, beta&#41;;
        	if&#40;value != valINCONNUE&#41;
        	&#123;
            	return value;
        	&#125;
		&#125;
    &#125;

    //-----------------------------------------------------------------
    // on ateint la profondeur en cours , on lance le quiescent search
    //-----------------------------------------------------------------
    if&#40;depth <= 0&#41;
    &#123;
        value =  quiesce&#40;alpha, beta, &tmpMove&#41;;
        return value;
    &#125;
    //-----------------------------------------------------------------
    // extension d'une profondeur si la couleur en cours est en échec
    //-----------------------------------------------------------------
    echec = roi_attaque&#40;pos_roi&#91;side&#93;, side&#41;;
    if&#40;echec&#41;
    &#123;
        depth++;
    &#125;
    //-----------------------------------------------------------------
    //              test si on peut lancer le nulmove
    //              conditions &#58;    pas de finale de pion
    //                              pas en échec
    //                              profondeur > 4
    //-----------------------------------------------------------------
    if&#40;nm_ok&#41;
    &#123;
        if&#40;(!echec&#41; && &#40;ok_pour_nul_move&#40;)) && &#40;depth >= 2&#41; && &#40;nulmove&#41; && (!follow_pv&#41;)
        &#123;
            ++ctr_nm;
            jouer_coup_nul&#40;);
            nodes++;
            value = -pvs&#40;-beta, -&#40;beta-1&#41;, depth - NULL_DEPTH - 1, &tmpMove, NO_NULL&#41;;
            dejouer_coup_nul&#40;);
            if &#40;value >= beta&#41;
            &#123;
                return beta;
            &#125;
        &#125;
    &#125;
    //-----------------------------------------------------------------
    //     init du pointeur et flag "au moins un coup jouable"
    //-----------------------------------------------------------------
    havemove = 0;
    pBestMove->type = COUP_VIDE;
    //-----------------------------------------------------------------
    //              génération des coups pseudo-légaux
    //-----------------------------------------------------------------
    movecnt = gen_coups&#40;side, moveBuf&#41;;
    if&#40;follow_pv&#41;
        tri_pv&#40;moveBuf, movecnt&#41;;
    //-----------------------------------------------------------------
    //                      boucle coups normaux
    //-----------------------------------------------------------------
    for &#40;i = 0; i < movecnt; ++i&#41;
    &#123;
        ext = FAUX;
        meilleur_coup_suivant&#40;moveBuf, movecnt, i&#41;;

        if &#40;jouer_coup&#40;moveBuf&#91;i&#93;))
        &#123;
            continue;
        &#125;

        havemove++;
        nodes++;
        //extension si pion avance a la 7eme rangée &#40;et coup non réduit lmr&#41;
        if&#40;moveBuf&#91;i&#93;.piece_from == PION && &#40;ROW&#40;moveBuf&#91;i&#93;.dest&#41; <= 1 || ROW&#40;moveBuf&#91;i&#93;.dest&#41; >= 6&#41;)
        &#123;
            ext = VRAI;
        &#125;

        if&#40;havemove == 1&#41;
        &#123;
            value = -pvs&#40;-beta, -alpha, depth - 1, &tmpMove, OK_NULL&#41;;
        &#125;
        else
        &#123;
            //------------------------------------------------------
            //                      lmr possible?
            //------------------------------------------------------
            echec2 = roi_attaque&#40;pos_roi&#91;side&#93;, side&#41;;
            if&#40;lmr_ok&#41;
            &#123;
                if&#40;&#40;prof >= START_PROF&#41; && (!echec&#41; && (!echec2&#41; && (!ext&#41; &&
                   (!follow_pv&#41; && &#40;moveBuf&#91;i&#93;.type == NORMAL&#41;)
                &#123;
                    if&#40;havemove > 5&#41;
                        value = -pvs&#40;-&#40;alpha+1&#41;, -alpha, &#40;depth - 2&#41; , &tmpMove, OK_NULL&#41;;
                    else
                        value = -pvs&#40;-&#40;alpha+1&#41;, -alpha, &#40;depth - 1&#41; , &tmpMove, OK_NULL&#41;;
                &#125;
                else
                &#123;
                    value = alpha + 1;
                &#125;
                if&#40;value > alpha&#41;
                &#123;
                    ++ctr_pvs;
                    value = -pvs&#40;-&#40;alpha+1&#41;, -alpha, depth - 1, &tmpMove, NO_NULL&#41;;
                    if&#40;value > alpha && value < beta&#41;
                    &#123;
                        value = -pvs&#40;-beta, -alpha, depth - 1, &tmpMove, OK_NULL&#41;;
                    &#125;
                &#125;
            &#125;
            else
            &#123;
                ++ctr_pvs;
                value = -pvs&#40;-&#40;alpha+1&#41;, -alpha, depth - 1, &tmpMove, NO_NULL&#41;;
                if&#40;value > alpha && value < beta&#41;
                &#123;
                    value = -pvs&#40;-beta, -alpha, depth - 1, &tmpMove, OK_NULL&#41;;
                &#125;
            &#125;
        &#125;

        dejouer_coup&#40;);

        if &#40;value > alpha&#41;
        &#123;
            history&#91;moveBuf&#91;i&#93;.from&#93;&#91;moveBuf&#91;i&#93;.dest&#93; += &#40;prof * prof&#41;;
            if&#40;history&#91;moveBuf&#91;i&#93;.from&#93;&#91;moveBuf&#91;i&#93;.dest&#93; >= 999999&#41;
                history&#91;moveBuf&#91;i&#93;.from&#93;&#91;moveBuf&#91;i&#93;.dest&#93; = 999999;
            if&#40;max_hh < history&#91;moveBuf&#91;i&#93;.from&#93;&#91;moveBuf&#91;i&#93;.dest&#93;)
            &#123;
                max_hh = history&#91;moveBuf&#91;i&#93;.from&#93;&#91;moveBuf&#91;i&#93;.dest&#93;;
            &#125;
            *pBestMove = moveBuf&#91;i&#93;;
            if &#40;value >= beta&#41;     //" cutoff "
            &#123;
                save_hash&#40;depth, beta, hashfBETA, pBestMove&#41;;

                if&#40;moveBuf&#91;i&#93;.type < PROMO_CAVALIER&#41;
                &#123;
                    killer2&#91;prof&#93; = killer1&#91;prof&#93;;
                    killer1&#91;prof&#93; = moveBuf&#91;i&#93;;
                &#125;
                return beta;
            &#125;
            hashf = hashfEXACT;
            alpha = value;

            //-----------------------------------------------------------------
            //                       mise a jour pv
            //-----------------------------------------------------------------
            pv&#91;prof&#93;&#91;prof&#93; = *pBestMove;
            for &#40;j = prof + 1; j < long_pv&#91;prof + 1&#93;; ++j&#41;
            &#123;
                pv&#91;prof&#93;&#91;j&#93; = pv&#91;prof + 1&#93;&#91;j&#93;;
            &#125;
            long_pv&#91;prof&#93; = long_pv&#91;prof + 1&#93;;
        &#125;
    &#125;
    //-----------------------------------------------------------------
    //              si aucun coups , situation de MAT ou de PAT
    //-----------------------------------------------------------------
    if (!havemove&#41;
    &#123;
        if &#40;roi_attaque&#40;pos_roi&#91;side&#93;, side&#41;)
        &#123;
            save_hash&#40;depth, -MATE + prof, hashf, pBestMove&#41;;
            return -MATE + prof;
        &#125;

        else
        &#123;
            save_hash&#40;depth, 0, hashf, pBestMove&#41;;
            return 0;
        &#125;
    &#125;
    save_hash&#40;depth, alpha, hashf, pBestMove&#41;;
    return alpha;
&#125;
Some help is welcome
bests
dany
The first question: it's normal

Second: It is possible that you collect wrong PV

You do a full PV research only when alpha < value < beta, yet you update PV when value > alpha. My guess is that you collect PV from a non PV search, but I'm not sure.

Personally I like more:

Code: Select all

              
if&#40;value > alpha /* && value < beta */)
&#123;
  value = -pvs&#40;-beta, -alpha, depth - 1, &tmpMove, OK_NULL&#41;;
&#125; 
Best Regards,
Karlo Balla Jr.
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: Somethings wrong but where (lol)

Post by Henk »

mar wrote:
Sven Schüle wrote:Even a very simple PST will already lead to better play, and there is almost zero runtime cost of using a PST when incrementally updating the score in make/unmake.
Yes, absolutely. Even basic PSQ will already make your program "play chess".
Pure material eval will play weird nonsense moves like a4/a5 (basically anything random that gets searched first that doesn't lose material)
so using PSQ is already a huge improvement over material only (from human point of view).
Biggest problem is draw percentage. It usually plays moves like Ke8-e7, Ke7-e8 etc. In the opening of course.
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Somethings wrong but where (lol)

Post by hgm »

That is a sign of not awarding pushing Pawns forward enough. No matter how much you award developing pieces through the PST, the engine would still not do it if it thinks it can always do it later (but still within the horizon). So when there are only two moves left that would improve the score, but it searches 8 ply, it can always get the score improvement by playing a very poor move (like Nf3-g1), doing the two good moves, and then undoing the poor move. There are usually many such reversible poor moves, so statistically it is much more likely it choses those to start with than that it choses one of the two remaining good moves, no matter how good the latter are.

So for the scoring in the PST to have any effect on play, it is important that there always is a large supply of slightly beneficial moves. Then moving back and forth the same piece would leave less turns for reaping the score of the slightly beneficial moves, so that it would only consider moves that earn more without taking them back. Usually Pawn pushes provide such a supply of slightly beneficial moves.

Of course a delayed-loss bonus also helps some.
Daniel Anulliero
Posts: 759
Joined: Fri Jan 04, 2013 4:55 pm
Location: Nice

Re: Somethings wrong but where (lol)

Post by Daniel Anulliero »

Henk wrote:
mar wrote:
Sven Schüle wrote:Even a very simple PST will already lead to better play, and there is almost zero runtime cost of using a PST when incrementally updating the score in make/unmake.
Yes, absolutely. Even basic PSQ will already make your program "play chess".
Pure material eval will play weird nonsense moves like a4/a5 (basically anything random that gets searched first that doesn't lose material)
so using PSQ is already a huge improvement over material only (from human point of view).
Biggest problem is draw percentage. It usually plays moves like Ke8-e7, Ke7-e8 etc. In the opening of course.
Ok , end of "off topic" things and tanks , henk for your useful posts as always lol

Well thanks to hg , sven , Dann and martin (Henk's idea was just a small joke) for their lights

Finaly , thx to Karlo Bala jr for a long answer to my true question , and yes I think I do something wrong about PV

Please look at my code and give your advice about my PV / LMR and NUlmove method.

Also : do you think if it is normal the search drop from depth 16 to 12 when just adding pst ?
Or my move ordering is may be bad ?