Hashing Dictionaries

From Chessprogramming wiki
Jump to: navigation, search

Home * Board Representation * Bitboards * Sliding Piece Attacks * Hashing Dictionaries

This approach using associate arrays or hash tables was introduced in the ICGA Journal (June 2007) by Sam Tannous [1]. Like other occupancy lookup approaches it works line-wise for ranks, files, diagonals and anti-diagonals. It uses hash arrays from an interpreted, high level language, Python:

Many high level programming languages (notably Python (van Rossum, 1993)) have useful predefined data structures (e.g. associative arrays) which are dynamically resizable hash tables that resolve collisions by probing techniques. The basic lookup function used in Python is based on Algorithm D: Open Addressing with Double Hashing from Section 6.4 in Knuth [2]. 

Avoiding Rotated Bitboards with Direct Lookup

Sam Tannous compared this approach to a Rotated Bitboards implementation in Python and found direct lookup favorable for move generation. In languages like C, targeting 64-bit cpus like x86-64, or even in Java, it is likely another story if one compares Open Addressing with Double Hashing with rotated or perfect hashing techniques like Kindergarten or even Magic Bitboards.


Quoted from Avoiding Rotated Bitboards with Direct Lookup:

This paper describes an approach for obtaining direct access to the attacked squares of sliding pieces without resorting to rotated bitboards. The technique involves creating four hash tables using the built in hash arrays from an interpreted, high level language. The rank, file, and diagonal occupancy are first isolated by masking the desired portion of the board. The attacked squares are then directly retrieved from the hash tables. Maintaining incrementally updated rotated bitboards becomes unnecessary as does all the updating, mapping and shifting required to access the attacked squares. Finally, rotated bitboard move generation speed is compared with that of the direct hash table lookup method. 

External Links


  1. Sam Tannous (2007). Avoiding Rotated Bitboards with Direct Lookup. ICGA Journal, Vol. 30, No. 2, pdf
  2. Donald Knuth (1998). The Art of Computer Programming. Volume 3, Sorting and Searching. Addison Wesley. ISBN 0201896850

Up one Level