Skip to content

Instantly share code, notes, and snippets.

@qpwo
qpwo / monte_carlo_tree_search.py
Last active July 22, 2024 09:10
Monte Carlo tree search (MCTS) minimal implementation in Python 3, with a tic-tac-toe example gameplay
"""
A minimal implementation of Monte Carlo tree search (MCTS) in Python 3
Luke Harold Miles, July 2019, Public Domain Dedication
See also https://en.wikipedia.org/wiki/Monte_Carlo_tree_search
https://gist.github.com/qpwo/c538c6f73727e254fdc7fab81024f6e1
"""
from abc import ABC, abstractmethod
from collections import defaultdict
import math
@peterellisjones
peterellisjones / Chess Perft test positions
Last active January 31, 2024 02:21
Test positions for debugging chess engines. Formatted as JSON array of FEN strings
[
{
"depth":1,
"nodes":8,
"fen":"r6r/1b2k1bq/8/8/7B/8/8/R3K2R b KQ - 3 2"
},
{
"depth":1,
"nodes":8,
"fen":"8/8/8/2k5/2pP4/8/B7/4K3 b - d3 0 3"