TransWikia.com

How to visualise chess moves using a TikZ tree?

TeX - LaTeX Asked on March 19, 2021

I am building a chess repertoire and would like to visualise it as a tree using TikZ.

Below is an example of what I would like do achieve (source: https://kevinbinz.com/2015/02/26/decision-trees-in-chess/)

  • round nodes with alternated color,
  • moves on edges,
  • text in a last rectangular node (evaluation of the position).

Exact font, color code, node decoration and arrow shape are irrelevant.

example

Note. Any data can be used in the answer.

One Answer

This should be enough to get you started:

documentclass{article}
usepackage{forest}
forestset{end node/.style={draw,rectangle, fill=green!30,minimum width=1cm},
           chess tree/.style={for tree={align=center,edge={-latex},s sep=1cm,l sep=1cm,
           where n children=0{end node, edge={-}}{delay={draw, circle,minimum size=1cm, 
           if={iseven(level())}{fill=white}{fill=black!20}}}}},
           move/.style={if n=1{edge label={node[midway,left]{#1}}}
                              {edge label={node [midway, right]{#1}}}}}
begin{document}
begin{forest}chess tree
[
    [,move=Be3,
        [,move=g5
            [{[1a]-3}]
        ]
    ] 
    [,move=Bh6
        [{[2a]-2}]
    ]
]
end{forest}
end{document}

output of code

Correct answer by Alan Munn on March 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP