Packagecom.lookbackon.ds
Classpublic class ZobristHashTable
InheritanceZobristHashTable Inheritance HashTable Inheritance Object

See also

http://www.burtleburtle.net/bob/hash/doobs.html
http://chessprogramming.wikispaces.com/Zobrist+Hashing


Public Properties
 PropertyDefined By
 InheritedmaxSize : int
[read-only] The hash table's maximum capacity.
HashTable
 Inheritedsize : int
[read-only] The total number of items.
HashTable
Protected Properties
 PropertyDefined By
 Inherited_size : int
HashTable
 Inherited_table : Array
HashTable
Public Methods
 MethodDefined By
  
ZobristHashTable(size:int, zobristKey:int)
An important issue is the question of what size the hash keys should have.
ZobristHashTable
 Inherited
clear():void
Clears all items.
HashTable
 Inherited
contains(obj:*):Boolean
Determines if the collection contains a given item.
HashTable
  
dump():String
[override] Prints out all elements (for debug/demo purposes).
ZobristHashTable
 Inherited
find(key:*):*
Finds the entry that is associated with the given key.
HashTable
 Inherited
Initializes an iterator object pointing to the first item in the collection.
HashTable
 Inherited
hashInt(i:int):int
[static] A simple function for hashing integers.
HashTable
 Inherited
hashString(s:String):int
[static] A simple function for hashing strings.
HashTable
 Inherited
insert(key:*, obj:*):void
Inserts a key/data couple into the table.
HashTable
 Inherited
isEmpty():Boolean
Checks if the collection is empty.
HashTable
 Inherited
remove(key:*):*
Removes an entry based on a given key.
HashTable
 Inherited
toArray():Array
Converts the collection into an array.
HashTable
 Inherited
toString():String
Prints out a string representing the current object.
HashTable
  
If we now want to get the Zobrist hash code of a certain position, we initialize the hash key bei xoring all random numbers linked to the given feature. E.g the starting position: [Hash for White Rook on a1] xor [White Knight on b1] xor [White Bishop on c1] xor ...
ZobristHashTable
Constructor Detail
ZobristHashTable()Constructor
public function ZobristHashTable(size:int, zobristKey:int)

An important issue is the question of what size the hash keys should have. Smaller hash keys are faster and more space efficient, while larger ones reduce the risk of a hash collision. A collision occurs if two positions map the same key [7] . The dangers of which were well assessed by Robert Hyatt and Anthony Cozzie in their paper Hash Collisions Effect [8] . Usually 64bit are used as a standard size in modern chess programs. But our chinese chess jam using 32bit size.

Parameters
size:int — what size the hash keys should have.
 
zobristKey:int — the zobristed key for hash map.
Method Detail
dump()method
override public function dump():String

Prints out all elements (for debug/demo purposes).

Returns
String — A human-readable representation of the structure.
xor()method 
public function xor(anewTable:ZobristHashTable):ZobristHashTable

Parameters

anewTable:ZobristHashTable — to be xor-ed.

Returns
ZobristHashTable — after xoring anew zobrist hash table.