There’s an implementation of the Monte Carlo tree search in cglib, my library for CodinGame.

We already scratched the surface about this algorithm in previous post Monte Carlo Tree Search - basics. I’ve found that many times it’s better to bang my head over an implementation so that I can really understand the ins and outs of an algorithm.

The implementation (in Perl, of course!) can be found at, with some documentation at MonteCarloTreeSearch.pod. And yes, I should really, really start to write proper tests for all this stuff.

Or, for what matters, start using it in CodinGame 🙄

My plan is to comment a bit on the code in the future posts… so stay tuned!