Author: Uri Blass
Date: 09:55:21 01/03/03
Go up one level in this thread
On January 03, 2003 at 12:19:43, Dave Gomboc wrote:
>On January 03, 2003 at 12:03:45, Uri Blass wrote:
>
>>code B is slightly faster than code A.
>>I know that side can get only 0 or 1(something that the compiler does not know)
>>and B is eqvivalent to A if you assume that side gets only 0 or 1.
>>
>>Is it possible to write a third code that will be even faster than B?
>>
>>I think that if the compiler can know that side is or 0 or 1 it can do B even
>>faster.
>>
>>code A:
>>
>>if (side==LIGHT)
>>{
>> if (to>=56)
>> {
>> gen_promote(from,to,bits);
>> return;
>> }
>>}
>>else
>>{
>> if (to<=7)
>> {
>> gen_promote(from,to,bits);
>> return;
>> }
>>}
>>
>>code B:
>>if ((to+side*(63-2*to))>=56)
>>{
>> gen_promote(from,to,bits);
>> return;
>>}
>>
>>Uri
>
>If you used a (C++) bool instead of an int, then the compiler would know that
>only two values are possible.
>
>Dave
I use microsoft visual c++ but my files end with .c.
I know that badically C and C++ are not exactly the same and there are small
differences(inspite of the fact that in most of the cases C codes will work also
as C++ codes)
I decided for that reason not to have .cpp files but only .c files.
I think that I will solve the problem simply by having 2 functions for white and
for black(I already have 2 function for white and for black in pawns moves
and the above code is only relevant for pawns).
Uri
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.