1

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.

11
  • 1
    Welcome to TeX.SE! Can you show us what you have tried so far?
    – Mensch
    Commented Dec 17, 2017 at 23:55
  • Hey, I'm trying to do a game tree in Latex Commented Dec 17, 2017 at 23:57
  • see example on top of the page 325 in TikZ & PGF manual (v 3.0.1a). it can serve you as starting point. also see texample.net/tikz/examples/feature/trees
    – Zarko
    Commented Dec 17, 2017 at 23:59
  • 1
    Show us what you got with whatever you tried. Nobody wants to type out the content of your tree from an image file just in order to see if they might be able to help. There are many, many, many similar examples on this site and elsewhere and many packages to choose from.
    – cfr
    Commented Dec 18, 2017 at 0:37
  • 1
    Similar: tex.stackexchange.com/questions/314282/…. Very similar: tex.stackexchange.com/questions/54308/…. [I knew this arc thing had come up before - at least twice, I think. I didn't remember it was the 'continuous moves' representation, but a search on that would have turned up existing solutions, since the OP obviously could use that as a search term, given that's the point of the question ....]
    – cfr
    Commented Dec 18, 2017 at 0:49

2 Answers 2

5

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}
5

You can also use the istgame package:

Edit: istgame v2.0

With the istgame v2.0, \istrootcntm (instead of \istcntm) and \xtCInfoset (curved information set) can improve codes a little. (discouraged to use obsolete \istcntm)

\begin{document}   

\begin{istgame}[font=\scriptsize]
\xtALPush{-2pt}{-2pt}
% top part
\xtdistance{15mm}{50mm}
\istroot(0)[chance node]{N}
  \istb{\theta}[al]
  \istb{1-\theta}[ar]
  \endist
% middle part: left
\cntmdistance*{15mm}{15mm}
\istrootcntm[-120](P1)(0-1)
  \istb{P}[l]  \endist
\istroot(N1)(0-1)<135>{G}
  \istb*<grow=-60>{N}[r]
  \endist
% middle part: right
\istrootcntm[-120](P2)(0-2)
  \istb{P}[l]
  \endist
\istroot(N2)(0-2)  
  \istb*<grow=-60>{N}[r]
  \endist
% lower part: left
\xtdistance{15mm}{10mm}
\istroot(PN1)(P1-1)[chance node]<180>{N}
  \istb{\gamma}[l]
  \istb{\tau}[l]
  \istb{\phi}[l]
  \istb{1-\gamma-\tau-\phi}[r]
  \endist
% lower part: right
\xtdistance{15mm}{10mm}
\istroot(PN2)(P2-1)[chance node]<180>{N}
  \istb{\gamma}[l]
  \istb{\tau}[l]
  \istb{\phi}[l]
  \istb{1-\gamma-\tau-\phi}[r]
  \endist
% bottom part
\xtdistance{10mm}{5mm}
\foreach \a in {1,2}
  {\foreach \b in {1,2,3,4}
     {\istroot(T\a\b)(PN\a-\b)<180>{T}
      \istb{A}[l]  \istb{B}[r]  \endist
     }
  }
% information sets
\foreach \c in {1,2,3,4}
  {\xtCInfoset[solid,thin,orange](T1\c)(T2\c)<1.2>
  }
\end{istgame}

\end{document}

enter image description here

Original answer (istgame v1.0)

%% full codes
\documentclass{standalone}

\usepackage{istgame}

\begin{document}   

\begin{istgame}[font=\scriptsize]
\xtALPush{-2pt}{-2pt}
% top part
\xtdistance{15mm}{50mm}
\istroot(0)[chance node]{N}
  \istb{\theta}[al]
  \istb{1-\theta}[ar]
  \endist
% middle part: left
\istcntm[-120](cntm)(0-1)[green]+15mm..15mm+
\istroot[-120](P1)(cntm)<135>{G}+15mm..15mm+
  \istb{P}[l]
  \endist
\istroot(N1)(cntm)  
  \istb*<grow=-60>{N}[r]
  \endist
% middle part: right
\istcntm[-120](cntm)(0-2)[green]+15mm..15mm+
\istroot[-120](P2)(cntm)<45>{G}+15mm..15mm+
  \istb{P}[l]
  \endist
\istroot(N2)(cntm)  
  \istb*<grow=-60>{N}[r]
  \endist
% lower part: left
\xtdistance{15mm}{10mm}
\istroot(PN1)(P1-1)[chance node]<180>{N}
  \istb{\gamma}[l]
  \istb{\tau}[l]
  \istb{\phi}[l]
  \istb{1-\gamma-\tau-\phi}[r]
  \endist
\xtdistance{10mm}{5mm}
\istroot(T11)(PN1-1)<180>{T}
  \istb{A}[l]  \istb{R}[r]  \endist
\istroot(T12)(PN1-2)<180>{T}
  \istb{A}[l]  \istb{R}[r]  \endist
\istroot(T13)(PN1-3)<180>{T}
  \istb{A}[l]  \istb{R}[r]  \endist
\istroot(T14)(PN1-4)<180>{T}
  \istb{A}[l]  \istb{R}[r]  \endist
% lower part: right
\xtdistance{15mm}{10mm}
\istroot(PN2)(P2-1)[chance node]<180>{N}
  \istb{\gamma}[l]
  \istb{\tau}[l]
  \istb{\phi}[l]
  \istb{1-\gamma-\tau-\phi}[r]
  \endist
\xtdistance{10mm}{5mm}
\istroot(T21)(PN2-1)<180>{T}
  \istb{A}[l]  \istb{R}[r]  \endist
\istroot(T22)(PN2-2)<180>{T}
  \istb{A}[l]  \istb{R}[r]  \endist
\istroot(T23)(PN2-3)<180>{T}
  \istb{A}[l]  \istb{R}[r]  \endist
\istroot(T24)(PN2-4)<180>{T}
  \istb{A}[l]  \istb{R}[r]  \endist
% information sets
\xtInfoset[solid,thin,orange,bend left=20](T11)(T21)
\xtInfoset[solid,thin,orange,bend left=20](T12)(T22)
\xtInfoset[solid,thin,orange,bend left=20](T13)(T23)
\xtInfoset[solid,thin,orange,bend left=20](T14)(T24)
\end{istgame}

\end{document}

The istgame environment is just like the tikzpicture environment. For the bottom part of this tree, you can use \foreach to repeat things. A complete example is as follows:

%% shortened codes using \foreach
\documentclass{standalone}

\usepackage{istgame}

\begin{document}   

\begin{istgame}[font=\scriptsize]
\xtALPush{-2pt}{-2pt}
% top part
\xtdistance{15mm}{50mm}
\istroot(0)[chance node]{N}
  \istb{\theta}[al]
  \istb{1-\theta}[ar]
  \endist
% middle part: left
\istcntm[-120](cntm)(0-1)[green]+15mm..15mm+
\istroot[-120](P1)(cntm)<135>{G}+15mm..15mm+
  \istb{P}[l]
  \endist
\istroot(N1)(cntm)  
  \istb*<grow=-60>{N}[r]
  \endist
% middle part: right
\istcntm[-120](cntm)(0-2)[green]+15mm..15mm+
\istroot[-120](P2)(cntm)<45>{G}+15mm..15mm+
  \istb{P}[l]
  \endist
\istroot(N2)(cntm)  
  \istb*<grow=-60>{N}[r]
  \endist
% lower part: left
\xtdistance{15mm}{10mm}
\istroot(PN1)(P1-1)[chance node]<180>{N}
  \istb{\gamma}[l]
  \istb{\tau}[l]
  \istb{\phi}[l]
  \istb{1-\gamma-\tau-\phi}[r]
  \endist
% lower part: right
\xtdistance{15mm}{10mm}
\istroot(PN2)(P2-1)[chance node]<180>{N}
  \istb{\gamma}[l]
  \istb{\tau}[l]
  \istb{\phi}[l]
  \istb{1-\gamma-\tau-\phi}[r]
  \endist
% bottom part
\xtdistance{10mm}{5mm}
\foreach \a in {1,2}
  {\foreach \b in {1,2,3,4}
     {\istroot(T\a\b)(PN\a-\b)<180>{T}
      \istb{A}[l]  \istb{B}[r]  \endist
     }
  }
% information sets
\foreach \c in {1,2,3,4}
  {\xtInfoset[solid,thin,orange,bend left=20](T1\c)(T2\c)
  }
\end{istgame}

\end{document}
2
  • Neat. I do not find this in Ubuntu's texlive set, otherwise I'd put it to use.
    – pauljohn32
    Commented Jan 26, 2018 at 16:22
  • Ubuntu is probably installing an outdated TeXLive and the package is quite new. You can install it into your local texmf folder from the version on CTAN.
    – Alan Munn
    Commented Jan 29, 2019 at 17:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .