Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: question about when to use local varaibles

Author: Uri Blass

Date: 15:20:02 09/05/03

Go up one level in this thread


On September 05, 2003 at 17:23:05, Uri Blass wrote:

>On September 05, 2003 at 17:08:43, Robert Hyatt wrote:
>
>>On September 05, 2003 at 16:17:48, Uri Blass wrote:
>>
>>>I want to have some rule when it is a good idea to use local varaibles.
>>>
>>>I believe that it is clear that when instead of changing the hash key zob[hply]
>>>many times in my makemove it is better to start using local varaible and start
>>>my makemove with
>>>	__int64 zob=zobkey[hply];
>>>and finish it with when hply was already increased by 1 with
>>>zobkey[hply]=zob;
>>>
>>>My question is how many times using the same expression zobkey[hply]
>>>justify using local varaible
>>
>>I don't see any benefit to doing what you are doing.  IE
>>zobkey[hply+1]=zobkey[hply]; will make the copy.  The only thing you save
>>is the indexing operation needed to access zobkey[hply+1] as you modify it.
>>But a good compiler will probably be able to optimize that into a register
>>anyway if you make sure that you copy and update it as quickly as possible
>>before doing anything else...
>
>I do not see how I do it without loss of speed because of other reasons.
>part of the update that I do are only in case of capture or only in case of
>castling and if I update it in the beginning without changing more information
>then I may have the same if twice.
>
>I will need to check if the move is a capture one time for updating the hash key
>and one time for updating the board.
>
>Uri

Inspite of it thanks for the advice

I see that I could make movei slightly faster(less than 1% difference) by
not delaying something that I have to do.

__int64 zob=zobkey[hply]^zobrist[0][0][0];

I know that it may be compiler random optimization but I tend to guess that it
is better to start with things that I can know that I must do.

Maybe it is also better if I xor also with the following info

zobrist[piece(m.from)][side][m.from]^zobrist[piece(m.from)][side][m.to];

Today I have if (side==LIGHT) in my makemove so I decided to xor with

zobrist[piece(m.from)][LIGHT][m.from]^zobrist[piece(m.from)][LIGHT][m.to];

or in the else case to xor with

zobrist[piece(m.from)][DARK][m.from]^zobrist[piece(m.from)][DARK][m.to]


note that piece(m.from) is by definition
info[m.from]&8 and I can translate it to info[m.from] when side=LIGHT and
to info[m.from]-8 when side=DARK.

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.