我怎样才能重现这个带箭头的简单游戏树图?

我怎样才能重现这个带箭头的简单游戏树图?

我想重现下图。我认为这是使用 Tikz 完成的,但我不确定箭头和花括号是如何绘制的。

在此处输入图片描述

我想知道你们是否可以帮助我编写一个代码来帮助我开始。

答案1

使用 来绘制这个相当简单forest。我不知道这是否是最有效的方法。

\usepackage[edges]{forest}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
\begin{document}
\begin{forest}                      
for tree={grow'=0,align=left,l sep=6em,
    anchor=center,parent anchor=east,child anchor=west,
    edge={semithick,-stealth,shorten >=1em}},
 [Type $a$ and $b$: $z$,alias=root
  [{$s=1$\\
   Type $a$: $\delta u(c)$\\
   Type $b$: $u(c)$\\
   $\delta>1$},
   edge label={node[pos=0.4,above]{$1/2$}},
   alias=c1,inner ysep=0pt]
  [{$s=2$\\
   Type $a$: $u(c)$\\
   Type $b$: $\delta  u(c)$\\
   $\delta>1$},
   edge label={node[pos=0.4,below]{$1/2$}},
   alias=c2,inner ysep=0pt]
 ]
\path ([yshift=-1ex]current bounding box.south) coordinate (aux);
\begin{scope}[decoration={calligraphic brace, amplitude=6pt},line width=1pt]
  \draw[decorate] (aux-|root.east) --
    (aux-|root.west) node[midway,below=1ex]{Day};
  \draw[decorate] (aux-|c1.east) --
    ([xshift=-1ex]c1.west|-aux) node[midway,below=1ex]{Night};
  \draw[decorate] (c1.south west) -- (c1.north west);
  \draw[decorate] (c2.south west) -- (c2.north west);
\end{scope} 
\end{forest}
\end{document}

在此处输入图片描述

您还可以将括号添加到节点的定义中。

\documentclass[tikz,border=10pt]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
\tikzset{brace node/.style={align=left,inner xsep=1.5em,inner ysep=0pt,
path picture={
\draw[decoration={calligraphic brace, amplitude=6pt},line width=1pt,decorate]
 ([xshift=2ex,yshift=0.5pt]path picture bounding box.south west)
 -- ([xshift=2ex,yshift=-0.5pt]path picture bounding box.north west);
}}}
\begin{document}
\begin{forest}                      
for tree={grow'=0,align=left,l sep=6em,
    anchor=center,parent anchor=east,child anchor=west,
    edge={semithick,-stealth}},
 [Type $a$ and $b$: $z$,alias=root
  [{$s=1$\\
   Type $a$: $\delta u(c)$\\
   Type $b$: $u(c)$\\
   $\delta>1$},
   edge label={node[pos=0.4,above]{$1/2$}},
   brace node,alias=c1]
  [{$s=2$\\
   Type $a$: $u(c)$\\
   Type $b$: $\delta  u(c)$\\
   $\delta>1$},
   edge label={node[pos=0.4,below]{$1/2$}},
   brace node,alias=c2]
 ]
\path ([yshift=-1ex]current bounding box.south) coordinate (aux);
\begin{scope}[decoration={calligraphic brace, amplitude=6pt},line width=1pt]
  \draw[decorate] (aux-|root.east) --
    (aux-|root.west) node[midway,below=1ex]{Day};
  \draw[decorate] ([xshift=-1.5ex]c1.east|-aux) --
    (c1.west|-aux) node[midway,below=1ex]{Night};
\end{scope} 
\end{forest}
\end{document}

在此处输入图片描述

答案2

再次尝试使用istgame包裹:

在此处输入图片描述

\documentclass{article}

\usepackage{amsmath}
%\usepackage{tikz} % istgame loads tikz
\usepackage{istgame}
\usetikzlibrary{decorations.pathreplacing}

\begin{document}

% complicated payoffs 
% this can go into the istgame environment (to make it local)
\def\mypayoffA
{ \ensuremath{
  \begin{cases}
  s=1\\
  \text{Type } a:~\delta u(c)\\
  \text{Type } b:~u(c)\\
  \delta>1
  \end{cases}
  }
}
\def\mypayoffB
{ \ensuremath{
  \begin{cases}
  s=2\\
  \text{Type } a:~u(c)\\
  \text{Type } b:~\delta u(c)\\
  \delta>1
  \end{cases}
  }
}

\begin{istgame}[decoration={brace,amplitude=5pt}]
% tree (istgame)
\setistgrowdirection'{east}
\xtdistance{30mm}{22mm}
\istroot(0)[null node]<180>{Type $a$ and $b$: $-z$}
  \istb[->]{\frac12}[a]{\mypayoffA}
  \istb[->]{\frac12}[b]{\mypayoffB}
  \endist
% bottom part (tikz)
\node also [alias=A] (current bounding box);
\draw [decorate,overlay] (0|-A.south) -- (A.south west) 
  node [midway,below=1ex] {Day};
\draw [decorate] (A.south east) -- ([xshift=1ex]0-2|-A.south) 
  node [midway,below=1ex] {Night};
\end{istgame}

\end{document}

相关内容