Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: separate move functions?

Author: Sune Fischer

Date: 06:34:32 12/12/01

Go up one level in this thread


On December 11, 2001 at 20:03:41, Wylie Garvin wrote:

>>>However, my observation is that at the time you GENERATE moves you know what
>>>kind of move you are generating;
>>
>>Precisely, so I put that information into the move sort of like this:
>>
>>move.typeofmove = WCastleQ; or
>>move.typeofmove = BEnPassent;
>>
>>then I can call the correct move rutine without checking a thing:
>>
>>pMakeMove[move.typeofmove](Position,move);
>>where pMakeMove is an array of pointers to my move functions.
>>
>One thing to watch out for is, calling functions through pointers can be slow on
>some kinds of machines.  For example, on Intel it will be slow unless the
>compiler can predict well in advance which actual function you are going to call
>(or unless you are calling the same one like 90% of the time).

Well chess programs are all ready infected with branch prediction problems, I
thought this would avoid some of that, but you think a conditional "if" is just
as fast?

Like in your method, it will call one function most of the time, the others only
at "special" moves. However when there is a special move, I needn't check
several conditionals to investigate, I can call the right function right away.

>Yeah, portability is out the window.  That's no problem--when something else
>replaces Intel as the dominant desktop machine, I'll just write a new one.  =)
>I am making some minimal use of MMX instructions for manipulating 64-bit zobrist
>keys and bitboards, but so far it appears to be faster to just use integer
>registers.  The main places where I expected them to come in handy (calculating
>attack bitboards and such) seem to have gone away in favor of BSF/BSR type
>stuff...

From what I understand of assembler it runs about a factor of 2-3 faster than
good optimized C code, but you need to spend 10 times more time on it and
debugging is hell. If that is true, I think one can easily gain a factor of 3 in
speed by improving the search algorithm and its extension, all whithin the same
time frame.

-S.



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.