GODPAPER | All Packages | All Classes | Index | Frames No Frames |
ZobristHashTable

Package | com.lookbackon.ds
Class | public class ZobristHashTable
Inheritance | ZobristHashTable HashTable Object

See also

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

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | maxSize : int [read-only] The hash table's maximum capacity. | HashTable
|  | size : int [read-only] The total number of items. | HashTable

Protected Properties
Hide Inherited Protected Properties
Show Inherited Protected Properties

| Property | Defined By
--- | --- | ---
|  | _size : int | HashTable
|  | _table : Array | HashTable

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | ZobristHashTable(size:int, zobristKey:int) An important issue is the question of what size the hash keys should have. | ZobristHashTable
|  | clear():void Clears all items. | HashTable
|  | contains(obj:*):Boolean Determines if the collection contains a given item. | HashTable
|  | dump():String [override] Prints out all elements (for debug/demo purposes). | ZobristHashTable
|  | find(key:*):* Finds the entry that is associated with the given key. | HashTable
|  | getIterator():Iterator Initializes an iterator object pointing to the first item in the collection. | HashTable
|  | hashInt(i:int):int [static] A simple function for hashing integers. | HashTable
|  | hashString(s:String):int [static] A simple function for hashing strings. | HashTable
|  | insert(key:*, obj:*):void Inserts a key/data couple into the table. | HashTable
|  | isEmpty():Boolean Checks if the collection is empty. | HashTable
|  | remove(key:*):* Removes an entry based on a given key. | HashTable
|  | toArray():Array Converts the collection into an array. | HashTable
|  | toString():String Prints out a string representing the current object. | HashTable
|  | xor(anewTable:ZobristHashTable):ZobristHashTable 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.

Thu Jan 16 2014, 01:11 PM +08:00