# How to colorize only one of the three branches in a game tree?

I am using Osborne's egameps package to create a game tree of an extensive game. How could I colorize only the right branch of the tree branch in the first movement as red. I attempted to use \iiib[][][linecolor=red]{$X$}{$Y$}{$Z$}, as I deal with the two-branch situation, but it doesn't colorize anything, and disturbs the entire game tree. What should I do?

Here is the code:

\documentclass[12pt]{scrartcl}
\usepackage{pstricks,egameps}
\usepackage{pst-3d}% Above two packages are for extensive games

\begin{figure}[htb]%
\hspace*{\fill}%
\begin{egame}(810,290)
\putbranch(360,250)(3,1){360}
\egalvshift=5
\iiib[][][linecolor=red]{1}{$X$}{$Y$}{$Z$}
\putbranch(0,130)(1,1){90}
\egalhshift=18
\iib{2}{$Y$}{$Z$}[$0,2$][$1,1$]
\putbranch(360,130)(1,1){90}
\egalhshift=18
\iib{2}{$X$}{$Z$}[$0,2$][$2,0$]
\putbranch(720,130)(1,1){90}
\egalhshift=18
\iib[linecolor=red][]{2}{$Z$}{$Y$}[$1,1$][$2,0$]
\end{egame}
\hspace*{\fill}%
\caption[]{An extensive game.}\label{f:se1}
\end{figure}

-
Welcome to TeX.sx. Could you extend your code to a minimal working example (MWE) (i.e. the preamble)? Would you consider using another package to do this kind of thing? A lot of the things I see in the manual can be done with TikZ/forest. How do you diagrams look like? – Qrrbrbirlbel Nov 8 '13 at 6:48
@Qrrbrbirlbel There were only two packages (actually only the \usepackage{pstricks,egameps} one) is used in this code, as shown in the updated code part. Could you show me how to use TikZ to colorize only one branch in the first move? Thank you. – user39691 Nov 9 '13 at 3:26

A version after receiving additional information.

\documentclass{article}
\usepackage{pstricks}
\usepackage{egameps}

\begin{document}

\begin{figure}[\htb]%
\hspace*{\fill}%
\begin{egame}(810,290)
\putbranch(360,250)(3,1){360}
\egalvshift=5
%\iiib[][][linecolor=red]{1}{$X$}{$Y$}{$Z$}
\iiib{1}{$X$}{$Y$}{$Z$}
\ib[linecolor=red]{1}{}
\putbranch(0,130)(1,1){90}
\egalhshift=18
\iib{2}{$Y$}{$Z$}[$0,2$][$1,1$]
\putbranch(360,130)(1,1){90}
\egalhshift=18
\iib{2}{$X$}{$Z$}[$0,2$][$2,0$]
\putbranch(720,130)(1,1){90}
\egalhshift=18
\iib[linecolor=red][]{2}{$Z$}{$Y$}[$1,1$][$2,0$]
\end{egame}
\hspace*{\fill}%
\caption[]{An extensive game.}\label{f:se1}
\end{figure}

\end{document}


-
Sorry, but what I need is only making the right branch(or anyone branch) of the three branches in the first move in red, rather than all of them in red. @Przemysław Scherwentke – user39691 Nov 9 '13 at 3:28
@user39691 I hope that a new version is closer to your expectations. – Przemysław Scherwentke Nov 9 '13 at 3:49
It works! Very nice! Thank you very much! And an additionally question: if I want the left or the middle branch to be in red, what can I do? I tried to move the \ib[linecolor=red]{1}{} to different positions around \iiib{1}{$X$}{$Y$}{$Z$}, or used \iib[linecolor=red]{1}{}, but non of them works... @Przemysław Scherwentke – user39691 Nov 9 '13 at 4:47
@user39691 Alas, \iiib has not three style parameters, so I am afraid that your tree should be build of trees with one or two branches (the trick with making a node initial again). – Przemysław Scherwentke Nov 9 '13 at 5:20

It is probably possible to get the last level (at least for a simple tree) from forest directly but for now, you need to give it manually.

The egame style sets a few styles only for this tree. Comments in code.

## Code

\documentclass[tikz]{standalone}
\usepackage{forest}
\tikzset{
edge label style/.style={text=.,font=\scriptsize,inner sep=+.1667em,midway,yshift=+1mm}}
\forestset{
label position/.code=\forestoset{label position}{#1},
last level/.initial=-1, % set it!
egame/.style={
/tikz/every label/.append style={inner sep=+.1em,font=\scriptsize},
el/.style={% short for "edge label"
if={n()<=\forestOve{\forestove{@parent}}{n children}/2}
{edge label={node[edge label style, left] {$##1$}}}
{edge label={node[edge label style, right]{$##1$}}}},
for tree={
label position=above,% default label position
if={level==\pgfkeysvalueof{/forest/last level}}{% last level?
delay={content/.expanded={$\forestov{content}$}}% put content in math
}{
node options={% a black dot
shape=circle,
fill, draw, inner sep=+0pt,
minimum size=+2pt},
delay={
label/.expanded=% level as label
{\forestove{label position}:\noexpand\pgfmathprint{int(level()+1)}}}
}}}}
\begin{document}
\begin{forest} last level=2, egame
[
[,        el=X,
[{0,2}, el=Y]
[{1,1}, el=Z] ]
[,        el=Y, label position=above right
[{0,2}, el=X]
[{2,0}, el=Z] ]
[,        el=Z, edge=red
[{1,1}, el=Z, edge=red]
[{2,0}, el=Y] ]
]
\end{forest}
\end{document}


## Output

-

A recommended solution with PSTricks.

\documentclass[preview,border=12pt]{standalone}

\usepackage{pst-tree}

\def\red{\ncline[linecolor=red]}
\def\lbl#1#2{\nput{#1}{\pssucc}{$#2$}}% \nput will not update the bounding box!

\begin{document}
\psTree{\TC*~[tnpos=a]{1}}
\psset{levelsep=1}
\psTree{\TC*\lbl{135}{2}\tlput{$X$}}
\Tp*~{$0,2$}\tlput{$Y$}
\Tp*~{$1,1$}\trput{$Y$}
\endpsTree
\psTree{\TC*\lbl{45}{2}\trput{$Y$}}
\Tp*~{$0,2$}\tlput{$X$}
\Tp*~{$2,0$}\trput{$Z$}
\endpsTree
\psTree{\TC*[edge=\red]\lbl{45}{2}\trput{$Z$}}
\Tp*[edge=\red]~{$1,1$}\tlput{$Z$}
\Tp*~{$2,0$}\trput{$Y$}
\endpsTree
\endpsTree
\end{document}


## Notes

• \nput can be used to label a tree node. Unfortunately, it will not update the bounding box. It should not be used.
• ~[]{} is another syntax to label a tree node. It will update the bounding box. But, unfortunately, tnpos can only accept 4 preset values: a for above, b for bottom, l for left, and r for right. It does not support an arbitrary angle such as 45 degree. A sad news!
-