Computer Chess Club Archives


Search

Terms

Messages

Subject: a question for ed schröder

Author: martin fierz

Date: 09:51:28 04/10/04


hi ed,

you posted the stuff below a day or two ago, and i have a question about it:

you suggest creating a "translation table" to get an unbroken and continuous
string of characters and then use this in a switch statement. if i understand
this right, i'd have to make a rather large first table which does something
like

material-signature = function(pieces); somewhere in the 0...~4000 range (as far
as i can see, you need to be able to represent any combination of 1 vs 1 or
better 2 vs 2 pieces)

X=conversiontable[material-signature] ~ somewhere in the 0...20 range for all
special cases you want to consider.

then you do switch(X) - now how does the compiler know that the conversiontable
values are in a single range?? i don't understand how it can possibly know this
:-(

cheers
  martin

*******************************************************************************
I think I misread, I thought one of your worry was all the time-consuming
compares and jumps to go to the relevant parts of eval depending of the material
on the board. If so, create a 2-dimensional translation table that converts the
present material to an unbroken and continuous string of characters
(0,1,2,3,4,5.....) and then use the result with switch-case.

I have such an endgame table with over 30 entries (KPK, KRK, KBNK, KQKR, KNKPP,
KBKPPP, KRPKR etc.) and instead of doing 30 expensive compares I just have to do
2 initialization instructions, get the value of the translation table and then
the switch-case will move me with just one assembler instruction to the right
place (label). Imagine the speed gain.

  switch (val) { case  0 : goto KPK;
                 case  1 : goto KRK;
                 case  2 : goto KNBK;
                 case  3 : goto KQKR;
                 ...................
                 case 99 : goto whatever;
               }

Again, the compiler will translate this to just *one* instruction, even if you
have 200 entries and thus save 200 compares.

Ed
*****************************************************************************





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.