如何使遊戲樹中的分支平行?

如何使遊戲樹中的分支平行?

我創建了以下遊戲樹: 在此輸入影像描述 這是我的程式碼:

\documentclass[leqno, oneside, 12pt]{book}
\usepackage{amsmath}
\usepackage{istgame}
\usepackage{caption}
\usepackage{makecell}
\begin{document}
\begin{figure}[ht]
    \centering
    \begin{istgame}[font=\footnotesize]
        \xtdistance{30mm}{90mm}
        \setxtinfosetstyle{dashed}
        \xtShowEndPoints
        \istroot[right](0)<above>{0}
            \istbA{0.95}[above,sloped]
            \istbA{0.05}[above,sloped]
        \endist
        \xtdistance{30mm}{30mm}
        \istroot[right](1)(0-2)<above>{1.1}
            \istbA{g_1\quad(\beta)}[above,sloped]
            \istbA{f_1\quad(1-\beta)}[above,sloped]{0,0}
        \endist
        \xtOwner(1){\makecell{$\langle\alpha\rangle$}}[below]
        \istroot[right](2)(0-1)<above>{1.1}
            \istbA(2){g_1\quad(\beta)}[above,sloped]
            \istbA{f_1\quad(1-\beta)}[above,sloped]{0,0}
        \endist
        \xtOwner(2){\makecell{$\langle1-\alpha\rangle$}}[below]
        \istroot[right](3)(1-1)<above>{2.2}
            \istbA{g_2\quad(\gamma)}[above,sloped]
            \istbA{f_2\quad(1-\gamma)}[above,sloped]{-1,5}
        \endist
        \xtOwner(3){\makecell{$\langle1\rangle$}}[below]
        \istroot[right](4)(3-1)<above>{1.3}
            \istbA{g_3\quad(\epsilon)}[above,sloped]
            \istbA{f_3\quad(1-\epsilon)}[above,sloped]{4,4}
        \endist
        \xtOwner(4){\makecell{$\langle\delta\rangle$}}[below]
        \istroot[right](5)(2-1)<above>{1.3}
            \istbA(2){g_3\quad(\epsilon)}[above,sloped]{8,8}
            \istbA{f_3\quad(1-\epsilon)}[above,sloped]{4,4}
        \endist
        \xtOwner(5){\makecell{$\langle1-\delta\rangle$}}[below]
        \istroot[right](6)(4-1)<above>{2.4}
            \istbA{g_4\quad(\zeta)}[above,sloped]{8,8}
            \istbA{f_4\quad(1-\zeta)}[above,sloped]{3,9}
        \endist
        \xtOwner(6){\makecell{$\langle1\rangle$}}[below]
        \xtInfosetO(1)(2)(1.2cm)
        \xtInfosetO(3)(3)(1.2cm)
        \xtInfosetO(4)(5)(1.2cm)
        \xtInfosetO(6)(6)(1.2cm)
    \end{istgame}
    \caption{}
\end{figure}
\end{document}

我想讓每個上行分支彼此平行,每個下行分支也彼此平行。 (如您所見,現在下行線不平行。)同時,兩個 1.1 節點需要對齊,兩個 1.3 節點也需要對齊。我該怎麼做呢?我真的很感謝任何幫助!

答案1

我對這個包不是很熟悉,但我查看了文檔,似乎沒有辦法指定替代(或弧)的角度\istbA;正如您所做的那樣,只有一種方法可以指定子項的分佈。

為了診斷目的,我製作了下圖: 原來的樹,被剝去

\documentclass[tikz,margin=10pt]{standalone}
\usepackage{istgame}
\usepackage{makecell}

\begin{document}
    \begin{istgame}
        \xtdistance{30mm}{90mm}
        \setxtinfosetstyle{dashed}
        \xtShowEndPoints

        \setistgrowdirection'{east}
        
        \istroot(0)<above>{0}
            \istbA{to:0-1}[above,sloped]
            \istbA{to:0-2}[above,sloped]
        \endist
        
        \xtdistance{30mm}{30mm}
        
        \istroot(1)(0-1)<above>{1}
            \istbA{to:1-1}[above,sloped]{end}
            \istbA{to:1-2}[above,sloped]
        \endist
        \xtOwner(1){\makecell{1label}}[below]
        
        \istroot(2)(0-2)<above>{2}
            \istbA{to:2-1}[above,sloped]{end}
            \istbA(2){to:2-2}[above,sloped]
        \endist
        \xtOwner(2){\makecell{2label}}[below]
        
        \istroot(3)(1-2)<above>{3}
            \istbA{to:3-1}[above,sloped]{end}
            \istbA{to:3-2}[above,sloped]
        \endist
        \xtOwner(3){\makecell{3label}}[below]
        
        \istroot(4)(3-2)<above>{4}
            \istbA{to:4-1}[above,sloped]{end}
            \istbA{to:4-2}[above,sloped]
        \endist
        \xtOwner(4){\makecell{4label}}[below]
        
        \istroot(5)(2-2)<above>{5}
            \istbA{to:5-1}[above,sloped]{end}
            \istbA(2){to:5-2}[above,sloped]{end}
        \endist
        \xtOwner(5){\makecell{5label}}[below]
        
        \istroot(6)(4-2)<above>{6}
            \istbA{to:6-1}[above,sloped]{end}
            \istbA{to:6-2}[above,sloped]{end}
        \endist
        \xtOwner(6){\makecell{6label}}[below]
        
        \xtInfosetO(1)(2)(1.2cm)
        \xtInfosetO(3)(3)(1.2cm)
        \xtInfosetO(4)(5)(1.2cm)
        \xtInfosetO(6)(6)(1.2cm)
    \end{istgame}
\end{document}

有一種方法可以添加“失踪”的孩子,使用\istb<missing>\istbm簡稱。不幸的是,很難說出角度是如何\istbA(<level>)計算的,因此即使使用這個精簡的模型,嘗試透過添加這些缺失的子項來對齊底行也被證明過於乏味。

相反,如果您願意犧牲對稱性,我提供以下解決方案: 替代樹,剝離

\documentclass[tikz,margin=10pt]{standalone}
\usepackage{istgame}
\usepackage{makecell}

\begin{document}
    \begin{istgame}
        \xtdistance{30mm}{60mm}
        \setxtinfosetstyle{dashed}
        \xtShowEndPoints

        \setistgrowdirection'{east}
        
        \istroot(0)<above>{0}
            \istbA{to:0-1}[above,sloped]
            \istbA{to:0-2}[above,sloped]
        \endist
        
        \xtdistance{30mm}{30mm}
        
        \istroot(1)(0-1)<above>{1}
            \istbA{to:1-1}[above,sloped]{end}
            \istbA{to:1-2}[above,sloped]
            \istbm
        \endist
        \xtOwner(1){\makecell{1label}}[below]
        
        \istroot(2)(0-2)<above>{2}
            \istbA{to:2-1}[above,sloped]{end}
            \istbA(2){to:2-2}[above,sloped]
            \istbm
        \endist
        \xtOwner(2){\makecell{2label}}[below]
        
        \istroot(3)(1-2)<above>{3}
            \istbA{to:3-1}[above,sloped]{end}
            \istbA{to:3-2}[above,sloped]
            \istbm
        \endist
        \xtOwner(3){\makecell{3label}}[below]
        
        \istroot(4)(3-2)<above>{4}
            \istbA{to:4-1}[above,sloped]{end}
            \istbA{to:4-2}[above,sloped]
            \istbm
        \endist
        \xtOwner(4){\makecell{4label}}[below]
        
        \istroot(5)(2-2)<above>{5}
            \istbA{to:5-1}[above,sloped]{end}
            \istbA(2){to:5-2}[above,sloped]{end}
            \istbm
        \endist
        \xtOwner(5){\makecell{5label}}[below]
        
        \istroot(6)(4-2)<above>{6}
            \istbA{to:6-1}[above,sloped]{end}
            \istbA{to:6-2}[above,sloped]{end}
            \istbm
        \endist
        \xtOwner(6){\makecell{6label}}[below]
        
        \xtInfosetO(1)(2)(1.2cm)
        \xtInfosetO(3)(3)(1.2cm)
        \xtInfosetO(4)(5)(1.2cm)
        \xtInfosetO(6)(6)(1.2cm)
    \end{istgame}
\end{document}

填寫後,看起來像 在此輸入影像描述

同樣,這並不理想,但如果您的目標是不惜一切代價並行的,那麼就可以實現。我建議添加[scale=1.2]或類似於\begin{istgame}縮放,但這是個人喜好。在下面的 MWE 中,您會注意到我刪除了[right]標籤並添加了標籤\setistgrowdirection'{east},這使得節點在程式碼中以合理的方式從上到下排列,至少在我看來是這樣。

希望這會有所幫助!

微量元素:

\documentclass[tikz,margin=10pt]{standalone}
\usepackage{istgame}
\usepackage{makecell}

\begin{document}
    \begin{istgame}
        \xtdistance{30mm}{60mm}
        \setxtinfosetstyle{dashed}
        \xtShowEndPoints

        \setistgrowdirection'{east}
        
        \istroot(0)<above>{0}
            \istbA{0.05}[above,sloped]
            \istbA{0.95}[above,sloped]
        \endist
        
        \xtdistance{30mm}{30mm}
        
        \istroot(1)(0-1)<above>{1.1}
            \istbA{f_1\quad(1-\beta)}[above,sloped]{0,0}
            \istbA{g_1\quad(\beta)}[above,sloped]
            \istbm
        \endist
        \xtOwner(1){\makecell{$\langle\alpha\rangle$}}[below]
        
        \istroot(2)(0-2)<above>{1.1}
            \istbA{f_1\quad(1-\beta)}[above,sloped]{0,0}
            \istbA(2){g_1\quad(\beta)}[above,sloped]
            \istbm
        \endist
        \xtOwner(2){\makecell{$\langle1-\alpha\rangle$}}[below]
        
        \istroot(3)(1-2)<above>{2.2}
            \istbA{f_2\quad(1-\gamma)}[above,sloped]{-1,5}
            \istbA{g_2\quad(\gamma)}[above,sloped]
            \istbm
        \endist
        \xtOwner(3){\makecell{$\langle1\rangle$}}[below]
        
        \istroot(4)(3-2)<above>{1.3}
            \istbA{f_3\quad(1-\epsilon)}[above,sloped]{4,4}
            \istbA{g_3\quad(\epsilon)}[above,sloped]
            \istbm
        \endist
        \xtOwner(4){\makecell{$\langle\delta\rangle$}}[below]
        
        \istroot(5)(2-2)<above>{1.3}
            \istbA{f_3\quad(1-\epsilon)}[above,sloped]{4,4}
            \istbA(2){g_3\quad(\epsilon)}[above,sloped]{8,8}
            \istbm
        \endist
        \xtOwner(5){\makecell{$\langle1-\delta\rangle$}}[below]
        
        \istroot(6)(4-2)<above>{2.4}
            \istbA{f_4\quad(1-\zeta)}[above,sloped]{3,9}
            \istbA{g_4\quad(\zeta)}[above,sloped]{8,8}
            \istbm
        \endist
        \xtOwner(6){\makecell{$\langle1\rangle$}}[below]
        
        \xtInfosetO(1)(2)(1.2cm)
        \xtInfosetO(3)(3)(1.2cm)
        \xtInfosetO(4)(5)(1.2cm)
        \xtInfosetO(6)(6)(1.2cm)
    \end{istgame}
\end{document}

答案2

我想使用\istb而不是使用\istbA.

您可能想替換\istbA(2)

\istbA(2)<grow=-27,level distance=67mm>

或只是為了使用

\istb<grow=-27,level distance=67mm>

此更改將給出您想要的(近似)結果。

在此輸入影像描述

\documentclass[leqno, oneside, 12pt]{book}
\usepackage{amsmath}
\usepackage{istgame}
\usepackage{caption}
\usepackage{makecell}

\begin{document}
\begin{figure}[ht]
\centering
\begin{istgame}[font=\footnotesize]
    %%% some calculation:
    \pgfmathparse{90-atan(30/15)}  
        \node(0,0)[draw,yshift=10mm]{\pgfmathresult};
    \pgfmathparse{sqrt(30^2+15^2)} 
        \node(0,0)[draw,yshift=15mm]{\pgfmathresult};
    %%% tree direction
    \setistgrowdirection{east}     %%% instead of using [right] in \istroot
    %\setistgrowdirection'{east}   %%% (swap version) looks more convenient

    %%% \istb (instead of \istbA)
    \xtdistance{30mm}{90mm}
    \setxtinfosetstyle{dashed}
    \xtShowEndPoints
    \istroot(0)<above>{0}
        \istb{0.95}[above,sloped]
        \istb{0.05}[above,sloped]
    \endist
    \xtdistance{30mm}{30mm}
    \istroot(1)(0-2)<above>{1.1}
        \istb{g_1\quad(\beta)}[above,sloped]
        \istb{f_1\quad(1-\beta)}[above,sloped]{0,0}
    \endist
    \xtOwner(1){\makecell{$\langle\alpha\rangle$}}[below]
    \istroot(2)(0-1)<above>{1.1}
        \istb<grow=-27,level distance=67mm>[blue,thick]  %%% CHANGED
             {g_1\quad(\beta)}[above,sloped]
        \istb{f_1\quad(1-\beta)}[above,sloped]{0,0}
    \endist
    \xtOwner(2){\makecell{$\langle1-\alpha\rangle$}}[below]
    \istroot(3)(1-1)<above>{2.2}
        \istb{g_2\quad(\gamma)}[above,sloped]
        \istb{f_2\quad(1-\gamma)}[above,sloped]{-1,5}
    \endist
    \xtOwner(3){\makecell{$\langle1\rangle$}}[below]
    \istroot(4)(3-1)<above>{1.3}
        \istb{g_3\quad(\epsilon)}[above,sloped]
        \istb{f_3\quad(1-\epsilon)}[above,sloped]{4,4}
    \endist
    \xtOwner(4){\makecell{$\langle\delta\rangle$}}[below]
    \istroot(5)(2-1)<above>{1.3}
        \istb<grow=-27,level distance=67mm>[blue,thick]  %%% CHANGED
             {g_3\quad(\epsilon)}[above,sloped]{8,8}
        \istb{f_3\quad(1-\epsilon)}[above,sloped]{4,4}
    \endist
    \xtOwner(5){\makecell{$\langle1-\delta\rangle$}}[below]
    \istroot(6)(4-1)<above>{2.4}
        \istb{g_4\quad(\zeta)}[above,sloped]{8,8}
        \istb{f_4\quad(1-\zeta)}[above,sloped]{3,9}
    \endist
    \xtOwner(6){\makecell{$\langle1\rangle$}}[below]
    \xtInfosetO(1)(2)(1.2cm)
    \xtInfosetO(3)(3)(1.2cm)
    \xtInfosetO(4)(5)(1.2cm)
    \xtInfosetO(6)(6)(1.2cm)
\end{istgame}
\caption{}
\end{figure}
\end{document}

相關內容