Author: José Carlos
Date: 05:29:09 12/28/99
Go up one level in this thread
On December 27, 1999 at 13:06:21, Bruce Moreland wrote:
>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.
>
Do you mean using the _forceinline command or handly copy and paste the code
everywhere I use it. I've tried the _forceinline, but does not seem to be faster
(maybe the speed optimization of the compiler does this automatically).
>"EsPV" looks like a global and I don't understand it.
I don't store moves in the hash table yet, so I know the best move only in the
PV. This is why I tell the move generator "we are in the PV", so if the move is
the same, I give a value to it that puts it the first on the list.
The reason why I don't store moves in the hash table yet is that I haven't had
time to think "how do I know what move to store and when?". I might be trivial,
perhaps, but I need to think about 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.
I'm sure I don't do it in the best way. Let's see: for each move I generate (I
do it handly, don't have bitboards or something) I give it a value I use later
for sorting the moves. This value depends of if it is a capture (I got values
defined depending of piece captured and piece capturing) or castling or
promoting or a simple piece move. For each move, I look into the corresponding
piece eval table, and use the value assigned to that square.
For example: if I move a knight to a1, the value assigned is:
KNGHT_MOVE + Knight[SQA1]
If there was a rook in a1, then it would be added Capture[KNIGHT,ROOK] instead
of KNIGHT_MOVE.
That is when generating moves. When adding, I check if the move is a killer or
the PV (I try killers before captures).
>bruce
José C.
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.