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.


Note. Any data can be used in the answer.


This should be enough to get you started:

\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, 
           move/.style={if n=1{edge label={node[midway,left]{#1}}}
                              {edge label={node [midway, right]{#1}}}}}
\begin{forest}chess tree

output of code

  • This is perfect, thank you for your time – Victor Jan 27 at 20:03
  • @Victor I'd be really interested in your final result. Would you mind posting it once you're done? :) – JeT Jan 27 at 20:51
  • With pleasure! :) – Victor Jan 27 at 21:51
  • @Victor I've made a couple of changes to the code to removed the arrow from the final branch, and removed a spurious end node that wasn't needed in the tree. – Alan Munn Jan 27 at 22:36
  • This is a bit cleaner indeed, thank you! What I am currently struggling with is spacing correctly the branches when there are a lot of them (let's say five or six). After that I'll send you the result – Victor Jan 28 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.