Skip to content

Spieltheorie Bäume, feste Knotengröße

Wir brauchen Ihre Hilfe, um unsere Schriften zur Informatik zu verbreiten.

Lösung:

Ich versuche, deinen Code zu bereinigen und füge die Option hn (hohler Knoten) zu Knoten hinzufügen, die im Kreis sind. für den Wurzelknoten schlage ich ein Rechteck mit abgerundeten Ecken vor. Die Endknoten würde ich nicht in einen Kreis setzen, eventuell würde ich einen grauen Hintergrund hinzufügen (in mwe . unten ist es für die letzten beiden Endknoten gezeigt). Wenn du solche Lösung magst, brauchst du nur den Knotenstil hinzufügen gn (grauer Knoten) zu allen Endknoten hinzufügen.

Da der Baum sehr breit ist, reduziere ich die Seitenränder auf 20 mm. Außerdem habe ich aus der Präambel alles entfernt, was nicht mit dem Baumdiagramm zusammenhängt.

documentclass[11pt]{article}
usepackage[margin=20mm]{geometry}
usepackage[skip=1ex]{caption}
usepackage{tikz}   %for game theory stuff

%---------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%

begin{document}

begin{figure}
    centering
    caption{Caption}

    begin{tikzpicture}[
          font = footnotesize,
     hn/.style = {circle, draw},
     gn/.style = {rounded corners, fill=gray!20, inner xsep=2pt},
level 1/.style = {level distance = 30mm,sibling distance=31mm},
level 2/.style = {level distance = 20mm,sibling distance=10mm},
level 4/.style = {level distance =  5mm},
level 5/.style = {level distance = 20mm}
                        ]
node[draw, rounded corners] {Nature}
    child {node (1) [hn] {P1}
      child {node (7) {$-1, 1$}
            edge from parent node[left] {c}
            }
    child {
        child{
            child{ node (8) [hn] {P2}
        child {node (27) {$1,-1$}
            edge from parent node[left] {f}}
        child {node (28){$-2,2$}
            edge from parent node[right] {c}}
                }
        edge from parent node[right] {r}}
            }
    edge from parent node[left=1mm] {$JQK$}
                     node[left=1mm, pos=0.25] {$p_1$}
        }
    child {node (2) [hn] {P1}
        child {node (9) {$-1, 1$}
            edge from parent node[right] {c}
               }
        child {node (10) [hn] {P2}
            child {node (19) {$1,-1$}
                edge from parent node[right, pos=0.6, xshift=-15] {f}}
            child {node (20) {$-2,2$}
                edge from parent node[right, pos=0.6, xshift=2] {c}
                  }
            edge from parent node[right, pos=0.6, xshift=2] {r}
            }
        edge from parent node[left=1mm] {$JKQ$}
                         node[left=1mm, pos=0.3] {$p$}
            }
   child {node (3) [hn] {P1}
      child {node (11) [hn] {P2}
        child {node (21) {$1,-1$}
            edge from parent node[right=1mm] {f}}
            child {node (22) {$-2,2$}
                edge from parent node[right=1mm] {c}}
            edge from parent node[right=1mm] {r}}
    child {node(12) {$-1,1$}
        edge from parent node[right, pos=0.6, xshift=2] {c}
           }
        edge from parent node[left=1mm] {$QKJ$}
                         node[left=1mm, pos=0.35] {$p$}
        }
   child {node (4) [hn] {P1}
      child {node (13) {$1,-1$}
        edge from parent node[right=1mm] {c}
            }
    child {node(14) [hn] {P2}
        child {node (23) {$1,-1$}
            edge from parent node[right=1mm] {f}}
            child {node (24) {$2,-2$}
                edge from parent node[right=1mm] {c}
                }
            edge from parent node[right=1mm] {r}
            }
        edge from parent node[right=1mm] {$QJK$}
                         node[right=1mm, pos=0.35] {$ p$}
        }
    child {node (5) [hn] {P1}
        child {node (15) [hn] {P2}
            child {node (25){$1,-1$}
                edge from parent node[right=1mm] {f}
                  }
            child {node (26) {$2,-2$}
                edge from parent node[right=1mm] {c}
                  }
            edge from parent node[right=1mm] {r}}
            child {node(16) {$1,-1$}
                edge from parent node[right=1mm] {c}
                 }
            edge from parent node[right=1mm] {$KJQ$}
                             node[right=1mm, pos=0.3] {$p$}
        }
   child {node (6) [hn] {P1}
      child{
        child{
            child {node (17) [hn] {P2}
            child {node (27) [gn]  {$1,-1$}
                edge from parent node[right=1mm] {r}
                    }
            child {node [gn] {$2,-2$}
                edge from parent node[right=1mm] {c}
                    }
                }
        edge from parent node[right=1mm] {r}
            }}
    child {node(18) {$1,-1$}
        edge from parent node[right=1mm] {c}
            }
        edge from parent node[right=1mm] {$KQJ$}
                         node[right=1mm,pos=0.25] {$p$}
        };
draw[dashed]   (1)  -- (2)
                (3)  -- (4)
                (5)  -- (6)
                (10) -- (11)
                (14) -- (15)
                (8)  -- (17);
    end{tikzpicture}
end{figure}

enter image description here

(rote Linien zeigen Textgrenzen an)

Eine andere Lösung ist die Verwendung des istgame Paket (Version 2).

enter image description here

documentclass{standalone}

usepackage{amsmath}
defvpay#1#2{begin{matrix}#1\#2end{matrix}}

usepackage{istgame}

begin{document}

begin{istgame}[scale=.8,font=footnotesize]
xtShowEndPoints % solid nodes
setistEllipseNodeStyle{6mm} % minimum circle size for players
xtdistance{30mm}{30mm}
istrooto(0){Nature}
  istB{JQK}[l]{p_1}[left,near start,xshift=-5pt]
  istB{JKQ}[l]{p}[left,near start]
  istB{QJK}[l]{p}[left,near start]
  istB{QJK}[r]{p}[right,near start]
  istB{KJQ}[r]{p}[right,near start,xshift=5pt]
  istB{KQJ}[r]{p}[right,near start,xshift=5pt]
  endist
xtdistance{25mm}{10mm}
istrooto(1)(0-1){$P_1$}
  istb{c}[l]{vpay{-1}{1}} istb{r}[r] endist
istrooto(2)(0-2){$P_1$}
  istb{c}[l]{vpay{-1}{1}} istb{r}[r] endist
istrooto(3)(0-3){$P_1$}
  istb{r}[l] istb{c}[r]{vpay{-1}{1}} endist
istrooto(4)(0-4){$P_1$}
  istb{c}[l]{vpay{1}{-1}} istb{r}[r] endist
istrooto(5)(0-5){$P_1$}
  istb{r}[l] istb{c}[r]{vpay{1}{-1}} endist
istrooto(6)(0-6){$P_1$}
  istb{r}[l] istb{c}[r]{vpay{1}{-1}} endist
xtdistance{20mm}{10mm}
istrooto(a)(2-2){$P_2$}
  istb{f}[l]{vpay{1}{-1}} istb{c}[r]{vpay{-2}{2}} endist
istrooto(b)(3-1){$P_2$}
  istb{f}[l]{vpay{1}{-1}} istb{c}[r]{vpay{-2}{2}} endist
istrooto(c)(4-2){$P_2$}
  istb{f}[l]{vpay{1}{-1}} istb{c}[r]{vpay{2}{-2}} endist
istrooto(d)(5-1){$P_2$}
  istb{f}[l]{vpay{1}{-1}} istb{c}[r]{vpay{2}{-2}} endist
xtdistance{28mm}{25mm}
istrooto(A)(1-2){$P_2$}
  istb[draw=red]{f}[l]{vpay{1}{-1}} istb[draw=blue]{c}[r]{vpay{-2}{2}} endist
istrooto(B)(6-1){$P_2$}
  istb[double]{f}[l]{vpay{1}{-1}} istb[ultra thick]{c}[r]{vpay{2}{-2}} endist
% information sets
setxtinfosetstyle{dashed}
xtInfoset(1)(2)
xtInfoset(3)(4)
xtInfoset(5)(6)
xtInfoset(a)(b)
xtInfoset(c)(d)
xtInfoset(A)(B)
end{istgame}

end{document}

Wir zeigen Ihnen Kommentare und Bewertungen


Tags : /

Nutzen Sie unsere Suchmaschine

Suche
Generic filters

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.