Author: Dezhi Zhao
Date: 08:15:24 02/21/03
Go up one level in this thread
On February 21, 2003 at 04:14:49, Uri Blass wrote: >On February 20, 2003 at 13:51:37, Filip Tvrzsky wrote: > >>On February 20, 2003 at 12:49:39, Uri Blass wrote: >> >>> >>>I guess that you mean >>>#define gen_dat_i_mpromote (gen_dat[i].m & (63 << 16)) >>> >>>I guess that the laternative that I tried >>> >>>#define to(x) (((x)>>8)&255) was also bad >>>and better was >>>#define to(x) (((x)&255<<8) >>> >>>I guess that in that case I need to change some more code >>> >>>For example >>> >>>I have today some cases when I have >>>switch(m.bits) >>>case 1: >>>case 17: >>>... >>> >>>in that case I need to say case 1<<24 and in order not to have an ugly code >>>I need to have more constants for 2^24,2^24*17,... >>> >>>I can use >>>enum >>>{ >>> bits1=16777216 >>> bits17= >>>... >>>} >>> >>>Uri >> >>#define to(x) (((x)>>8)&255) is definitely worse than #define to(x) >>(((x)&255<<8) because in the first case the shifting is done in run-time and in >>the second during compilation. Note also that the result of both macros is >>different. > >Yes > >This is an important note. > >I did not do the mistake of assuming that they are the same but I see that I >have problems. > >I cannot use my usual macros after that translate > >for example > >I had if (piece(m.b.to))=PAWN) in my code >I cannot transalate it to >if (piece(to(m))==PAWN) because to(m) does not get something between 0 and 63 >after the change and it seem that I cannot do it faster in this case. > you probabaly need another inline function or micro here: #define IsPawn(move) (piece(move.b.to) == PAWN) If you are using VC, inline functions are prefered. You can easily browse these inline fuctions. And the compiler does type checking that is certainly helpful. >There are number of cases when I can do it faster for example if I check if the >rank of to is the first rank but I also need special definitions for it. > >I guess that I will not change the defintion of to(m) to the better definition >and for special cases I can add other definitions like >#define rankto(i) i&(1<<12+1<<13+1<<14) > >#define rankto1 0 >#define rankto2 1<<12 >#define filetoa 0 >#define filetob 1<<9 > >Here the numbers are not magiv numbers because we usually use numbers in chess >but I still does not like these definitions. > > >I think that I will do changing my data structure in some steps when the first >step is the slow definition and using the slow definition for to(m) because >changing too much at the same time is a sure way to get bugs. > >It means that the first step may make Movei slower and I need only to check that >I did not do errors and only later it will become faster. > >I do not plan to add evaluation before I do it because it will do that work even >harder. > >If I want to change my data structure then it is better to do it earlier even if >it means smaller improvement in the near future relative to changing the >evaluation. > >Uri
This page took 0.01 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.