Author: Russell Reagan
Date: 10:50:13 01/17/04
Go up one level in this thread
On January 17, 2004 at 12:24:59, Robert Hyatt wrote:
>There is probably some break-even point in how many times you use one or the
>other, before the other is preferable. I wouldn't try to predict without
>running it however.
One thing I do sometimes (based on my blind faith in the compiler) is store
intermediate values in a const variable (usually in a function). My hope is that
the compiler will be able to make the best choice about whether or not to go
ahead and store the intermediate value, or whether to substitute the small
computation in the one or two places where it is used in the function. Is this a
good idea, or is there any reason why I should avoid this?
An example of something I might do:
// In movegen...
Bitboard rooksLeft = friendlyRooks;
while (rooksLeft)
{
const int from = FirstOne(rooksLeft);
const Bitboard attacks = RookAttacks(from); // <-- Store intermediate value
// Generate captures
Bitboard moves = attacks & enemyPieces; // <--- Use attacks once
while (moves)
{
// Generate the captures...
}
// Generate noncaptures
moves = attacks & emptySquares; // <--- Use 'attacks' again
while (moves)
{
// Generate the noncaptures...
}
}
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.