Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: slow coding

Author: Daniel Mehrmannn

Date: 18:20:01 11/17/05

Go up one level in this thread


On November 17, 2005 at 21:08:06, Dann Corbit wrote:

>On November 17, 2005 at 18:34:34, Daniel Mehrmannn wrote:
>
>>On November 17, 2005 at 18:13:36, Dann Corbit wrote:
>>
>>>On November 17, 2005 at 17:05:24, Jarkko Pesonen wrote:
>>>
>>>>http://www.uciengines.de/UCI-Engines/TogaII/togaii.html
>>>>
>>>>engine name Toga 1.0MV.6
>>>>
>>>
>>>static int full_search(board_t * board, int alpha, int beta, int depth, int
>>>height, mv_t pv[], int node_type) {
>>>// ...
>>>// I set FutilityMargin in the general case, because some paths
>>>// could leave it uninitialized.
>>>   int FutilityMargin = FutilityMargin3;
>>>
>>>Consider the following when depth >= 3:
>>>
>>>			if (depth < 2)
>>>				FutilityMargin = FutilityMargin1;
>>>			else if (depth < 3)
>>>				FutilityMargin = FutilityMargin2;
>>>			/* else
>>>				FutilityMargin = FutilityMargin3; */
>>>
>>>Perhaps futility pruning is never used in such a case, but then if so there is
>>>no harm in setting the value.
>>
>>btw this looks like a very slow coding. It's better to use here switch()/case
>>stuff for an faster code instead the expensive if() stuff.
>
>A switch also branches.  The odds of a mispredicted branch are the same.
>
>If a switch were a trillion times faster than an if(), then a change to switch
>in this instance would not speed up Toga by even one tenth of one percent.  I am
>absolutely sure of it, without having measured.

I disagree. Okay, basicly it depends what are you doing and how often it called.
In my experience a switch call is faster than if().

Best,
Daniel




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.