Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: What is wrong with this tablebase code?

Author: Rafael Andrist

Date: 01:10:00 05/12/02

Go up one level in this thread


On May 12, 2002 at 00:23:25, Todd Segal wrote:

>This is just a hack for a board with 2 K's and one Q (a sure win) and I always
>get the same wrong probing value. Is there anything wrong with the code?
>
>Thanks!
>
>- Todd Segal

>INDEX SqFindKing(square *p) { if (turn == 0)
>{ turn = 1; return 32; } else return 31; }

This is very risky. It may probably work, but you have no guarantee it does,
because it would be possible to access the position of the white King twice in a
row.

>INDEX SqFindOne (square *pcs, int p) { return 7;}
>INDEX SqFindFirst (square *pcs, int p) { return 11;}
>INDEX SqFindSecond (square *pcs, int p) { return 13;}
>INDEX SqFindThird (square *pcs, int p) { return 20;}

Ok, we have the wK on 32 == a5, the bK on 31 == h4 and the wQ on 7 == h1. Black
is in check.

>  counts[0] = 0;
>  counts[1] = 0;
>  counts[2] = 0;
>  counts[3] = 0;
>  counts[4] = 1;
>  counts[5] = 0;
>  counts[6] = 0;
>  counts[7] = 0;
>  counts[8] = 0;
>  counts[9] = 0;
>
>  int iTb = IDescFindFromCounters(counts);
>  printf("This is the correct TB: %d\n", iTb);

It may not matter here, but you should check for negative iTb and set flip
accordingly.

>  int flip = 0;
>  square w[24], b[24];
>  for (int i = 0; i < 24; i++)
>    w[i] = b[i] = 13;
>
>  int eP = 127;

why not XX, avoid unnecessary errors?

>  INDEX index = PfnIndCalc(iTb, 1) (w, b, eP, flip);
>  printf("The index value is....%d\n", index);

here, it is Black to move

>  int tbscore = L_TbtProbeTable(iTb, 0, index);
>  printf ("And the score is %d\n", tbscore);

here, it is Whito to move...




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.