[Tex/LaTex] Latex and Game Theory: Combining an Extensive and Normal Form for a Three Players Game

tikz-matrixtikz-pgftikz-treestrees

I am having trouble on editing my Latex code to produce a figure (game) using the Tikz package.

I am trying to produce a three players game combining an extensive form (for player 3) and two matrices for player 1 and player 2. Below, I am sending the figure I produced:

game

The tex code I wrote for producing this game is:

    \begin{figure}[!htbp]
\centering
\caption*{Three Players Game: Combining Extensive Form with Matrix Form}\label{hybrid}
\begin{tikzpicture}[scale=1,font=\footnotesize,edge from parent/.style={draw,thick}]
  % Two node styles: solid and hollow
    \tikzstyle{solid node}=[circle,draw,inner sep=1.2];
    \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]
  % The Tree
  \node(0)[hollow node]{}
    child{node{}
    edge from parent node[above left]{X}
    }
    child{node{}
    edge from parent node[above right]{Y}
    };
  % movers
  \node[above,circle,inner sep=1,yshift=4]at(0){1};
  \node[below]at(0-1){
    \gamemathfalse
    \arrayrulewidth.75pt
    \begin{game}{2}{2}[$P_{1}$][$P_{2}$]
           & X   & Y\\
       X & $1, 1, 1$ & $2, 0, 2$\\
       Y & $0, 2, 0$ & $2, 2, 2$
       \end{game}
         };
         \node[below,xshift=-15]at(0-2){
           \gamemathfalse
           \arrayrulewidth.75pt
           \begin{game}{2}{2}[$P_{1}$][$P_{2}$]
                  & X   & Y\\
              X & $3, 1, 3$ & $2, 2, 2$\\
              Y & $1, 1, 1$ & $1, 3, 1$
           \end{game}
         };
       \end{tikzpicture}
       \end{figure}

There are several things I would like to fix in this figure:

  1. Instead of the number "1" above the first node, I would like to have "P3" (for Player 3). I tried several things to substitute 1 by P3 such as including "label=above:{P3}" within the code line: "\node(0)[hollow node]{}". But the number 1 is still there.

  2. I would like to align the left matrix according to the end of the extensive form tree (similar to the alignment of the right matrix).

  3. If possible, I would like to have P3 and the extensive form below the matrix. That is, instead of having first the extensive form and then having it connected to the matrices from top to bottom, I would like to have first the two matrices on the top, and below to it the extensive form (as in the edited figure below).

In sum, this is the Tikz/game/figure I am looking for:

game edited

Thanks in advance!

Best Answer

Here are a few examples of your tree in various directions, using the istgame package. You can use \setistgrowdirection or its swap version \setistgrowdirection' to change the tree growing direction.

(I drew the game tables using the tabu package, because (as mentioned in the manual) the sgame package is not compatible with the memoir class or any other packages that load array.sty.)

enter image description here

\documentclass{article}

\usepackage{istgame}
\usepackage{tabu,makecell,multirow}
\DeclareExpandableDocumentCommand\xcol{mO{c}m}{\multicolumn{#1}{#2}{$#3$}}

\def\gameX{%
  \mbox{%
  \begin{tabu}spread0pt{X[c1]X[$c1]*2{|X[$c2]}|}
  \xcol2{} & \xcol2{P_2} \\
  \xcol2{} & \xcol1{X} &\xcol1{Y} \\\tabucline{3-}
  \multirowcell{2}{$P_1$}
    &  X   & 1,1,1     & 2,0,2    \\\tabucline{3-}
    &  Y   & 0,2,0     & 2,2,2    \\\tabucline{3-}
  \end{tabu}%
  }
}

\def\gameY{%
  \mbox{%
  \begin{tabu}spread0pt{X[c1]X[$c1]*2{|X[$c2]}|}
  \xcol2{} & \xcol2{P_2} \\
  \xcol2{} & \xcol1{X} &\xcol1{Y} \\\tabucline{3-}
  \multirowcell{2}{$P_1$}
    &  X   & 3,1,3     & 2,2,2    \\\tabucline{3-}
    &  Y   & 1,1,1     & 1,3,1    \\\tabucline{3-}
  \end{tabu}%
  }
}
\pagestyle{empty}

\begin{document}

\begin{itemize}
\item a tree: downward

\begin{istgame}
\xtdistance{15mm}{50mm}
\istroot(0)[initial node]{$P_3$}
  \istb{X}[al]{\gameX}[below,xshift=-8mm]
  \istb{Y}[ar]{\gameY}[below,xshift=-8mm]
  \endist
\end{istgame}

\item a tree: upward

\begin{istgame}
\setistgrowdirection'{north}
\xtdistance{15mm}{50mm}
\istroot(0)[initial node]<-90>{$P_3$}
  \istb{X}[bl]{\gameX}
  \istb{Y}[br]{\gameY}
  \endist
\end{istgame}

\item a tree: toward the right

\begin{istgame}
\setistgrowdirection'{east}
\xtdistance{20mm}{15mm}
\istroot(0)[initial node]<180>{$P_3$}
  \istb{X}[al]{\gameX}[above right,yshift=-2mm]
  \istb{Y}[bl]{\gameY}
  \endist
\end{istgame}
\end{itemize}

\end{document}

Added: You can draw the strategic games as you like. For example, if you prefer using the tabular environment (to tabu), replace the \def\gameX and \def\gameY parts above by the following:

\def\gameX{%
  \mbox{%
  \begin{tabular}{cc|c|c|}
  \xcol2{} & \xcol2{P_2} \\
  \xcol2{} & \xcol1{X} &\xcol1{Y} \\\cline{3-4}
  \multirowcell{2}{$P_1$}
    &  X   & 1,1,1     & 2,0,2    \\\cline{3-4}
    &  Y   & 0,2,0     & 2,2,2    \\\cline{3-4}
  \end{tabular}%
  }
}

\def\gameY{%
  \mbox{%
  \begin{tabular}{cc|c|c|}
  \xcol2{} & \xcol2{P_2} \\
  \xcol2{} & \xcol1{X} &\xcol1{Y} \\\cline{3-4}
  \multirowcell{2}{$P_1$}
    &  X   & 3,1,3     & 2,2,2    \\\cline{3-4}
    &  Y   & 1,1,1     & 1,3,1    \\\cline{3-4}
  \end{tabular}%
  }
}