[Tex/LaTex] Drawing a game tree on Tikz

tikz-pgftikz-treestrees

I need to draw the following game tree on tikz. It's a bayesian game.
Sorry for the pic, I made it on Paint.

So basically there are 2 players G and T, N is the nature that gives a chance for each type of player. The action of G is continuous, that's why I put the curve line.

enter image description here

So, my main doubr is to put the continuous set of action for player G and to put the same set of information for players of the same type. As it can be seen in the following pic:

 \documentclass[tikz,border=10pt,multi]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{trees}
\usetikzlibrary{calc}
\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}
}
\begin{document}
\begin{tikzpicture}[font=\footnotesize,edge from parent/.style={draw,thick}]
% Two node styles: solid and hollow
\tikzstyle{solid node}=[circle,draw,inner sep=1.2,fill=black];
\tikzstyle{hollow node}=[circle,draw,inner sep=1.2];
% Specify spacing for each level of the tree
\tikzstyle{level 1}=[level distance=15mm,sibling distance=50mm]
\tikzstyle{level 2}=[level distance=15mm,sibling distance=25mm]
\tikzstyle{level 3}=[level distance=15mm,sibling distance=15mm]
\tikzstyle{level 4}=[level distance=15mm,sibling distance=10mm]
% The Tree
\node(0)[hollow node]{}
child{node[solid node]{}
child{node[solid node]{}
child{node[below]{$1,0$} edge from parent node[left]{$\gamma$}
child{node[below]{$2,3$} edge from parent node[right]{$\tal$}
edge from parent node[above left]{$P$}
}
%I need to put for options in the node
child{node[solid node]{}
edge from parent node[above right]{$N$}
}
edge from parent node[above left]{$\theta$}
}
child{node[solid node]{}
child{node[solid node]{}
child{node[below]{$1,0$} edge from parent node(m)[left]{$\gamma$}
child{node[below]{$2,3$} edge from parent node(n)[right]{$\tal$}
edge from parent node[above left]{$c$}
}
child{node[solid node]{}
edge from parent node[above right]{$N$}
}
edge from parent node[above right]{$1-\theta$}
}
% information sets
\drawloosely dotted,very thicktoout=-15,in=195;
% movers
\node[above,yshift=2]at(0){};
\foreach \x in {1,2} \node[above,yshift=2]at(0-\x){};
\node at($.5(m)+.5(n)$){1};
\end{tikzpicture}
\end{document}

I tried using this code here:

\begin{tikzpicture}
\tikzstyle{hollow node}=[circle,draw,inner sep=1.5]
\tikzstyle{solid node}=[circle,draw,inner sep=1.5,fill=black]
\tikzset{
red node/.style={circle,draw=red,fill=red,inner sep=1.2},
blue node/.style={rectangle,draw=blue,inner sep=2.5}
}
% Specify spacing for each level of the tree
\tikzstyle{level 1}=[level distance=15mm,sibling distance=40mm]
\tikzstyle{level 2}=[level distance=15mm,sibling distance=30mm]
\tikzstyle{level 3}=[level distance=15mm,sibling distance=15mm]
\tikzstyle{level 4}=[level distance=15mm,sibling distance=12mm]

\node[hollow node,label=above:{Natureza}]{}
child{node(1)[solid node]{}
child{node[solid node]{} edge from parent node[left]{$P$}}
child{node[solid node]{} edge from parent node[right]{$N$}}
edge from parent node[left,xshift=-3]{$\theta$}
}
child{node(2)[solid node]{}
child{node[solid node]{} edge from parent node[left]{$P$}}
child{node[solid node]{} edge from parent node[right]{$N$}}
edge from parent node[right,xshift=3]{$1-\theta$}
};
\node at ($(1)!.5!(2)$) {$Governo$};
\end{tikzpicture}

If anyone could help me, I would be glad.

Best Answer

It is not altogether clear what exactly you want changed and what exactly you are stuck on, even with the addition of code.

Personally, I would use Forest because I like it and it is easy to make it do things concisely and more-or-less automagically, depending on your requirements. You can also use TikZ code in the tree, since it is based on TikZ. Tree specifications are a lot more concise, however.

Here's an example which implements a configuration where the content specified for each node is split:

<label>:<edge label>

and the option

my arc

enables the drawing of the little green arcs. Hopefully this should get you started.

Then we can write

  [N, label=above:Natureza
    [G:\theta, my arc
      [N:P, name=a
        [T:\gamma[:A][:R]]
        [T:\tau[:A][:R]]
        [T:\phi[:A][:R]]
        [T:1-\gamma-\tau-\phi[:A][:R]]
      ]
      [:N, name=b]
    ]
    [G:1-\theta, my arc, before typesetting nodes={prepend'={a}, append'={b}}
    ]
  ]

to specify the main tree, adding the 'Governo' label by hand afterwards.

  \node [font=\itshape] at (!r |- !r1) {Governo};

The result is as follows:

tree with little green arcs

With a judicious definition for copy name template we can implement a style, copy connect to join a node to its counterpart on the other side.

Then we can write

  [N, label=above:Natureza
    [G:\theta, my arc
      [N:P, name=a, for children=copy connect
        [T:\gamma[:A][:R]]
        [T:\tau[:A][:R]]
        [T:\phi[:A][:R]]
        [T:1-\gamma-\tau-\phi[:A][:R]]
      ]
      [:N, name=b]
    ]
    [G:1-\theta, my arc, before typesetting nodes={prepend'={a}, append'={b}}
    ]
  ]
  \node [font=\itshape] at (!r |- !r1) {Governo};

to produce

tree with big orange arcs, too

This works because the nodes on the right are copies of the nodes on the left and we've labelled our copies systematically by appending -c to the name.

Complete code:

\documentclass[border=10pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{forest}
\usetikzlibrary{calc}
\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}
}
\begin{document}
\begin{forest}
  for tree={
    l sep'+=25pt,
    s sep'+=5pt,
  },
  before typesetting nodes={
    where content={}{}{
      split option={content}{:}{my label,my edge label},
      delay={content=},
    },
    delay={for descendants={if n children=0{}{solid node}}},
  },
  hollow node,
  my label/.style={
    if={isodd(n)}{label={[green!75!black, font=\small]left:#1}}{label={[green!75!black, font=\small]right:#1}}
  },
  my edge label/.style={
    if={isodd(n)}{edge label={node [midway, red, left, font=\scriptsize] {$#1$}}}{edge label={node [midway, red, right, font=\scriptsize] {$#1$}}}
  },
  my arc/.style={
    tikz+={
      \draw [green!75!black] ($()!0.3!(!l)$) [bend left] to ($()!0.3!(!1) + (-5pt,2.5pt)$);
    },
  },
  copy name template={#1-c},
  copy connect/.style={
    tikz+/.process={
      Ow {name}
      {
        \draw [orange] () [bend left=15] to (##1-c);
      }%
    },
  }
  [N, label=above:Natureza
    [G:\theta, my arc
      [N:P, name=a, for children=copy connect
        [T:\gamma[:A][:R]]
        [T:\tau[:A][:R]]
        [T:\phi[:A][:R]]
        [T:1-\gamma-\tau-\phi[:A][:R]]
      ]
      [:N, name=b]
    ]
    [G:1-\theta, my arc, before typesetting nodes={prepend'={a}, append'={b}}
    ]
  ]
  \node [font=\itshape] at (!r |- !r1) {Governo};
\end{forest}
\end{document}