Author: Robert Hyatt
Date: 18:07:18 07/19/02
Go up one level in this thread
On July 19, 2002 at 00:19:12, Steffen Jakob wrote:
>On July 18, 2002 at 17:48:50, Robert Hyatt wrote:
>
>// ...
>
>>>>>>>or in C-world code
>>>>>>>#define getFile(s) ((s)&7)
>>>>>>>#define getRank(s) ((s)>>3)
>>>>>>>
>>>>>>>Greetings,
>>>>>>>Steffen.
>>>>>>
>>>>>>
>>>>>>I already do this. I have "Rank()" and "File()" macros that I use most
>>>>>>everywhere already. Ditto for "From()", "To()", "Piece()", "Captured()" to
>>>>>>extract that field from the 21 bit compressed move format I use internally.
>>>>>
>>>>><nitpicking>
>>>>>crafty> egrep '&7\)|>>3\)' *.[ch] | grep -v '#define' | wc --lines
>>>>> 23
>>>>></nitpicking>
>>>>>
>>>>>Best wishes,
>>>>>Steffen.
>>>>
>>>>
>>>>your egrep is NFG. If you look, many of those are in init.c and in the
>>>>chess.h file where the File() is actually defined using that pattern. :)
>>>
>>>What's so special about init.c? I use my encapsulating code in class
>>>constructors as well ;-) BTW: the definitions of the macros are excluded by the
>>>2nd grep call with the -v option above.
>>>
>>>Greetings,
>>>Steffen.
>>
>>Note your grep -v only works on #defines where it fits on one line. Hint: mine
>>often go to 2=3=4 lines which breaks that. Also, not all &7 has anything
>
>No, I checked before I wrote the grep statement that this isnt the case for your
>rank/file macros definitions.
You missed some. At least in my version and I don't recall any changes.
The various attack functions in chess.h had &7 and >>3 in a few places
where they do the rotated attack lookups and need the rank or file number
for an index. IE here for one:
# define AttacksFile(a) \
rook_attacks_rl90[(a)][(tree->pos.occupied_rl90>> \
(56-(((a)&7)<<3)))&255]
>
>to do
>>with the file number. For example my transposition age field is 3 bits and
>
>Run my command without the piped "wc". I dont think that the age field is
>involved. Actually I couldnt find something with "age" and "7" in your code.
>
In iterate.c:
transposition_id=(transposition_id+1)&7;
>I
>>use the &7 to truncate the age... as in age = (age+1) & 7; which tricks your
>>grep into thinking that I used that file mask again. :)
>
>>In any case, I have fixed all that are legitimate rank and file accesses to
>>use the correct mask.
>
>Cool :)
>
>Please also note that my grep command doesnt find all occurences of the
>"&7"-stuff (sometimes there is a space between & and 7).
>
>E.g.:
>output.c: *text++=(From(move) & 7)+'a';
>output.c: *text++=(To(move) & 7)+'a';
>output.c: *text++=(From(move) & 7)+'a';
>output.c: *text++=(To(move) & 7)+'a';
>
>I hope all this doesnt sound too nitpicking. :)
>
Nope, suggestions _always_ welcome. :)
>>By the way, another error is that I do have some >>32 operations which breaks
>>your >>3 string match too. :)
>
>No, it doesnt because I wrote >>3\). Note the closing bracket! :-)
>
You are correct. I "parsed out" the \ when reading it. :)
>Best wishes,
>Steffen.
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.