Upload
njern
View
374
Download
1
Tags:
Embed Size (px)
DESCRIPTION
The slides I used when presenting Monty - my submission for the CodeIt 2013 Ultimate Tic-tac-toe challenge.
Citation preview
Monty & Randy– the dynamic Ultimate Tic Tac Toe duo
Niclas Jern
njern
Co-Founder @ www.walkbase.com
Tools used
The challenge• There are 8 sexdecillion 837 quindecillion 965 quattuordecillion 761
tredecillion 661 duodecillion 276 undecillion 634 decillion 907 nonillion 936 octillion 847 septillion 827 sextillion 420 quintillion 932 quadrillion
210 trillion 688 billion possible ways to play UTTT – If you can express save game in 100 bytes, you have approximately 21 million
billion billion billion truckloads of 16 gig USB sticks with game data
• The AI has limited execution time• You can only upload the code (no training
data)
Solutions #1• Use a Monte Carlo Search Tree (MCST) based
bot (Monty) and his assistant (Randy)– “Stupid” in the beginning, but grows smarter the
further into the game you get (smaller search space)
– Playing against Randy (RandomBot) – wins 100%– Against itself – ties 80%, wins 13%/7%– Improves linearly with execution time
Solutions #2• Pick a language based on speed /
HackerRank execution time.– C/C++ is fast, but only gets two seconds– Python gets 16 seconds, but is quite slow– Java is fast, but warming up the JVM eats into
it’s five seconds.– Golang gets a generous six seconds and is
comparable to C/C++
Solutions #2• Ruthlessly benchmark and optimize:– Slowest function is checking which
moves are available.• With optimization, checking an empty board
(worst case) went from 15000 nanoseconds (initial version) to 4000 nanoseconds (final version) on i7 laptop.
Solutions #3 (not implemented)
• Idea: save successful search trees– Add CBR (Case-based reasoning)– Augment generated search trees with saved
ones for fun & profit– Using real game history would be more realistic
than simulating random games with Randy
Thoughts about “Code it”• A lot of fun–Would love to participate again!– Good mix of algorithmic and more
dynamic challenges.
Thoughts about “Code it”• Good reason to sit down and learn
new algorithms, tools and techniques– The S.W Sloan point-in-poly algorithm
(too slow for Polygon challenge )–MCST (Monty)– Probability mapping (Battleship)
Thank you• And hope to see you again during the
next Code It!