Author: Bruce Moreland
Date: 10:06:21 12/27/99
Go up one level in this thread
On December 27, 1999 at 06:59:45, José Carlos wrote:
>
>Using the profiling utility in Visual C++, I've realized that the function that
>take most of time in my program is the "addmove function".
>It is very simple, but I'd like to know if there is any programming trick, or
>any alternative way of coding this, that makes it faster.
>This is my code:
>
>typedef struct _Jugada
>{
> unsigned int Mov; // Move
> int Val; // Eval (for ordering)
>} Jugada;
>
>/* ... */
>
>Jugada PV[MAX_JUG][MAX_JUG];
>
>/* ... */
>
>void CTablero::IncluirJugada(Jugada mov)
>{
> // First, look for special cases: PV, killers
> if (EsPV)
> {
> if (mov.Mov==PV[Ply][0].Mov)
> mov.Val=VAL_PV; // For ordering (this is the PV move)
> else
> {
> if (mov.Mov==Killers[Ply][0].Mov)
> mov.Val=VAL_KILLER_0; // For ordering (first killer)
> else if (mov.Mov==Killers[Ply][1].Mov)
> mov.Val=VAL_KILLER_1; // For ordering (second killer)
> }
> }
> else // We are not in the PV
> {
> if (mov.Mov==Killers[Ply][0].Mov)
> mov.Val=VAL_KILLER_0;
> else if (mov.Mov==Killers[Ply][1].Mov)
> mov.Val=VAL_KILLER_1;
> }
>
> Jugadas[Numero_Jugadas]=mov; // Add the move to the move list (including "Val"
>for ordering)
>
> UltimaJugada[Ply]=Numero_Jugadas;
> Numero_Jugadas++;
>}
>
> Thanks in advance.
>
> José C.
This looks fine but if you call it once for every move generated you may wish to
inline the function into your move generator.
"EsPV" looks like a global and I don't understand it.
You might not have to do all of this code every place where you add a move in
your move generator. For instance, captures and killers could be exclusive.
bruce
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.