Subversion Repositories Games.Chess Giants

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.     Protector -- a UCI chess engine
  3.  
  4.     Copyright (C) 2009-2010 Raimund Heid (Raimund_Heid@yahoo.com)
  5.  
  6.     This program is free software: you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation, either version 3 of the License, or
  9.     (at your option) any later version.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  
  19. */
  20.  
  21. #ifndef _hash_h_
  22. #define _hash_h_
  23.  
  24. #include "protector.h"
  25. #include "position.h"
  26.  
  27. /**
  28.  * Define the size of the specified hashtable.
  29.  *
  30.  * @param size the size of the hashtable in bytes
  31.  */
  32. void setHashtableSize(Hashtable * hashtable, UINT64 size);
  33.  
  34. /**
  35.  * Initialize the specified hashtable. Call this function exactly once
  36.  * for every hashtable before using it.
  37.  */
  38. void initializeHashtable(Hashtable * hashtable);
  39.  
  40. /**
  41.  * Reset the specified hashtable. Call this function in order to
  42.  * erase all stored data.
  43.  */
  44. void resetHashtable(Hashtable * hashtable);
  45.  
  46. /**
  47.  * Increment the date of the specified hashtable.
  48.  */
  49. void incrementDate(Hashtable * hashtable);
  50.  
  51. /**
  52.  * Construct a hashentry from the given values.
  53.  */
  54. Hashentry constructHashEntry(UINT64 key, INT16 value, INT16 staticValue,
  55.                              UINT8 importance, UINT16 bestMove, UINT8 date,
  56.                              UINT8 flag);
  57.  
  58. /**
  59.  * Put the specified entry into the hashtable.
  60.  */
  61. void setHashentry(Hashtable * hashtable, UINT64 key, INT16 value,
  62.                   UINT8 importance, UINT16 bestMove, UINT8 flag,
  63.                   INT16 staticValue);
  64.  
  65. /**
  66.  * Get the entry specified by key.
  67.  */
  68. Hashentry *getHashentry(Hashtable * hashtable, UINT64 key);
  69.  
  70. INT16 getHashentryValue(const Hashentry * entry);
  71. UINT8 getHashentryImportance(const Hashentry * entry);
  72. UINT16 getHashentryMove(const Hashentry * entry);
  73. UINT8 getHashentryDate(const Hashentry * entry);
  74. UINT8 getHashentryFlag(const Hashentry * entry);
  75. UINT64 getHashentryKey(const Hashentry * entry);
  76. INT16 getHashentryStaticValue(const Hashentry * entry);
  77. bool nodeIsInUse(UINT64 key, UINT8 depth);
  78. bool setNodeUsage(UINT64 key, UINT8 depth);
  79. void resetNodeUsage(UINT64 key, UINT8 depth);
  80.  
  81. /**
  82.  * Initialize this module.
  83.  *
  84.  * @return 0 if no errors occurred.
  85.  */
  86. int initializeModuleHash(void);
  87.  
  88. /**
  89.  * Test this module.
  90.  *
  91.  * @return 0 if all tests succeed.
  92.  */
  93. int testModuleHash(void);
  94.  
  95. #endif
  96.