SlideShare a Scribd company logo
1 of 17
Download to read offline
Go, Kotlin Go!
Go is an abstract strategy board game for
two players, in which the aim is to surround
more territory than the opponent.
The game was invented in ancient China more
than 2,500 years ago and is believed to be
the oldest board game continuously played
today.
The game reached Japan in the 7th century CE
—where it is called go ( 碁 ) or igo ( 囲碁 ).
The modern version of the game as we know it
today was formalized in Japan in the 15th
century.
AlphaGo Zero
Rules
At the beginning of the game, the
board is empty.
One player takes the black
stones, the other player the
white ones.
The player with the black stones
makes the first move.
A move is made by placing a stone
on an interesection.
A player can play on any
unoccupied intersection he wants
to.
A stone does not move after being
played, unless it is captured and
taken off the board.
The previous board position
cannot be recreated.
Eyes and false eyes
There is no special rule for life and death of
groups, they just emerge from capture rule.
How cool is that?
Diagrams from https://senseis.xmp.net/
Computer Go
Nice client
https://sabaki.yichuanshen.de/
Strongest Open Source Go program
http://pachi.or.cz/
DeepLearning Open Source
https://github.com/gcp/leela-zero
Strongest commercial Go program
https://www.remi-coulom.fr/CrazyStone/
Old generation Open Source
https://www.gnu.org/software/gnugo/
Deep Learning and the Game of Go opens
up the world of deep learning and AI by
teaching you to build your own Go-
playing machine. You'll explore key deep
learning ideas like neural networks and
reinforcement learning and maybe even
step up your Go game a notch or two. AI
experts and Go enthusiasts Max Pumperla
and Kevin Ferguson take you every step
of the way as you build your Go bot and
train it from eternal loser to hardened
Go player.
https://github.com/uberto/kakomu
I think that this Python code
would look better in Kotlin...
KAKOMU ( 囲む )
https://github.com/uberto/kakomu
In Japanese it means “to surround” and the
ideogram is the same that in the game of Go
First commit 2nd Jan 2018
42 classes and about 700 loc (excluding tests)
It’s able to play at a intermediate level on a
9x9 board
Next big feature will be DeepLearning support
Lessons Learned
●
Don’t fear the ?
●
Avoid !! at any cost
●
Immutability is nice but…
●
Algebraic Data Types to
avoid if
●
Premature Optimization
is...
●
Kotlin is awesome!
How to capture?
Stone: each position on the board can be empty|white|black
String: a set of stones which are in contact
Liberties: the empty positions touched by a string
Group: a group of strings that “work together”. Computer
don’t care about it.
Look at code Board.placeStone()
How to decide who won?
A B C D E F G H J
9 . x x x o . o . o 9
8 x x x o o o o o . 8
7 . x x x o o . o o 7
6 x x x o o o o . o 6
5 . x x x x x o o o 5
4 x x x x x o o o . 4
3 x . x . x x o o o 3
2 x x . x x x x x o 2
1 x . x x . x o o o 1
A B C D E F G H J
Final score black: 45 white: 36
Minimax
Minimax algorithm with
alternate moves. A minimax
algorithm is a recursive
algorithm for choosing the
next move in an n-player
game, usually a two-player
game. A value is associated
with each position or state
of the game.
AlphaBeta pruning
The benefit of alpha–beta
pruning lies in the fact that
branches of the search tree can
be eliminated. This way, the
search time can be limited to
the 'more promising' subtree,
and a deeper search can be
performed in the same time.
The optimization reduces the
effective depth to slightly more
than half that of simple minimax
if the nodes are evaluated in an
optimal or near optimal order
(best choice for side on move
ordered first at each node).
Monte Carlo Tree Search
The focus of Monte Carlo tree search is on the analysis of the most
promising moves, expanding the search tree based on random sampling
of the search space. The application of Monte Carlo tree search in
games is based on many playouts. In each playout, the game is played
out to the very end by selecting moves at random. The final game
result of each playout is then used to weight the nodes in the game
tree so that better nodes are more likely to be chosen in future
playouts.
Performance
Timings for a complete rollout from start single thread
on my laptop i7 2Ghz (in millisec on 9x9 and 19x19)
10 160 validmove without deepcopy
6 65 immutable goStrings
3.5 38 neighbors map
1.5 31 faster isAnEye
1.3 27 simpleKo
1.25 25 selectMove returning State
0.7 12 remove System.nanotime
0.5 4.5 RandomBot evaluating single move
0.33 2.4 single swap instead of shuffle
0.27 2.1 array instead of map for winCount
`
Next step

More Related Content

Similar to Go kotlin, Go!

MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME ijscai
 
Monte carlo tree search for the
Monte carlo tree search for theMonte carlo tree search for the
Monte carlo tree search for theijscai
 
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME ijscai
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial IntelligenceAltafur Rahman
 
research for game dave
 research for game dave  research for game dave
research for game dave DanMorland
 
Learning to Play Complex Games
Learning to Play Complex GamesLearning to Play Complex Games
Learning to Play Complex Gamesbutest
 
0-miniproject sem 4 review 1(1)(2).pptx
0-miniproject sem 4 review 1(1)(2).pptx0-miniproject sem 4 review 1(1)(2).pptx
0-miniproject sem 4 review 1(1)(2).pptxAhishektttPhm
 
Adversarial search
Adversarial searchAdversarial search
Adversarial searchDheerendra k
 
Topic - 6 (Game Playing).ppt
Topic - 6 (Game Playing).pptTopic - 6 (Game Playing).ppt
Topic - 6 (Game Playing).pptSabrinaShanta2
 
Endless vision gdd_revised_1214
Endless vision gdd_revised_1214Endless vision gdd_revised_1214
Endless vision gdd_revised_1214Lisa Lee
 
International journal of engineering issues vol 2015 - no 2 - paper1
International journal of engineering issues   vol 2015 - no 2 - paper1International journal of engineering issues   vol 2015 - no 2 - paper1
International journal of engineering issues vol 2015 - no 2 - paper1sophiabelthome
 
2. initial plans
2. initial plans2. initial plans
2. initial plansJackScott54
 
TornadoBrickSmasherUserManual
TornadoBrickSmasherUserManualTornadoBrickSmasherUserManual
TornadoBrickSmasherUserManualClayton Schembri
 
Space Brawl Game Design Document
Space Brawl Game Design DocumentSpace Brawl Game Design Document
Space Brawl Game Design Documentryanhorbal
 
Game Playing In A I Final
Game  Playing In  A I  FinalGame  Playing In  A I  Final
Game Playing In A I FinalNeelamani Samal
 

Similar to Go kotlin, Go! (20)

MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
 
Monte carlo tree search for the
Monte carlo tree search for theMonte carlo tree search for the
Monte carlo tree search for the
 
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
 
OthelloFinal.pptx
OthelloFinal.pptxOthelloFinal.pptx
OthelloFinal.pptx
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
research for game dave
 research for game dave  research for game dave
research for game dave
 
Learning to Play Complex Games
Learning to Play Complex GamesLearning to Play Complex Games
Learning to Play Complex Games
 
0-miniproject sem 4 review 1(1)(2).pptx
0-miniproject sem 4 review 1(1)(2).pptx0-miniproject sem 4 review 1(1)(2).pptx
0-miniproject sem 4 review 1(1)(2).pptx
 
3. research
3. research3. research
3. research
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 
Topic - 6 (Game Playing).ppt
Topic - 6 (Game Playing).pptTopic - 6 (Game Playing).ppt
Topic - 6 (Game Playing).ppt
 
quarto
quartoquarto
quarto
 
Endless vision gdd_revised_1214
Endless vision gdd_revised_1214Endless vision gdd_revised_1214
Endless vision gdd_revised_1214
 
International journal of engineering issues vol 2015 - no 2 - paper1
International journal of engineering issues   vol 2015 - no 2 - paper1International journal of engineering issues   vol 2015 - no 2 - paper1
International journal of engineering issues vol 2015 - no 2 - paper1
 
2. initial plans
2. initial plans2. initial plans
2. initial plans
 
TornadoBrickSmasherUserManual
TornadoBrickSmasherUserManualTornadoBrickSmasherUserManual
TornadoBrickSmasherUserManual
 
Space Brawl Game Design Document
Space Brawl Game Design DocumentSpace Brawl Game Design Document
Space Brawl Game Design Document
 
Dave
DaveDave
Dave
 
Game Playing In A I Final
Game  Playing In  A I  FinalGame  Playing In  A I  Final
Game Playing In A I Final
 
Games.4
Games.4Games.4
Games.4
 

More from Uberto Barbini

CQRS with Event Source in Functional sauce served by Kotlin
CQRS with Event Source in Functional sauce served by Kotlin CQRS with Event Source in Functional sauce served by Kotlin
CQRS with Event Source in Functional sauce served by Kotlin Uberto Barbini
 
It's All About Morphisms
It's All About MorphismsIt's All About Morphisms
It's All About MorphismsUberto Barbini
 
The Role of Testing in DevOps
The Role of Testing in DevOpsThe Role of Testing in DevOps
The Role of Testing in DevOpsUberto Barbini
 
When Tdd Goes Awry (IAD 2013)
When Tdd Goes Awry (IAD 2013)When Tdd Goes Awry (IAD 2013)
When Tdd Goes Awry (IAD 2013)Uberto Barbini
 
Boost your-oop-with-fp
Boost your-oop-with-fpBoost your-oop-with-fp
Boost your-oop-with-fpUberto Barbini
 
Develop Gwt application in TDD
Develop Gwt application in TDDDevelop Gwt application in TDD
Develop Gwt application in TDDUberto Barbini
 

More from Uberto Barbini (9)

CQRS with Event Source in Functional sauce served by Kotlin
CQRS with Event Source in Functional sauce served by Kotlin CQRS with Event Source in Functional sauce served by Kotlin
CQRS with Event Source in Functional sauce served by Kotlin
 
It's All About Morphisms
It's All About MorphismsIt's All About Morphisms
It's All About Morphisms
 
Legacy is Good
Legacy is GoodLegacy is Good
Legacy is Good
 
The Role of Testing in DevOps
The Role of Testing in DevOpsThe Role of Testing in DevOps
The Role of Testing in DevOps
 
When Tdd Goes Awry (IAD 2013)
When Tdd Goes Awry (IAD 2013)When Tdd Goes Awry (IAD 2013)
When Tdd Goes Awry (IAD 2013)
 
When Tdd Goes Awry
When Tdd Goes AwryWhen Tdd Goes Awry
When Tdd Goes Awry
 
Boost your-oop-with-fp
Boost your-oop-with-fpBoost your-oop-with-fp
Boost your-oop-with-fp
 
The Effective Team
The Effective TeamThe Effective Team
The Effective Team
 
Develop Gwt application in TDD
Develop Gwt application in TDDDevelop Gwt application in TDD
Develop Gwt application in TDD
 

Recently uploaded

Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfadriantubila
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxolyaivanovalion
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightDelhi Call girls
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...Pooja Nehwal
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...shivangimorya083
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 

Recently uploaded (20)

Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptx
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 

Go kotlin, Go!

  • 1. Go, Kotlin Go! Go is an abstract strategy board game for two players, in which the aim is to surround more territory than the opponent. The game was invented in ancient China more than 2,500 years ago and is believed to be the oldest board game continuously played today. The game reached Japan in the 7th century CE —where it is called go ( 碁 ) or igo ( 囲碁 ). The modern version of the game as we know it today was formalized in Japan in the 15th century.
  • 2.
  • 4. Rules At the beginning of the game, the board is empty. One player takes the black stones, the other player the white ones. The player with the black stones makes the first move. A move is made by placing a stone on an interesection. A player can play on any unoccupied intersection he wants to. A stone does not move after being played, unless it is captured and taken off the board. The previous board position cannot be recreated.
  • 5. Eyes and false eyes There is no special rule for life and death of groups, they just emerge from capture rule. How cool is that? Diagrams from https://senseis.xmp.net/
  • 6. Computer Go Nice client https://sabaki.yichuanshen.de/ Strongest Open Source Go program http://pachi.or.cz/ DeepLearning Open Source https://github.com/gcp/leela-zero Strongest commercial Go program https://www.remi-coulom.fr/CrazyStone/ Old generation Open Source https://www.gnu.org/software/gnugo/
  • 7. Deep Learning and the Game of Go opens up the world of deep learning and AI by teaching you to build your own Go- playing machine. You'll explore key deep learning ideas like neural networks and reinforcement learning and maybe even step up your Go game a notch or two. AI experts and Go enthusiasts Max Pumperla and Kevin Ferguson take you every step of the way as you build your Go bot and train it from eternal loser to hardened Go player. https://github.com/uberto/kakomu I think that this Python code would look better in Kotlin...
  • 8. KAKOMU ( 囲む ) https://github.com/uberto/kakomu In Japanese it means “to surround” and the ideogram is the same that in the game of Go First commit 2nd Jan 2018 42 classes and about 700 loc (excluding tests) It’s able to play at a intermediate level on a 9x9 board Next big feature will be DeepLearning support
  • 9. Lessons Learned ● Don’t fear the ? ● Avoid !! at any cost ● Immutability is nice but… ● Algebraic Data Types to avoid if ● Premature Optimization is... ● Kotlin is awesome!
  • 10. How to capture? Stone: each position on the board can be empty|white|black String: a set of stones which are in contact Liberties: the empty positions touched by a string Group: a group of strings that “work together”. Computer don’t care about it. Look at code Board.placeStone()
  • 11.
  • 12. How to decide who won? A B C D E F G H J 9 . x x x o . o . o 9 8 x x x o o o o o . 8 7 . x x x o o . o o 7 6 x x x o o o o . o 6 5 . x x x x x o o o 5 4 x x x x x o o o . 4 3 x . x . x x o o o 3 2 x x . x x x x x o 2 1 x . x x . x o o o 1 A B C D E F G H J Final score black: 45 white: 36
  • 13. Minimax Minimax algorithm with alternate moves. A minimax algorithm is a recursive algorithm for choosing the next move in an n-player game, usually a two-player game. A value is associated with each position or state of the game.
  • 14. AlphaBeta pruning The benefit of alpha–beta pruning lies in the fact that branches of the search tree can be eliminated. This way, the search time can be limited to the 'more promising' subtree, and a deeper search can be performed in the same time. The optimization reduces the effective depth to slightly more than half that of simple minimax if the nodes are evaluated in an optimal or near optimal order (best choice for side on move ordered first at each node).
  • 15. Monte Carlo Tree Search The focus of Monte Carlo tree search is on the analysis of the most promising moves, expanding the search tree based on random sampling of the search space. The application of Monte Carlo tree search in games is based on many playouts. In each playout, the game is played out to the very end by selecting moves at random. The final game result of each playout is then used to weight the nodes in the game tree so that better nodes are more likely to be chosen in future playouts.
  • 16. Performance Timings for a complete rollout from start single thread on my laptop i7 2Ghz (in millisec on 9x9 and 19x19) 10 160 validmove without deepcopy 6 65 immutable goStrings 3.5 38 neighbors map 1.5 31 faster isAnEye 1.3 27 simpleKo 1.25 25 selectMove returning State 0.7 12 remove System.nanotime 0.5 4.5 RandomBot evaluating single move 0.33 2.4 single swap instead of shuffle 0.27 2.1 array instead of map for winCount