Difference between revisions of "Hashing Dictionaries"

From Chessprogramming wiki
Jump to: navigation, search
(Created page with "'''Home * Board Representation * Bitboards * Sliding Piece Attacks * Hashing Dictionaries''' This approach using associate arrays or Hash Table|ha...")
 
Line 1: Line 1:
 
'''[[Main Page|Home]] * [[Board Representation]] * [[Bitboards]] * [[Sliding Piece Attacks]] * Hashing Dictionaries'''
 
'''[[Main Page|Home]] * [[Board Representation]] * [[Bitboards]] * [[Sliding Piece Attacks]] * Hashing Dictionaries'''
  
This approach using associate arrays or [[Hash Table|hash tables]] was introduced in the [[ICGA Journal]] (June 2007) by [[Sam Tannous]] <ref>[[Sam Tannous]] ('''2007'''). ''[http://arxiv.org/abs/0704.3773 Avoiding Rotated Bitboards with Direct Lookup]''. [[ICGA Journal#30_2|ICGA Journal, Vol. 30, No. 2]], [http://arxiv.org/PS_cache/arxiv/pdf/0704/0704.3773v2.pdf pdf]</ref>. Like other [[Occupancy|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]]:
+
This approach using associate arrays or [[Hash Table|hash tables]] was introduced in the [[ICGA Journal]] (June 2007) by [[Sam Tannous]] <ref name="ICGAJ">[[Sam Tannous]] ('''2007'''). ''Avoiding Rotated Bitboards with Direct Lookup''. [[ICGA Journal#30_2|ICGA Journal, Vol. 30, No. 2]], [https://arxiv.org/abs/0704.3773 arXiv:0704.3773]
 +
</ref>. Like other [[Occupancy|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 <ref>[[Donald Knuth]] ('''1998'''). ''The Art of Computer Programming''. Volume 3, Sorting and Searching. Addison Wesley. ISBN 0201896850</ref>.  
 
  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 <ref>[[Donald Knuth]] ('''1998'''). ''The Art of Computer Programming''. Volume 3, Sorting and Searching. Addison Wesley. ISBN 0201896850</ref>.  
  
Line 7: Line 8:
 
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 Bitboards|rotated]] or [[Hash Table#PerfectHashing|perfect hashing]] techniques like [[Kindergarten Bitboards|Kindergarten]] or even [[Magic Bitboards]].
 
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 Bitboards|rotated]] or [[Hash Table#PerfectHashing|perfect hashing]] techniques like [[Kindergarten Bitboards|Kindergarten]] or even [[Magic Bitboards]].
  
=Abstract=
+
==Abstract==
Quoted from ''Avoiding Rotated Bitboards with Direct Lookup'':  
+
Quoted from ''Avoiding Rotated Bitboards with Direct Lookup'' <ref name="ICGAJ"/>:  
 
  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 Table|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.  
 
  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 Table|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=  
+
==Toolkit==
* [http://docs.python.org/lib/module-UserDict.html UserDict - Class wrapper for dictionary objects] from [http://docs.python.org/lib/lib.html Python Library Reference]
+
* [[Shatranj (Toolkit)]]
* [http://docs.python.org/lib/defaultdict-objects.html defaultdict objects] from [http://docs.python.org/lib/lib.html Python Library Reference]
 
  
 
=References=  
 
=References=  
 
<references />
 
<references />
 
 
'''[[Sliding Piece Attacks|Up one Level]]'''
 
'''[[Sliding Piece Attacks|Up one Level]]'''

Revision as of 16:25, 27 June 2021

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.

Abstract

Quoted from Avoiding Rotated Bitboards with Direct Lookup [1]:

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. 

Toolkit

References

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

Up one Level