summaryrefslogtreecommitdiff
path: root/src/pawnhash.c
blob: 23c0cb0634ad4d304b9c009591bfbab3977342d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**

Copyright (c) Scott Gasch

Module Name:

    pawnhash.c

Abstract:

    Pawn structure score hashing code.

Author:

    Scott Gasch ([email protected]) 14 Jun 2004

Revision History:

    $Id: pawnhash.c 345 2007-12-02 22:56:42Z scott $

**/

#include "chess.h"


PAWN_HASH_ENTRY *
PawnHashLookup(SEARCHER_THREAD_CONTEXT *ctx) 
/**

Routine description:

    Called by eval with a pointer to a POSITION, look in our pawn hash
    to see if we have an entry that matches the pawn structure in the
    POSITION.  If so, "check out" that entry and return a pointer to
    it.

    Note: a single direct-indexed probe, no multi-probing scheme --
    ctx->rgPawnHash is embedded per-thread inside SEARCHER_THREAD_
    CONTEXT (chess.h), so there's no cross-thread contention to
    avoid here in the first place.

Parameters:

    POSITION *pos

Return value:

    PAWN_HASH_ENTRY *

**/
{
    POSITION *pos = &(ctx->sPosition);
    ULONG u = (ULONG)pos->u64PawnSig & (PAWN_HASH_TABLE_SIZE - 1);
    return(&(ctx->rgPawnHash[u]));
}