Changes

Jump to: navigation, search

Persistent Hash Table

12,177 bytes added, 08:56, 19 May 2018
Created page with "'''Home * Learning * Persistent Hash Table''' FILE:DisintegrationofPersistence.jpg|border|right|thumb|link=https://en.wikipedia.org/wiki/The_Disintegratio..."
'''[[Main Page|Home]] * [[Learning]] * Persistent Hash Table'''

[[FILE:DisintegrationofPersistence.jpg|border|right|thumb|link=https://en.wikipedia.org/wiki/The_Disintegration_of_the_Persistence_of_Memory| [https://en.wikipedia.org/wiki/The_Disintegration_of_the_Persistence_of_Memory The Disintegration of the Persistence of Memory] <ref>[[Arts#Dali|Salvador Dalí]], [https://en.wikipedia.org/wiki/The_Disintegration_of_the_Persistence_of_Memory The Disintegration of the Persistence of Memory from Wikipedia], 1952-1954</ref> ]]

'''Persistent Hash Table''', ([https://en.wikipedia.org/wiki/Persistence_%28computer_science%29 persistent] [[Transposition Table|transposition table]])<br/>
a form of long-term [[Memory|memory]], to remember "important" nodes from earlier analyzed [[Chess Position|positions]] or played [[Chess Game|games]] with its [[Exact Score|exact score]] and [[Depth|depth]], in order to avoid repeating unsuccessful book lines. So called [https://en.wikipedia.org/wiki/Persistence_%28computer_science%29#Orthogonal_or_transparent_persistence orthogonal or transparent] persistent hash tables preserve their contents with focus on [[Node Types#PV|PV-nodes]] between moves while playing a game, between games, and even during interactive analysis while playing variations forward and backward <ref>[http://www.talkchess.com/forum/viewtopic.php?t=64517&start=2 Re: My "official" request to top engine programmers] by [[Harm Geert Muller]], [[CCC]], July 05, 2017</ref>. '''Non-orthogonal''' persistence, primary topic of this page, requires data to be written or read to or from storage devices using specific instructions in a program and have to provide mappings from or to the native data structures to or from the storage device data structures.

Inspired by the [https://en.wikipedia.org/wiki/Rote_learning rote learning] as used in [[Arthur Samuel|Arthur Samuel's]] [[Checkers]] program from 1959 <ref>[[Arthur Samuel]] ('''1959'''). ''[http://domino.watson.ibm.com/tchjr/journalindex.nsf/600cc5649e2871db852568150060213c/39a870213169f45685256bfa00683d74%21OpenDocument Some Studies in Machine Learning Using the Game of Checkers]''. IBM Journal July 1959</ref> <ref>[[Arthur Samuel]] ('''1967'''). ''Some Studies in Machine Learning. Using the Game of Checkers. II-Recent Progress''. [http://pages.cs.wisc.edu/%7Edyer/cs540/handouts/samuel-checkers.pdf pdf]</ref>, [[David Slate]] first described a persistent transposition table in computer chess for accumulating selected information from many games and then utilizing it subsequently via the transposition table <ref>[[David Slate]] ('''1987'''). ''A Chess Program that uses its Transposition Table to Learn from Experience.'' [[ICGA Journal#10_2|ICCA Journal, Vol. 10, No. 2]]</ref>. In his article, Slate mentions personal communication with [[Tony Scherzer]] and [[Tony Warnock]] regarding learning in [[Bebe]] and [[Lachex]].

=Learning in Mouse=
Slate's simple [[Brute-Force|brute-force]] program ''Mouse'', a [[Depth-First|depth-first]], full-width [[Iterative Deepening|iterated]] [[Alpha-Beta|alpha-beta]] searcher with an [[Evaluation|evaluation]] purely based on [[Material|material]] was used as a learning [https://en.wikipedia.org/wiki/Testbed testbed], only remembering positions where a significant [[Score|score]] drop occurred at the root.

==Transposition Table==
A relative small [[Transposition Table|transposition table]] of 4096 buckets (8192 entries) was used for the examples in his paper:
<pre>
6 bytes Hash code
2x2 bytes Score window
2 bytes Best Move, if any
10 bits Game ply
6 bits Ply from root node
1 byte Search height
1 byte Origin indication
</pre>

''Score window'' holds the current [[Lower Bound|lower]] and [[Upper Bound|upper bounds]]. Although some programs use only a single value and a flag for ''good, lower or upper bound'', there are occasions and algorithms <ref>[[David Slate]] ('''1984'''). ''Interior-node Score Bounds in a Brute-force Chess Program.'' [[ICGA Journal#7_4|ICCA Journal, Vol. 7, No. 4]]</ref> that fix the score between unequal bounds neither of which is infinite.

''Origin indication'' holds the explanation of the origin for the entry. There are values for ''current search, human advice, learned in previous session,'' etc.

==Algorithm==
The basic learning [[Algorithms|algorithm]] stores root entries to disk, if the final score of the chosen move is significantly worse than the best score in any of the previous iterations. Between searches during the playing session, relevant portions of the retained entries were loaded into their slots in the TT-table, adjusting bounds by a fuzz term, and to flag their origin to secure them from being indiscriminately overwritten.
<span id="LearninginBebe"></span>
=Learning in Bebe=
[[Tony Scherzer|Tony]] and [[Linda Scherzer]], and [[Dean Tjaden]] further elaborate on the persistent hash table in their [[BeBe#Award|award winning paper]] <ref>[[Tony Scherzer]], [[Linda Scherzer]], [[Dean Tjaden]] ('''1990'''). ''Learning in Bebe.'' [[Computers, Chess, and Cognition]] » [[BeBe#Award|Mephisto Best-Publication Award]]</ref> concerning [[Learning]] in [[BeBe]]:

==Short Term Memory==
The short term memory (STM) or [[Transposition Table|transposition table]] slot consists of 16 bytes, of which 12 are stored, and 4 bytes are implicit as a memory address. [[Upper Bound|Upper]] and [[Lower Bound|lower limit]] of the score are needed for the easiest implementation of the learning algorithm:
<pre>
4 bytes Hash code used as STM memory address
4 bytes Hash code used for match verification
2 bytes Search height
2 bytes Position-score lower limit
2 bytes Position-score upper limit
2 bytes The move
</pre>

==Long Term Memory==
The long term memory (LTM) entries are stored on disk and therefor retained between games. The structure is similar, however all 16 bytes were stored:
<pre>
4 bytes Hash code used as STM memory address
4 bytes Hash code used for match verification
2 bytes Depth of search
2 bytes Move number
2 bytes Position-score
2 bytes The move
</pre>
One LTM entry is created for each root node during the game.

==Algorithm==
The algorithm consists of two phases. One creates (or overwrites) the LTM entries at the end of each search considering a [[Contempt Factor|contempt factor]], while the second transforms and copies LTM entries to STM at the start of each search:
<pre>
Position-score lower limit = Position-score - fuzzy tolerance (up to 0.2 pawn units for none draw or mate scores)
Position-score upper limit = Position-score + fuzzy tolerance
</pre>

=Position Learning in Crafty=
Quote from ''[[Crafty]] Command Documentation'' (version 18) by [[Robert Hyatt]] <ref>[http://www.cis.uab.edu/hyatt/craftydoc.html Crafty Command Documentation (version 18)] - What is this new Position Learning I've heard about?</ref>:

'''What is this new Position Learning I've heard about?'''

Crafty now has a "permanent" hash table that is kept from game to game. A position gets into this "hash file" when Crafty executes a search and the search value is significantly lower than the last search value.

When this happens, Crafty stores the current information for this position in the permanent hash file, which can hold up to 65536 positions. Once it fills up, the positions are replaced on a FIFO basis, always keeping the most recent 64K entries.

Each time Crafty starts a search, the positions/scores from this file are stuffed into the normal transposition table, and used during the search just like any other table entry...

=See also=
* [[Book Learning]]
* [[Hash Table]]
* [[Memory]]
* [[Transposition Table]]

=Selected Publications=
* [[Arthur Samuel]] ('''1959'''). ''[http://domino.watson.ibm.com/tchjr/journalindex.nsf/600cc5649e2871db852568150060213c/39a870213169f45685256bfa00683d74!OpenDocument Some Studies in Machine Learning Using the Game of Checkers]''. IBM Journal July 1959
* [[Arthur Samuel]] ('''1967'''). ''Some Studies in Machine Learning. Using the Game of Checkers. II-Recent Progress''. [http://pages.cs.wisc.edu/~dyer/cs540/handouts/samuel-checkers.pdf pdf]
* [[David Slate]] ('''1987'''). ''A Chess Program that uses its Transposition Table to Learn from Experience.'' [[ICGA Journal#10_2|ICCA Journal, Vol. 10, No. 2]]
* [[Tony Scherzer]], [[Linda Scherzer]], [[Dean Tjaden]] ('''1990'''). ''Learning in Bebe.'' [[Computers, Chess, and Cognition]] » [[BeBe#Award|Mephisto Best-Publication Award]]
* [[Tony Scherzer]], [[Linda Scherzer]], [[Dean Tjaden]] ('''1991'''). ''Learning in Bebe.'' [[ICGA Journal#14_4|ICCA Journal, Vol. 14, No. 4]]

=Forum Posts=
==1990 ...==
* [https://groups.google.com/d/msg/rec.games.chess/wkTUUFfEvIE/RyFnJTjyQq4J Machine Learning Experience] by [[Michael Valvo|Mike Valvo]], [[Computer Chess Forums|rgc]], January 22, 1990 » [[Persistent Hash Table#LearninginBebe|Learning in Bebe]]
==2000 ...==
* [https://www.stmintz.com/ccc/index.php?id=150687 Simple Learning Technique and Random Play] by [[Miguel A. Ballicora]], [[CCC]], January 18, 2001 » [[Search with Random Leaf Values]]
* [https://www.stmintz.com/ccc/index.php?id=484765 Re: Rybka 1.01 Beta14 - persistent hash table] by [[Vasik Rajlich]], [[CCC]], February 06, 2006
* [http://www.open-aurec.com/wbforum/viewtopic.php?f=4&t=5293&p=26451#p26434 Re: Idea for opening book] by [[Mark Lefler]], [[Computer Chess Forums|Winboard Forum]], August 02, 2006
* [http://www.talkchess.com/forum/viewtopic.php?topic_view=threads&p=128388&t=14831 Re: Ed Does it Again! (and a question for Ed)] by [[Michael Sherwin]], [[CCC]], July 03, 2007
* [http://www.talkchess.com/forum/viewtopic.php?t=21754 A simple book learning method] by [[Alvaro Cardoso]], [[CCC]], June 12, 2008 » [[Book Learning]]
* [http://www.talkchess.com/forum/viewtopic.php?t=22546 Persistent Hash] by [http://www.talkchess.com/forum/profile.php?mode=viewprofile&u=608 Ted Summers], [[CCC]], July 24, 2008
==2010 ...==
* [http://www.talkchess.com/forum/viewtopic.php?t=62639 Cumulative building of a shared search tree] by [[Bojun Guo]], [[CCC]], December 28, 2016 » [[Chinese Chess]], [[Opening Book]]
* [http://www.talkchess.com/forum/viewtopic.php?t=64517 My "official" request to top engine programmers] by [[Rodolfo Leoni]], [[CCC]], July 04, 2017
: [http://www.talkchess.com/forum/viewtopic.php?t=64517&start=2 Re: My "official" request to top engine programmers] by [[Harm Geert Muller]], [[CCC]], July 05, 2017
* [http://www.talkchess.com/forum/viewtopic.php?t=64522 Improving hash replacing schema for analysis mode] by [[Daniel José Queraltó]], [[CCC]], July 05, 2017 » [[Transposition Table#ReplacementStrategies|Replacement Strategy]]
* [http://www.talkchess.com/forum/viewtopic.php?t=64557 Andscacs new PH feature: first impressions] by [[Rodolfo Leoni]], [[CCC]], July 08, 2017 » [[Andscacs]]
* [http://www.talkchess.com/forum/viewtopic.php?t=64720 Stockfish version with hash saving capability] by [[Daniel José Queraltó]], [[CCC]], July 25, 2017 » [[Stockfish]]
* [http://www.talkchess.com/forum/viewtopic.php?t=64759 Will you use hash saving?] by [[Daniel José Queraltó]], [[CCC]], July 30, 2017
* [http://www.talkchess.com/forum/viewtopic.php?t=65914 Persistent hashes - performance] by [[Rodolfo Leoni]], [[CCC]], December 06, 2017

=External Links=
* [http://www.cis.uab.edu/hyatt/craftydoc.html Crafty Command Documentation (version 18)] - What is this new Position Learning I've heard about?
* [http://www.rybkachess.com/index.php?auswahl=Persistent+hash Rybka 3 Persistent Hash] from [http://www.rybkachess.com/index.php Rybka - for the serious chess player]
* [http://www.developer.com/java/ent/article.php/600531/The-Persistent-Hashtable-A-Quick-and-Dirty-Database.htm The Persistent Hashtable: A Quick-and-Dirty Database] by [http://www.developer.com/author.php/5023/Greg-Travis.htm Greg Travis], [http://www.developer.com/ Developer.com]
* [https://en.wikipedia.org/wiki/Persistence_%28computer_science%29 Persistence (computer science) from Wikipedia]
* [https://en.wikipedia.org/wiki/Rote_learning Rote learning from Wikipedia]

=References=
<references />

'''[[Learning|Up one Level]]'''

Navigation menu