[Tex/LaTex] TikZ – Game theory tree with continuum of moves (depicted as a gray triangle)

diagramsforesttikz-pgftikz-treestrees

In extensive form games (game trees), we usually draw a (gray) triangle in the background of the player's branch (strategy) to denote that the player has a continuum of actions available at that node. For example, in the game tree I am sending below I manually draw the triangles for player PM. Player PM has to choose an x (that can assume any value from 0 to 1). However, I don't know how to draw the triangles using TikZ in LaTeX. I am sending what I am looking for:

enter image description here

Below, I am sending the TikZ code I wrote to produce my tree (without the triangles, of course):

\documentclass{article}
\usepackage{sgame, tikz} % Game theory packages
\usetikzlibrary{trees,backgrounds,calc,positioning,arrows}
\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(3)[hollow node,label=left:{$PM$}]{}
    child { node [solid node, label=left:$l_{i}$] {}
      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$}
};
\end{tikzpicture}
\end{document}

Best Answer

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}

enter image description here

Related Question