Drawing game tree - Tikz or Forest?
I cannot answer the question TikZ or forest because, as Alan points out, forest is based on TikZ. The only thing I can do is to add the bent dashed fit around two of your nodes. This is done with a style rconnect
\draw[dashed] let \p1=($(F1.north)-(F1.center)$) in
[/tikz/rconnect/radius=\y1] [rconnect=LL and RR];
where the let ... in
is to make sure that the dimensions match those of your fit
nodes. (You can add the Nature
node using a label
, which also fixes the minor error I got when running your code.)
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage[edges]{forest}
\usepackage[outline]{contour}
\usetikzlibrary{fit,shapes.misc,arrows.meta,positioning}
\tikzset{rconnect/.style args={#1 and #2}{insert path={
($(#1)+(270+\pgfkeysvalueof{/tikz/rconnect/angle}:\pgfkeysvalueof{/tikz/rconnect/radius})$)
arc(270+\pgfkeysvalueof{/tikz/rconnect/angle}:90+\pgfkeysvalueof{/tikz/rconnect/angle}:\pgfkeysvalueof{/tikz/rconnect/radius})
to[out=\pgfkeysvalueof{/tikz/rconnect/angle},in=180-\pgfkeysvalueof{/tikz/rconnect/angle}]
($(#2)+(90-\pgfkeysvalueof{/tikz/rconnect/angle}:\pgfkeysvalueof{/tikz/rconnect/radius})$)
arc(90-\pgfkeysvalueof{/tikz/rconnect/angle}:-90-\pgfkeysvalueof{/tikz/rconnect/angle}:\pgfkeysvalueof{/tikz/rconnect/radius})
to[in=\pgfkeysvalueof{/tikz/rconnect/angle},out=180-\pgfkeysvalueof{/tikz/rconnect/angle}]
cycle}},rconnect/.cd,radius/.initial=6.5pt,angle/.initial=-12}
\begin{document}
\begin{forest}
for tree={s sep=0.1cm,l sep=1.2cm,font=\scriptsize,
where n children=0{align=center,draw,edge={thick,-{Circle}}} {circle,fill,inner sep=0pt,minimum size=2mm},
where n=1{edge label={node[midway,above left=0pt,font=\scriptsize]{S}}} {edge
label={node[midway,above right=0pt,font=\scriptsize]{E}}},
edge={thick}
}
[,label=above:Nature,alias=T
[,alias=L
[,alias=LL
[
[{$B-C$ \\ $0$}]
[{$B$ \\ $X$}]
]
[
[{$B-L$ \\ $R-L$}]
[{$B-L$ \\ $R-L$}]
]
]
[,alias=LR
[
[{$B-C$ \\ $0$}]
[{$B$ \\ $X$}]
]
[
[{$B-L$ \\ $R-L$}]
[{$B-L$ \\ $R-L$}]
]
]
]
[,alias=R
[,alias=RL
[
[{$B-C$ \\ $\bar{R}$}]
[{$B$ \\ $X$}]
]
[
[{$B-L$ \\ $R-L$}]
[{$B-L$ \\ $R-L$}]
]
]
[,alias=RR
[
[{$B-C$ \\ $\bar{R}$}]
[{$B$ \\ $X$}]
]
[
[{$B-L$ \\ $R-L$}]
[{$B-L$ \\ $R-L$}]
]
]
]
]
\node[draw,dashed,rounded rectangle,fit=(L) (R)] (F1){};
\node[draw,dashed,rounded rectangle,fit=(LR) (RL)]{};
\draw[dashed] let \p1=($(F1.north)-(F1.center)$) in
[/tikz/rconnect/radius=\y1] [rconnect=LL and RR];
\end{forest}
\end{document}
Another solution to use the istgame package:
\documentclass{standalone}
\usepackage{amsmath}
\usepackage{makecell}
\usepackage{istgame}
\NewDocumentCommand\mact{m}
{\makecell[c]{#1}}
\NewDocumentCommand\mpay{m}
{\begin{matrix}#1\end{matrix}}
\begin{document}
\begin{istgame}[font=\footnotesize]
\setistmathTF*001
\xtShowEndPoints
% top part
\xtdistance{25mm}{120mm}
\istroot(0)[chance node]{Nature}
\istb{\mact{$R=O$\\cooperative\\partner}}[al]
\istb{\mact{$R=\bar R$\\noncooperative\\partner}}[ar] \endist
\xtdistance{25mm}{50mm}
\istroot(A)(0-1)%<180>{Minister}
\istb{\mact{Introduce\\first proposal}}[l] \endist
\istroot(B)(0-2)%<0>{Minister}
\istb{\mact{Introduce\\first proposal}}[r] \endist
% left part
\xtdistance{25mm}{60mm}
\istroot(A0)(A-1)<180>{Partner}
\istb{Scrutinize}[l] \istb{Endorse}[r] \endist
\xtdistance{25mm}{30mm}
\istroot(A1)(A0-1)<0>{$B-C,O$}
\istb{\mact{Introduce\\second\\proposal}}[al] \istb{Delay}[ar] \endist
\istroot(A2)(A0-2)<180>{$B,X$}
\istb{\mact{Introduce\\second\\proposal}}[al] \istb{Delay}[ar] \endist
\xtdistance{25mm}{15mm}
\istroot(A3)(A1-1)<180>{Partner}
\istb{Scrut.}[l]{B-C,O} \istb{Endorse}[r]{B,X} \endist
\istroot(A4)(A1-2)<0>{Partner}
\istb{S}[l]{\mpay{B-L,\\R-L}} \istb{E}[r]{\mpay{B-L,\\R-L}} \endist
\istroot(A5)(A2-1)<0>{Partner}
\istb{S}[l]{B-C,O} \istb{E}[r]{B,X} \endist
\istroot(A6)(A2-2)<0>{Partner}
\istb{S}[l]{\mpay{B-L,\\R-L}} \istb{E}[r]{\mpay{B-L,\\R-L}} \endist
% right part
\xtdistance{25mm}{60mm}
\istroot(B0)(B-1)<180>{Partner}
\istb{Scrutinize}[l] \istb{Endorse}[r] \endist
\xtdistance{25mm}{30mm}
\istroot(B1)(B0-1)<0>{$B-C,\bar R$}
\istb{\mact{Introduce\\second\\proposal}}[al] \istb{Delay}[ar] \endist
\istroot(B2)(B0-2)<180>{$B,X$}
\istb{\mact{Introduce\\second\\proposal}}[al] \istb{Delay}[ar] \endist
\xtdistance{25mm}{15mm}
\istroot(B3)(B1-1)<180>{Partner}
\istb{Scrut.}[l]{B-C,\bar R} \istb{Endorse}[r]{B,X} \endist
\istroot(B4)(B1-2)<0>{Partner}
\istb{S}[l]{\mpay{B-L,\\R-L}} \istb{E}[r]{\mpay{B-L,\\R-L}} \endist
\istroot(B5)(B2-1)<0>{Partner}
\istb{S}[l]{B-C,\bar R} \istb{E}[r]{B,X} \endist
\istroot(B6)(B2-2)<0>{Partner}
\istb{S}[l]{\mpay{B-L,\\R-L}} \istb{E}[r]{\mpay{B-L,\\R-L}} \endist
% information sets
\xtInfosetO(A)(B){Minister}
\xtCInfosetO(A1)!.35!(B1)<1.15>{Minister}
\xtCInfosetO(A2)!.65!(B2)<1.15>{Minister}
\end{istgame}
\end{document}