TikZ - Game theory tree with continuum of moves (depicted as a gray triangle)
Well, Forest would be easier if you have to draw several. For example, your tree could be specified as follows:
\begin{forest}
dec tree,
[PM
[l_i, my label=p, cont
[PM, my label=A
[l_i, my label=x, cont
[x, my label=Y]
[l_i, my label=N
[l_i, my label=VNC
[ne, my label=A]
[, my label=\lnot A]
]
[, my label=\lnot VNC]
]
]
]
[Sq, my label=\lnot A]
]
]
\end{forest}
where my label
sets up the edge labels, dec tree
enables the overall style, and cont
sets a triangle for the parent of the current node.
You can tweak this as desired. (For example, you probably want cont
to be specified for the parent and not one of the children. I did it this way only because I initially thought of making it the child's edge
.)
\documentclass[border=10pt]{standalone}
\usepackage{forest}
\forestset{
declare toks={lpost}{left},
my label/.style={
if n=1{
edge label={node [midway, left] {$#1$}}
}{
edge label={node [midway, right] {$#1$}}
},
},
cont/.style={
tikz+={
\fill [fill=black, fill opacity=.5, blend mode=darken] (!u.children) -- ([xshift=25pt].center) -- ([xshift=-25pt].center) -- cycle;
},
},
dec tree/.style={
for tree={
circle,
inner sep=1.5pt,
l sep'+=25pt,
s sep'+=25pt,
calign=fixed edge angles,
},
where n children=1{draw, fill=white}{
if n children=2{draw, fill=black}{},
},
where level=0{lpost=above}{
if n'=1{lpost=right}{},
},
before typesetting nodes={
where content={}{content=\ddots, inner ysep=0pt, child anchor=parent first, math content}{
label/.process={ OOw2{content}{lpost}{##2:$##1$} },
delay={content=},
},
}
}
}
\begin{document}
\begin{forest}
dec tree,
[PM
[l_i, my label=p, cont
[PM, my label=A
[l_i, my label=x, cont
[x, my label=Y]
[l_i, my label=N
[l_i, my label=VNC
[ne, my label=A]
[, my label=\lnot A]
]
[, my label=\lnot VNC]
]
]
]
[Sq, my label=\lnot A]
]
]
\end{forest}
\end{document}
I would probably add the triangles in the background layer. To this end, I load the library backgrounds
(and calc
for coordinate mending).
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds,calc}
\begin{document}
\begin{tikzpicture}[scale=2.5,font=\footnotesize]
\tikzset{
% Two node styles for game trees: solid and hollow
solid node/.style={circle,draw,inner sep=1.5,fill=black},
hollow node/.style={circle,draw,inner sep=1.5}
}
% Specify spacing for each level of the tree
\tikzstyle{level 1}=[level distance=8mm,sibling distance=20mm]
\tikzstyle{level 2}=[level distance=8mm,sibling distance=20mm]
\tikzstyle{level 3}=[level distance=8mm,sibling distance=20mm]
\tikzstyle{level 4}=[level distance=8mm,sibling distance=20mm]
\tikzstyle arrowstyle=[scale=2.5]
\tikzstyle directed=[postaction={decorate,decoration={markings,
mark=at position .5 with {\arrow[arrowstyle]{stealth}}}}]
% The Tree
\node(0)[hollow node,label=above:{$PM$}]{}
child{node(2)[solid node,label=right:{$l_{i}$}]{}
child{node[hollow node,label=left:{$PM$}](3){}
child { node[solid node, label=left:$l_{i}$](5) {}
child {
node{\emph{x}}
edge from parent
node[left, xshift=-3] {$Y$}}
child { node [solid node, label=right:$l_{i}$] {}
child { node [solid node,label=right:$l_{i}$] {}
child {
node {\emph{ne}}
edge from parent
node[left, xshift=-3] {$A$}}
child {
node {$\ddots$}
edge from parent
node[right, xshift=3] {$\neg A$}}
edge from parent
node[right] {}
edge from parent
node[left] {$VNC$}}
child {
node {$\ddots$}
edge from parent
node[right] {$\neg VNC$}}
edge from parent
node[right] {}
edge from parent
node[right, xshift=2] {$N$}}
edge from parent
node[right] {$x$}}
edge from parent node[left, xshift=-3]{$A$}}
child{node(4)[label=below:{$SQ$}]{}
edge from parent node[right]{$\neg A$}
}
edge from parent node[right,xshift=3]{$p$}
};
\begin{scope}[on background layer]
\draw[fill=gray!40](0.south)--($(2)+(0.6cm,0)$)--($(2)-(0.6cm,0)$)--cycle;
\draw[fill=gray!40](3.south)--($(5)+(0.6cm,0)$)--($(5)-(0.6cm,0)$)--cycle;
\end{scope}
\end{tikzpicture}
\end{document}
Edit: istgame
version 2.0
With the istgame
version 2, you can use a new macro \istrootcntm
(instead of using \istcntm
and \istroot
) to draw a continuum of branches. Using \istrootcntm
is simpler and more powerful than using \istcntm
(discouraged to use the obsolete macro \istcntm
). See also the use of input mode changer \setistmathTF
.
\documentclass{standalone}
\usepackage{istgame}
\begin{document}
\begin{istgame}[scale=2.5,font=\footnotesize]
\setistmathTF111 % all labels are in math mode
\xtdistance{8mm}{20mm}
\istrootcntm(0)[initial node]{PM}+8mm..12mm+
\istb{p}[r]
\endist
\istroot(a)(0-1)<150>{l_2}
\istb{A}[l]
\istb{\neg A}[r]{SQ}
\endist
\istrootcntm(1)(a-1)[initial node]<180>{PM}+8mm..12mm+
\istb{x}[r]
\endist
\istroot(b)(1-1)<150>{l_2}
\istb{Y}[l]{x}[bl]
\istb{N}[r]
\endist
\istroot(c)(b-2){l_i}
\istb{VNC}[l]
\istb{\neg VNC}[r]{\ddots}[br]
\endist
\istroot(d)(c-1){l_i}
\istb{A}[l]{ne}[bl]
\istb{\neg A}[r]{\ddots}[br]
\endist
\end{istgame}
\end{document}
Original answer
Here is another solution to use the package istgame, with which you can use \istcntm
to draw a continuum of actions.
\documentclass{standalone}
\usepackage{istgame}
\begin{document}
\begin{istgame}[scale=2.5,font=\footnotesize]
\xtdistance{8mm}{20mm}
\istcntm(ctm0)+8mm..12mm+
\istroot(0)(ctm0)[initial node]{$PM$}+\cntmlevdist..\cntmlevdist+
\istb{p}[r]
\endist
\istroot(a)(0-1)<150>{$l_2$}
\istb{A}[l]
\istb{\neg A}[r]{SQ}
\endist
\istcntm(ctm1)(a-1)+8mm..12mm+
\istroot(1)(ctm1)[initial node]<180>{$PM$}+\cntmlevdist..\cntmlevdist+
\istb{x}[r]
\endist
\istroot(b)(1-1)<150>{$l_2$}
\istb{Y}[l]{x}[bl]
\istb{N}[r]
\endist
\istroot(c)(b-2){$l_i$}
\istb{VNC}[l]
\istb{\neg VNC}[r]{\ddots}[br]
\endist
\istroot(d)(c-1){$l_i$}
\istb{A}[l]{ne}[bl]
\istb{\neg A}[r]{\ddots}[br]
\endist
\end{istgame}
\end{document}