%!TEX root = istgame-doc.tex

%\begin{document}
\setcounter{section}{-1}

\section{Changes}

A considerable number of macro names have been changed in the version 0.8 (Jan.\@ 17, 2017) of this package.\footnote{The \pkg{istgame} package of the version which is older than ver.\@ 1.0 had been distributed in the KTUG (Koran TeX Users Group).}
The following old macro names in any previously written documents using codes in \pkg{istgame} ver.\@ 0.7 or before, should be replaced by the new names, accordingly. 

Also, \cmd{\istroot*}, \cmd{\istcntm*}, and \cmd{\xtInfoset*} should be replaced by \cmd{\istrooto}, \cmd{\istcntmarc}, and \cmd{\xtInfoseto}, respectively, in the version 1.0 or later.

\begin{center}
\begin{tabu}to\linewidth{X[l4]X[l3]X[l2]}  \toprule
\makecell[l]{\textbf{ver.\@ 0.7 or before}}  & \makecell[l]{\textbf{ver.\@ 0.8 or later}} & \makecell[l]{\textbf{ver.\@ 1.0 or later}}\\\midrule
\cmd{\xdistance}     & \cmd{\xtdistance}     & \\\tabucline-
\cmd{\xDot}          &\cmd{\xtNode}          & \\\tabucline-
\cmd{\xInfoset}      &\cmd{\xtInfoset}       & \\\tabucline-
\cmd{\xInfoset*}     &\cmd{\xtInfoset*}      & \\\tabucline-
\cmd{\xInfosetOwner} &\cmd{\xtInfosetOwner}  & \\\tabucline-
\cmd{\xActionLabel}  &\cmd{\xtActionLabel}   & \\\tabucline-
\cmd{\xPayoff}       &\cmd{\xtPayoff}        & \\\tabucline-
\cmd{\ShowTerminalNodes}         &\cmd{\xtShowTerminalNodes} & \\\tabucline-
\cmd{\HideTerminalNodes}         &\cmd{\xtHideTerminalNodes} & \\\tabucline-
\cmd{\levdist}       &\cmd{\xtlevdist}       & \\\tabucline-
\cmd{\sibdist}       &\cmd{\xtsibdist}       & \\\tabucline-
\cmd{\setistactionlabelshift}    &   ~       & \cmd{\xtALPush} \\\tabucline-
\cmd{\setistactionlabelposition} &   ~       & \cmd{\xtALShift} \\\tabucline-
\cmd{\istroot*}      &                       & \cmd{\istrooto} \\\tabucline- 
\cmd{\istcntm*}      &                       & \cmd{\istcntmarc} \\\tabucline- 
\cmd{\xtInfoset*}    &                       & \cmd{\xtInfosetO} \\\bottomrule
\end{tabu} 
\end{center}

Here, the prefix `xt' stands for `extensive tree,'
so \cmd{\xtdiatnace} can be read as `extensive tree distance.'


\bigskip
\bigskip

\remark A known problem with the \pkg{tikz-qtree} package:

It seems that 
\pkg{tikz-qtree} changes node anchors.
So, with the \pkg{tikz-qtree} uploaded, you will get unexpected results
when you draw a game tree by using the \xw{tree} library in \tikz.
Since \pkg{istgame} is based on the \xw{tree} library, it is also affected by \pkg{tikz-qtree}, resulting in unexpected outputs.

The best way to resolve this problem is that you DO NOT LOAD \pkg{tikz-qtree} when you draw game trees with \tikz.
If, for some reason, you need to load \pkg{tikz-qtree} when you draw a game tree by using the \pkg{istgame} package, a temporary solution to resolve the conflict is to redefine the \pkg{istgame} environment as follows:

\begin{tcblisting}{listing only}
\RenewDocumentEnvironment{istgame}{O{}}   % accepts tikzpicture options
    {\begin{tikzpicture}[%
        edge from parent path={(\tikzparentnode\istparentanchor) -- 
        (\tikzchildnode\istchildanchor)}, % tikz-qtree conflict resolved
        font=\istgamefontsize,>=stealth,#1
        ]
    }
    {\end{tikzpicture}
    }
\end{tcblisting}

\clearpage

\section{Getting started}

The package \ipkg{istgame} provides macros built on \tikz\ to draw game trees. The core macros provided with this package are \icmd{\istroot}, \icmd{\istb}, and \icmd{\endist}. 
\cmd{\istroot} pins down the root of a tree or a subtree, \cmd{\istb} represents a branch, and \cmd{\endist} indicates the end of drawing a simple tree. Without \cmd{\endist}, the tree is not actually drawn, with no error messages produced.
A tree drawn by the sequence of \cmd{\istroot-}\cmd{\istb-}\cmd{\endist} is a \ixw{simple tree}. 
You can draw a whole game tree by repeatedly connecting these `simple tree structures.'

\mbigskip1

Here, the prefix `ist' stands for `it's a simple tree.' You can also read it as `insung's simple tree' if you would like.

\mbigskip1

The package \pkg{istgame} depends on the packages \ipkg{tikz}, \ipkg{xparse}, and \ipkg{expl3}.

To use the \pkg{istgame} package you must load the package in the preamble of your document:

\quad \cmd{\usepackage\{istgame\}}

The package loads the following \tikz\ libraries:

\quad \verb+calc,arrows,shapes,positioning,patterns,trees,fit,backgrounds,quotes+


\subsection{Getting-started example: a simple tree}

Let us get started with a simple self-explanatory example:

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
%% \usepackage{istgame}
% Example: a simple tree
\begin{istgame}
\istroot(0)(0,0) % names the root as (0) at (0,0)
  \istb % endpoint will be (0-1), automatically
  \istb % endpoint will be (0-2), automatically
  \istb % endpoint will be (0-3), automatically
  \endist % end of simple (parent-child) structure
\end{istgame}
\end{tcblisting}

The resulting tree has the height of 15mm and 
the distance between two neighbor endpoints (not shown) is also 15mm by default.
In \tikz, the height is called the \ixw{level distance} and 
the distance between two neighbor endpoints is called the \ixw{sibling distance}.

If the second parenthesis argument of \cmd{\istroot} is omitted, it is regarded as (0,0) by default, 
otherwise it is necessary to specify the coordinate from which a simple tree starts.

\subsection{Connecting simple tree structures}

Basically, in order to draw a whole game tree, we just repeat the simple \verb|\istroot-\istb-\endist| structure.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: connecting simple trees
\begin{istgame}
\istroot(0) % names the root (0) at (0,0)
  \istb % endpoint will be (0-1), automatically
  \istb % endpoint will be (0-2)
  \istb % endpoint will be (0-3)
  \endist % end of simple (parent-child) structure
\istroot(c)(0-3) % names the subroot (c) at (0-3)
  \istb % endpoint will be (c-1)
  \istb % endpoint will be (c-2)
  \endist
\end{istgame}
\end{tcblisting}

In the previous example, the simple `subtree' is rooted at \xw{(0-3)}, names the subroot \xw{(c)}, and has two branches whose endpoints are automatically named \xw{(c-1)} and \xw{(c-2)}, respectively. 

Note that the given names of the (sub)roots and the names of endpoints are given counterclockwise (from the left to the right) by \tikz\ at the endpoints of branches, which can be used as coordinates in the usual \tikz\ way.

\subsection{Complete examples for desperate users}

Basically, \cmd{\istroot} designates a decision node and its owner (or a player),
\cmd{\istb} prints a branch coming from the decision node with action labels and payoffs, and \cmd{\endist} actually draws the tree structures.

\mbigskip1

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth,breakable}
% Example: first try
\begin{istgame}
\xtdistance{15mm}{30mm}
\istroot(0)(0,0){Child}
  \istb{Good}[above left]{(0,2)}
  \istb{Bad}[above right]
  \endist
\istroot(1)(0-2)<30>{Parent}
  \istb{Forgive}[above left]{(1,1)}
  \istb{Punish}[above right]{(-1,-1)}
  \endist 
\end{istgame}
\end{tcblisting}

\subsubsection{How to put a decision node and its owner}

\begin{tcblisting}{listing only}
\istroot(<decision node name>)(<root location>)<owner position>{<owner>}
\end{tcblisting}

The only mandatory argument of \icmd{\istroot} is \xw{(<decision node name>)} and all others are optional.
If the \xw{(<location>)} where a decision node is placed is omitted, it is regarded as \xw{(0,0)} by default.
The position of the owner is \xw{<above>} (or equivalently, \xw{<90>}) degree by default.

In fact, \cmd{\istroot} and its variations have much more functions than these. Later, you can look into section \ref{sec:istroot} for more details.

\subsubsection{How to put action labels and payoffs}

\begin{tcblisting}{listing only}
\istb{<action label>}[<action pos>]{<payoffs>}[<payoff pos>]
\end{tcblisting}

With the macro \icmd{\istb}, you can put a action label and payoffs as optional arguments.
The positions of an action label and payoffs are specified as options right after each of the two.

In fact, \cmd{\istb} and its variations have much more functions than these. See section \ref{sec:istb} for more details. If this is your first reading this manual, however, you don't need to bother about all the details at the moment.

\subsubsection{How to put information sets}

\begin{tcblisting}{listing only}
\xtInfoset(<from coor>)(<end coor>){<owner>}
\end{tcblisting}


The macro \icmd{\xtInfoset} connects two nodes with a dotted line.
The two node coordinates are mandatory.
For more details about \cmd{\xtInfoset}, see section \ref{sec:infoset}.

\mbigskip1
In the following example, the macro \cmd{\xtInfoset} is used to show a information set.
\xw{[al]} is an abbreviation of \xw{[above left]}, and similarly for \xw{[ar]}, \xw{[bl]}, and \xw{[br]}.

\begin{tcblisting}{listing outside text, righthand width=.35\linewidth}
% Example: information set
\begin{istgame}
\xtdistance{15mm}{30mm}
\istroot(0){Alice}
  \istb{A}[al]{(2,2)} \istb{D}[ar]
  \endist 
\istroot(1)(0-2)<above right>{Alice}
  \istb{L}[al] \istb{R}[ar]
  \endist 
\xtdistance{10mm}{20mm}
\istroot(2)(1-1)
  \istb{\ell}[al]{(4,2)} \istb{r}[ar]{(1,1)}
  \endist 
\istroot(3)(1-2)
  \istb{\ell}[al]{(3,2)} \istb{r}[ar]{(0,3)}
  \endist 
\xtInfoset(2)(3){Elaine}
\end{istgame}
\end{tcblisting}




\section{Important distances: \protect\cmd{\xtdistance}}

\label{sec:xtdistance}

The length and the direction of branches in a simple tree can be controlled by the macro \icmd{\xtdistance}. 
Here, the prefix `xt' stands for `extensive tree.'

\begin{tcblisting}{listing only}
% syntax: \xtdistance
    \xtdistance[<level depth>]{<level dist>}{<sibling dist>}
% defaults: <level dist> is the only mandatory argument
    [1]{15mm}{15mm}
\end{tcblisting}

\cmd{\xtdistance} sets or resets the level and sibling distances.
You can use \cmd{\xtdistance} at any time you want to change the length and the direction of branches.
Since we are dealing with simple `parent-child' tree structures, \xw{<level depth>} is \xw{1} by default.
However, the level depth number other than 1 is not expected to be used.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: \xtdistance
\begin{istgame}
\xtdistance{15mm}{15mm} % default
\istroot(0) % names the root (0) at (0,0)
  \istb % endpoint will be (0-1), automatically
  \istb % endpoint will be (0-2)
  \istb % endpoint will be (0-3)
  \endist % end of simple (parent-child) structure
\xtdistance{15mm}{30mm} % changes sibling dist
\istroot(a)(0-1) % names the subroot (a) at (0-1)
  \istb % endpoint will be (a-1)
  \istb % endpoint will be (a-2)
  \endist
\istroot(a)
\end{istgame}
\end{tcblisting}

For example, \cmd{\xtdistance\{20mm\}\{30mm\}} internally assigns \xw{20mm} to \icmd{\xtlevdist} and \xw{30mm} to \icmd{\xtsibdist}, which renews the default distances.

\mbigskip1
In fact, the core macros are much more powerful. \cmd{\istroot} controls the direction to which a simple parent-child tree grows, 
node styles, the node owner and its position, the height and sibling distance of a current simple tree, etc.
\cmd{\istb} specifies the growing direction of an individual branch, branch line styles, branch color, the label of action, and the payoffs and their positions. 
Below we will see in more detail how the core macros and others work.


\section{The \env{istgame} environment and node styles}

\subsection{The \env{istgame} environment}

\label{ssec:envistgame}

This package provides the \ienv{istgame} environment, which is almost the sane as \ienv{tikzpicture} environment,
so this accepts all the options of the \env{tikzpicture} environment.

\mbigskip1
\begin{tcblisting}{listing only}
% definition: istgame environment
\def\istgamefontsize{\normalsize}
\NewDocumentCommand\setistgamefontsize {m} 
    {\renewcommand*{\istgamefontsize}{#1}
    }
\NewDocumentEnvironment{istgame}{O{}}   % accepts tikzpicture options
    {\begin{tikzpicture}[font=\istgamefontsize,>=stealth,#1]
    }
    {\end{tikzpicture}
    }
\end{tcblisting}

The default font size is set as \verb|font=\normalsize|. 
You can globally change the default font size by using \icmd{\setistgamefontsize}, like 
\verb|\setistgamefontsize{\scriptsize}|.
Since the environment \env{istgame} is basically the same as \env{tikzpicture}, you can also locally change the font size by using the \xw{font} option key, like
\verb|\begin{istgame}[font=\scriptsize]...\end{istgame}|. 


\subsection{Node styles}

\label{sec:nodestyles}

The \cmd{tikzstyle}'s of the six basic node styles are predefined.

\begin{itemize}\tightlist
\item \ixw{plain node}: draws nothing (defaults: \xw{inner sep=1pt}, \xw{outer sep=0pt})
\item \ixw{null node}: \begin{istgame}\istroot(0)[null node]\endist\end{istgame} (very small node, not expected to be used)
\item \ixw{solid node}: \begin{istgame}\istroot(0)[solid node]\endist\end{istgame} (default node style)
\item \ixw{hollow node}: \begin{istgame}\istroot(0)[hollow node]\endist\end{istgame}
\item \ixw{rectangle node}: \begin{istgame}\istroot(0)[rectangle node]\endist\end{istgame}
\item \ixw{ellipse node}: \begin{istgame}\istroot(0)[ellipse node]\endist\end{istgame}
\end{itemize}


For some special cases, you may want to change some node styles, including the minimum size. This can be done by \icmd{\setist<...>NodeStyle}, all of whose arguments are optional.

\begin{verbatim}
syntax:
  \setistPlainNodeStyle{<inner sep dim>}{<outer sep dim>}
  \setistNullNodeStyle[<draw color>]{<min-size dim>}[<bg color>][<opacity>]
  \setistSolidNodeStyle[<draw color>]{<min-size dim>}[<bg color>][<opacity>]
  \setistHollowNodeStyle[<draw color>]{<min-size dim>}[<bg color>][<opacity>]
  \setistRectangleNodeStyle[<draw color>]{<min-size dim>}[<bg color>][<opacity>]
  \setistEllipseNodeStyle[<draw color>]{<min-size dim>}[<bg color>][<opacity>]
\end{verbatim}


\begin{tcblisting}{listing outside text, righthand width=.1\linewidth}
% Examples:
\begin{istgame}\setistSolidNodeStyle[blue]{10pt}
    \istroot(0)[solid node]\endist\end{istgame}\\[1ex]
\begin{istgame}\setistHollowNodeStyle[blue]{10pt}[yellow]
    \istroot(0)[hollow node]\endist\end{istgame}\\[1ex]
\begin{istgame}\setistRectangleNodeStyle{10pt}[red][.5]
    \istroot(0)[rectangle node]\endist\end{istgame}\\[1ex]
\begin{istgame}\setistEllipseNodeStyle[blue]{10pt}[green]
    \istroot(0)[ellipse node]\endist\end{istgame}\\[1ex]
\begin{istgame}\setistNullNodeStyle[blue!20]{10pt}
    \istroot(0)[null node]\endist\end{istgame}
\end{tcblisting}

\mbigskip1

These basic node styles have their aliases, for convenience, for those who are familiar with game theoretic terminology.

\begin{tcblisting}{listing only,breakable}
% aliases for game theorists
\tikzstyle{decision node}=[solid node]  % decision nodes
\tikzstyle{terminal node}=[solid node]  % terminal nodes
\tikzstyle{initial node}=[hollow node]
\tikzstyle{chance node}=[hollow node]
\end{tcblisting}

The set of all nodes of a game tree can be partitioned into
the set of \xw{decision nodes}\index{decision node} and that of \xw{terminal nodes}\index{terminal node}.
You can use \ixw{initial node}
to distinguish the \ixw{root} (or the \xw{initial node}) of a game tree from decision nodes.
You can also use \ixw{chance node} to represent a chance node of a game tree.

%You can also change the node styles, like \verb|\setistDecisionNodeStyle[blue]{3pt}|.

Additional convenient node aliases are also provided: \ixw{box node}, \ixw{square node}, and \ixw{oval node}.

\begin{tcblisting}{listing only,breakable}
% some more aliases
\tikzstyle{box node}=[rectangle node]
\tikzstyle{square node}=[rectangle node]
\tikzstyle{oval node}=[ellipse node]
\end{tcblisting}

For aliases, you can also change the node styles, like \verb|\setistDecisionNodeStyle[blue]{3pt}| or \verb|\setistBoxNodeStyle{3pt}[green][.5]|.

\section{Core macro: \protect\cmd{\istroot}}

\label{sec:istroot}

\subsection{\protect\cmd{\istroot}: basics}

\subsubsection{\protect\cmd{\istroot} -- counterclockwise (standard version)}

\label{ssec:istroot}

The macro \cmd{\istroot} defines the root of a game or a subgame at a designated location, specifies the owner of the (sub)root, and does other functions.
In game theoretic terminology, \cmd{\istroot} designates a decision node and its owner (or a player).

\begin{tcblisting}{listing only,breakable}
% \istroot
% syntax: 
  \istroot[<grow keyval>,<opt>](<coor1>)(<coor2>)[<node style>,<opt>]%
           <owner label angle>{<owner>}+<lev-distance>..<sib-distance>+
% defaults: 
  [south]()(0,0)[decision node]<above>{}+15mm..15mm+
% arguments: (coor1) is mandatory, all others are optional arguments
  [grow] % the direction of growing <default: south>
  (coor1) % name of the (sub)root: mandatory
  (coor2) % the (sub)root is at (coor2) <default: (0,0)>
  [node style] % node style <default: decision node> 
  <angle> % position of owner name <default: above> 
  {owner} % name of the owner of the (sub)root
  +level dist..sibling dist+ % <defaults: 15mm,15mm>
\end{tcblisting}

The only mandatory argument of \cmd{\istroot} is \xw{(<coor1>)}, which gives the name of the root or subroot. All the other arguments are optional. The name of the (sub)root, \xw{(<coor1>)}, can be referred as a normal coordinate.
\xw{(coor2)} specifies the location where the (sub)root is placed.
If \xw{(coor2)} is omitted, it is regarded as \xw{(0,0)} by default.

The default node style of the root is a \xw{decision node}, which is just a solid node. You can change the node style to, for example, an \xw{oval node} or a \xw{box node}.

The owner of a decision node (or a player) is expressed with curly braces.
The position of the owner of a decision node is specified with angle brackets, like \xw{<90>}, \xw{<above>}, or \xw{<north>}.
To specify the position of the owner you can use \xw{<degrees>}, or the compass directions such as \xw{<north>}, \xw{<south>}, \xw{<east>}, \xw{<west>}, and their valid combinations.
You can also use the positional words such as \xw{<above>}, \xw{<below>}, \xw{<left>}, \xw{<rigth>}, and their valid combinations.

%\mbigskip1

Here is a simple example of drawing a tree structure.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: \istroot
\begin{istgame}
\istroot(0)
  \istb  \istb  \istb \endist
\istroot(a)(0-1)
  \istb  \istb  \endist
\end{istgame}
\end{tcblisting}

In the previous example, the game tree has the root named \xw{(0)}, located at \xw{(0,0)} by default, which has three branches.
Since \tikz\ arranges branches of a tree counterclockwise, by default,
the endpoints of the three branches are automatically named \xw{(0-1)}, \xw{(0-2)}, and \xw{(0-3)} from left to right or counterclockwise.

The root of the subtree is named \xw{(a)}, located at \xw{(0-1)}, and has two children.
Its children are automatically named \xw{(a-1)} and \xw{(a-2)} \ixw{counterclockwise} (or from left to right if the tree grows down).
See the following code example with explanatory labels to see what is going on.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: \istroot (explained with labels)
\begin{istgame}[font=\scriptsize]
\istroot(0)
  \istb  \istb  \istb \endist
\istroot(a)(0-1)
  \istb  \istb  \endist
%% labels: (ignore the following lines at the moment)
\xtOwner(0){(0)}
\xtOwner(0-1){(0-1)}[r]
\xtOwner(0-2){(0-2)}[b]
\xtOwner(0-3){(0-3)}[b]
\xtOwner(a){(a)}[l]
\xtOwner(a-1){(a-1)}[b]
\xtOwner(a-2){(a-2)}[b]
\draw [->,ultra thick,blue!20](-260:1.5) 
  arc (-260:80:1.5cm)
  node [above,blue!30] {counterclockwise};
\end{istgame}
\end{tcblisting}
\label{page:clockwise}


\mbigskip1

Internally, \xw{[<grow keyval>]} typed in as the first option of \cmd{\istroot} renews the direction of tree growing by assigning its value to \icmd{\istgrowdirection}, whose default is \xw{south}.

\mbigskip1

\remark For some cases, you may want to use options other than the grow direction, in the bracket before \xw{(coor1)}. In this case, the first thing in the bracket must be \xw{<grow keyval>}, like \xw{[south,blue,dashed]} (see section \ref{sec:firstthing} on page \pageref{sec:firstthing}).

\mbigskip1

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example 1: \istroot (one simple tree)
\begin{istgame}[font=\itshape]
\istroot[right](0)<left>{player 1}
  \istb  \istb  \endist
\end{istgame}
\end{tcblisting}
\label{page:onesimpletree}


\mbigskip1
The tree growing direction can be specified by \xw{[<degrees>]} or by using the compass directions such as 
\xw{[north]}, \xw{[south]}, \xw{[east]}, \xw{[west]}, \xw{[north east]}, \xw{[north west]}, \xw{[south east]}, \xw{[south west]}.
You can also use positional words like \xw{[left]}, \xw{[rigth]}, \xw{[down]}, and \xw{[up]}, but you cannot \xw{[above]} nor \xw{[below]}.

\remark One thing you should remember about this is that \cmd{\istgrowdirection} is internally used 
in the definition of \cmd{\istb} to control the label position for payoffs.
However, for the label position, \xw{[below]} and \xw{[above]} are good, 
but not \xw{[down]} nor \xw{[up]}.
So DO NOT USE \xw{[down]} and \xw{[up]} to specify the tree growing direction.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example 2: \istroot (three simple trees connected)
\begin{istgame}
\xtdistance{20mm}{20mm}
\istroot[right](0)[oval node]<left>{player 1}
  \istb  \istb  \endist
\istroot(a)(0-1)<right>{player 2}+15mm..10mm+
  \istb  \istb  \endist
\istroot[right](b)(0-2)[box node]<135>{player 3}
  \istb  \istb  \endist
\end{istgame}
\end{tcblisting}
\label{page:threesimpletrees}

The last two options of \cmd{\istroot} specify the \xw{level distance} and the \xw{sibling distance}.
This change of distances is valid only for the corresponding simple tree, while distance change by \cmd{\xtdistance} is valid within the current \pkg{istgame} environment unless it is changed again by \cmd{\xtdistance}.
Do not forget, when you use decimal distances, to delimit the decimal dimensions with curly braces, like
\verb|+{15.5mm}..{10.5mm}+|.

\subsubsection{\protect\cmd{\istroot'} -- clockwise (swap version)}

\label{ssec:istroot'}

The macro \icmd{\istroot'} is the swap version of \cmd{\istroot}.
\cmd{\istroot'} works just like \cmd{\istroot}, but with one exception: going clockwise instead of counterclockwise.
\cmd{\istroot'} arranges its branches \ixw{clockwise} (or from right to left if the tree grows down).

Compare the following example with that of \cmd{\istroot} on page \pageref{page:clockwise}.
The two examples have exactly the same codes as each other except for one thing: either \cmd{\istroot} or \cmd{\istroot'}.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: \istroot' (explained with labels)
\begin{istgame}[font=\scriptsize]
\istroot'(0)
  \istb  \istb  \istb \endist
\istroot'(a)(0-1)
  \istb  \istb  \endist
%% labels: (ignore the following lines at the moment)
\xtOwner(0){(0)}
\xtOwner(0-1){(0-1)}[r]
\xtOwner(0-2){(0-2)}[b]
\xtOwner(0-3){(0-3)}[b]
\xtOwner(a){(a)}[l]
\xtOwner(a-1){(a-1)}[b]
\xtOwner(a-2){(a-2)}[b]
\draw [<-,ultra thick,blue!20](-260:1.5) 
  arc (-260:80:1.5cm)
  node [above,blue!30] {clockwise};
\end{istgame}
\end{tcblisting}


We will look into this issue (of going counterclockwise or clockwise) in more detail in section \ref{sec:growing}, where we examine the tree growing direction.

If you draw a game tree growing south, you don't need to worry about the swap version \cmd{\istroot'} and just use \cmd{\istroot}.

\subsection{\protect\cmd{\istrooto}: oval version}

\label{ssec:istrootstar}

\subsubsection{\protect\cmd{\istrooto} -- counterclockwise}

The macro \icmd{\istrooto} is the oval version of \cmd{\istroot}.
This allows us to draw a bubble (by default, \xw{oval node}) with a node owner (or a game player) in it. With one exception to this, \cmd{\istrooto} works just like \cmd{\istroot}. Since the owner is shown in the specified node in \cmd{\istrooto}, the option \xw{<owner label angle>} of the standard version \cmd{\istroot} is ignored.

\begin{tcblisting}{listing only,breakable}
% \istrooto
% syntax: 
    \istrooto[<grow keyval>](<coor1>)(<coor2>)[<node style>]{<player>}+levd..sibd+
% default: only (coor1) is mandatory, all others optional
    [south]()(0,0)[oval node]{}+15mm..15mm+
\end{tcblisting}

\mbigskip1

The following example is the same as above with \cmd{\istroot} on page \pageref{page:onesimpletree}, but now with the oval version.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example 1: \istrooto (one simple tree)
\begin{istgame}[font=\itshape]
\istrooto[right](0)<180>{player 1}
  \istb  \istb  \endist
\end{istgame}
\end{tcblisting}

The following example is also the same as above with \cmd{\istroot} on page \pageref{page:threesimpletrees}, but now with the oval version.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example 2: \istrooto (three simple trees connected)
\begin{istgame}
\xtdistance{20mm}{20mm}
\istrooto[right](0)[oval node]<left>{player 1}
  \istb  \istb  \endist
\istroot(a)(0-1)<right>{player 2}+15mm..10mm+
  \istb  \istb  \endist
\istrooto[right](b)(0-2)[box node]<135>{player 3}
  \istb  \istb  \endist
\end{istgame}
\end{tcblisting}

Notice that the angle \xw{<180>}, \xw{<left>}, \xw{<right>}, or \xw{<135>} specifying the position of the owner's name is redundant to \cmd{\istrooto}.

\mbigskip1

\remark Note that, in \tikz, a tree branch comes from the center of the parent node and goes to the center of the child node.
%Now what if you want to have branches coming from some point of the circumference of, say, an oval parent node to that of a child node.
%\cmd{\setistbranchanchors} specifies the anchors of parent node and child node. (experimental!)
%
%\begin{tcblisting}{listing only}
%% \setistbranchanchors (experimental!)
%% syntax: \setistbranchanchors
%    \setistbranchanchors{<parent anchor>}{<child anchor>}
%% defaults: <parent anchor> is mandatory
%    {}{center}    
%\end{tcblisting}

Note also that \cmd{\istrooto} arranges its branches \ixw{counterclockwise}.

\begin{tcblisting}{listing outside text, righthand width=.4\linewidth}
% Example 3: \istrooto (counterclockwise)
\begin{istgame}
\setistOvalNodeStyle{.6cm}
\istrooto(0){0}+{12.5mm}..{3.45cm}+
  \istb  \istb  \endist
\xtShowEndPoints[oval node]
\xtdistance{12.5mm}{11.5mm}
\istrooto(1)(0-1){1}
  \istb{}{3}[center]  \istb{}{4}[center]
  \istb{}{5}[center]  \endist
\istrooto(2)(0-2){2}
  \istb{}{6}[center]  \istb{}{7}[center]
  \istb{}{8}[center]  \endist
\istrooto(6)(2-1){6}
  \istb{}{9}[center]  \istb{}{10}[center]
  \endist
\draw [->,ultra thick,blue!20](-260:1.5) 
  arc (-260:80:1.5cm)
  node [above,blue!30] {counterclockwise};
\end{istgame}
\end{tcblisting}


\subsubsection{\protect\cmd{\istrooto'} -- clockwise (swap version)}

The swap version of the oval version \icmd{\istrooto'} works just like \cmd{\istroot'} with one exception that it puts the owner within an oval node, by default.
\mbigskip1


\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example 2: \istrooto (three simple trees connected)
\begin{istgame}
\xtdistance{20mm}{20mm}
\istrooto'[right](0)[oval node]<left>{player 1}
  \istb  \istb  \endist
\istrooto'[right](b)(0-1)[box node]<135>{player 2}
  \istb  \istb  \endist
\istroot(a)(0-2)<right>{player 3}+15mm..10mm+
  \istb  \istb  \endist
\end{istgame}
\end{tcblisting}

\mbigskip1
The swap version is useful when a tree grows north or east.
The following example shows the tree rotating to the north by using \icmd{\setistgrowdirection}.
Note that \cmd{\istrooto'} arranges its branches \ixw{clockwise}.


\mbigskip1
\begin{tcblisting}{listing outside text, righthand width=.4\linewidth}
% Example 3: \istrooto' (clockwise)
\begin{istgame}
\setistgrowdirection{north}
\setistOvalNodeStyle{.6cm}
\istrooto'(0){0}+{12.5mm}..{3.45cm}+
  \istb  \istb  \endist
\xtShowEndPoints[oval node]
\xtdistance{12.5mm}{11.5mm}
\istrooto'(1)(0-1){1}
  \istb{}{3}[center]  \istb{}{4}[center]
  \istb{}{5}[center]  \endist
\istrooto'(2)(0-2){2}
  \istb{}{6}[center]  \istb{}{7}[center]
  \istb{}{8}[center]  \endist
\istrooto'(6)(2-1){6}
  \istb{}{9}[center]  \istb{}{10}[center]
  \endist
\draw [->,ultra thick,blue!20](260:1.5) 
  arc (260:-80:1.5cm)
  node [below,blue!30] {clockwise};
\end{istgame}
\end{tcblisting}

\mbigskip1

%\noindent 
%* Known Problem: Two examples above show that \cmd{\setistbranchanchors} does not work as expected for the first child node anchor.



%\clearpage

\section{Core macro: \protect\cmd{\istb}}

\label{sec:istb}

\subsection{\protect\cmd{\istb}: basics}

\label{ssec:istb}

The macro \icmd{\istb}, basically, prints a branch. 
Having all arguments as options, a simple \cmd{\istb} draws a branch from a parent node designated by \cmd{\istroot} to a child node (or endpoint of \cmd{\istb}).
If, for example, a parent node is name \xw{(A)} by \cmd{\istroot}, the first child node is automatically named \xw{(A-1)}, the second child node \xw{(A-2)}, and so on.

\mbigskip1
The macro \cmd{\istb} also puts an action label and payoffs along with a branch, and does other functions.
Note that the action labels and payoffs are defined to be typeset in the math mode, 
so you can use \verb|\text{...}| when you want to typeset them in the text mode.

\mbigskip1
\begin{tcblisting}{listing only,breakable}
% \istb
% syntax:
  \istb<grow, distance, missing>[<line style>]{<action>}[<pos>]{<payoff>}[<pos>]
% defaults: 
  <grow=south>{-}{}[center]{}[\istgrowdirection]
% arguments: all arguments are optional
  <grow=keyval> % the direction of a branch <default: south>
  [line style] % branch line style <default: solid>
  {action} % action label (in math mode)
  [action pos] % position of action label <default: center>
  {payoff} % payoffs (in math mode)
  [payoff pos] % position of payoffs <default: \istgrwodirection: south>
\end{tcblisting}

In the following example, each \cmd{\istb} draws a branch.
With the option \xw{<missing>}\index{missing}, \cmd{\istb} prints an invisible branch.
Since the third child is missing the last child was named \xw{(0-4)}.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: \istb<missing>
\begin{istgame}
\istroot(0)
  \istb  \istb  \istb<missing>  \istb  \endist
\istroot(D)(0-4)
  \istb \istb \endist
\end{istgame}
\end{tcblisting}

\mbigskip1

The macro \cmd{\istb} also has various options to control the line style of a branch, and the direction and length of a branch.
\cmd{\istb} can also place payoffs to the direction of tree growth by default. 

\mbigskip1

\remark What is \icmd{\istgrowdirection} and what is it used for?\par

\cmd{\istgrowdirection} has the value of \xw{[<grow keyval>]} typed in \cmd{\istroot} (default: \xw{south}).\par
The value of \cmd{\istgrowdirection} specifies the direction of putting `payoffs' with \xw{south} by default.
We will see this in more detail below.

\mbigskip1

For various line styles of a branch, you can use any options in \tikz\ of arrows, linewidth, color, and so on.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: \istb (branch line styles)
\begin{istgame}
\istroot(0)
  \istb[dashed,thick]{A}{(0,1)}
  \istb[->]{}{(1,-1)}
  \istb[blue,very thick]{B}[above]{(1,2)}
  \endist
\end{istgame}
\end{tcblisting}

\mbigskip1

By default, an action label is put on the mid point of the corresponding branch.
\mbigskip1

To specify the position of an action label,
you can use the positional words or their abbreviations below:\par
\xw{[a]} for \xw{[above]}, \xw{[b]} for \xw{[below]}, \xw{[l]} for \xw{[left]}, \xw{[r]} for \xw{[right]},\par
\xw{[al]} for \xw{[above left]}, \xw{[ar]} for \xw{[above right]}, \par
\xw{[bl]} for \xw{[below left]}, and \xw{[br]} for \xw{[below right]}.

\remark Note that these abbreviations must be used with no other options, otherwise you will get a compile error.

\mbigskip1

In the following example, notice that the tree grows south east and the payoffs are placed south east.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: tree toward south east (or -45 degree)
\begin{istgame}
\istroot[-45](0)
  \istb[dashed,thick]{A}{(0,1)}
  \istb[->]{}{(1,-1)}
  \istb[blue,very thick]{B}[above]{(1,2)}
  \endist
\end{istgame}
\end{tcblisting}

\mbigskip1

If you do not like the position of the payoffs, you can change it by using degrees, the compass directions, or the positional words and their abbreviations mentioned above.
In the following example, the tree grows south west, but the position of the payoffs at the end of the blue branch is changed to \xw{[below]}

\mbigskip1

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: tree toward south west (or 225 degree)
\begin{istgame}
\istroot[south west](0)
  \istb[dashed,thick]{A}{(0,1)}
  \istb[->]{}{(1,-1)}
  \istb[blue,very thick]{B}[right]{(1,2)}[below]
  \endist
\end{istgame}
\end{tcblisting}

\subsection{\protect\cmd{\istb*} (starred version)}

\label{ssec:istbstar}

The starred version \icmd{\istb*} prints a solid node (by default) at the end of the corresponding branch. 
This is the only difference between \cmd{\istb} and \cmd{\istb*}.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: \istb*
\begin{istgame}
\istroot[east](0)
  \istb[dashed,thick]{A} 
  \istb*[->]{}{(1,-1)}
  \istb[blue,very thick]{B}[above]
  \endist
\end{istgame}
\end{tcblisting}

\subsubsection*{\protect\cmd{\xtShowEndPoints} and \protect\cmd{\xtHideEndPoints}}

\label{page:endpoint}

Each endpoint is printed by each execution of \cmd{\istb*}.
You can print solid nodes (by default) at `all' the endpoints of `simple trees' by \icmd{\xtShowEndPoints}.
You can also change the shape of nodes of endpoints of simple trees by specifying it as an optional argument, like
\cmd{\xtShowEndPoints[oval node]}.
\icmd{\xtHideEndPoints} turns off the effect of \cmd{\xtShowEndPoints}.

\mbigskip1

\begin{tcblisting}{listing only,breakable}
% \xtShowEndPoints
% syntax: 
  \xtShowEndPoints[<node style>]
% default:
  [solid node]
\end{tcblisting}

\mbigskip1

Here is an example of using \cmd{\xtShowEndPoints} and \cmd{\xtHideEndPoints}.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: \xtShowEndPoints, \xtHideEndPoints
\begin{istgame}
\xtShowEndPoints[oval node]
\istroot(0)[solid node]
  \istb[dashed,thick]{A} 
  \istb
  \istb[very thick]{B}[ar]
  \endist
\xtdistance{15mm}{10mm}
\istroot(b)(0-2) \istb  \istb  \endist
\xtHideEndPoints
\istroot(b)(0-3) \istb  \istb  \endist
\end{istgame}
\end{tcblisting}


Note that \cmd{\xtShowEndPoints} and \cmd{\xtHideEndPoints} should be in an \env{istgame} environment to avoid unexpected results. 
Note also that \cmd{\istb*} overrides all the effects of these two macros by printing a \pkg{solid node}.


\subsection{\protect\cmd{\istb.}~(period version)}

\label{ssec:istbperiod}

The period version \icmd{\istb.}\ is designed to represent a `terminal move' in a game tree.
Basically, \cmd{\istb.}\ works exactly the same way as \cmd{\istb} does. 
However, using \cmd{\istb.}\ together with \cmd{\xtShowTerminalNodes} can control the shape of all the terminal nodes at once.

\subsubsection*{\protect\cmd{\xtShowTerminalNodes} and \protect\cmd{\xtHideTerminalNodes}}

\label{page:terminalnode}

The period version \cmd{\istb.}\ used  with \icmd{\xtShowTerminalNodes} prints a solid node (by default). 
You can change the style of the terminal nodes, like \cmd{\xtShowTerminalNodes[oval node]}.
This effect can be turned off by \icmd{\xtHideTerminalNodes}.

\begin{tcblisting}{listing only,breakable}
% \xtShowTerminalNodes (works only with \istb.)
% syntax: 
  \xtShowTerminalNodes[<node style>]
% default: 
  [solid node]
\end{tcblisting}

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: \xtShowTerminalNodes, \xtHideTerminalNodes
\begin{istgame}
\xtShowTerminalNodes[oval node]
\istroot(0)[solid node]
  \istb.[dashed,thick]{A} 
  \istb
  \istb[very thick]{B}[ar]
  \endist
\xtdistance{15mm}{10mm}
\istroot(b)(0-2) \istb.  \istb.  \endist
\xtHideTerminalNodes
\istroot(b)(0-3) \istb.  \istb.  \endist
\end{istgame}
\end{tcblisting}



\section{Players, action labels, and payoffs}

\subsection{How to put players}

\subsubsection{Players: basics}

As discussed in \ref{ssec:istroot}, the macro \cmd{\istroot} specifies the (sub)root and puts its owner (or a player).
The direction to which a player label is put is set by the angle \xw{< >} option of \cmd{\istroot}, like \xw{<above>} (by default), \xw{<0>}, or \xw{<45>}.
To specify the direction you can use degrees, the compass directions, or the positional words.

\mbigskip1

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: node owner
\begin{istgame}
\istroot(0)<above>{Child} % default: <above>
  \istb  \istb  \endist
\istroot(1)(0-2)<45>{Parent}
  \istb  \istb  \endist
\end{istgame}
\end{tcblisting}

\remark
The auxiliary macro \cmd{\xtOwner} is provided for an extra way of putting owners of decision nodes (see section \ref{sec:auxmac}).

\mbigskip1
Note that \cmd{\istrooto} produces a bubble type node with the owner in it, so the directional option \xw{<angle>} is redundant with \cmd{\istrooto} (see section \ref{ssec:istrootstar}).

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: node owner (with \istrooto)
\begin{istgame}
\istrooto(0){Child}
  \istb  \istb  \endist
\istrooto(1)(0-2)<45>{Parent}
  \istb  \istb  \endist
\end{istgame}
\end{tcblisting}

\subsubsection{Coloring players or a whole simple tree: \protect\cmd{\istroot}}

\label{sec:firstthing}

You can change the color of a player's name by giving \xw{color} with the angle option of \cmd{\istroot}, like \xw{<[red]>} or \xw{<[blue]45>}.
(This is the \tikz\ way for giving options for \xw{label}.)

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: coloring players
\begin{istgame}
\istroot(0)<[red]>{Child}
  \istb  \istb  \endist
\istroot(1)(0-2)<[blue]45>{Parent}
  \istb  \istb  \endist
\end{istgame}
\end{tcblisting}

\mbigskip1
The following example shows how you color a whole simple tree: \xw{red} for the Child's simple tree and \xw{blue} for the Parent's simple tree.

\mbigskip1
\remark Note that the first thing in the \xw{[option]} of \cmd{\istroot} must be `the direction of tree growing,' so it should be set as \xw{[south,red]} or \xw{[-90,blue]}.
\mbigskip1

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: coloring a simple tree
\begin{istgame}
\istroot[south,red](0)%  all branches will be red
        [fill=red,draw=red]<[red]>{Child} % node/owner
  \istb  \istb  \endist
\istroot[-90,blue](1)(0-2)%  all, blue branches
        [blue]<[blue]45>{Parent}
  \istb  \istb  \endist
\end{istgame}
\end{tcblisting}

\subsubsection{Decorating players or a whole simple tree: \protect\cmd{\istrooto}}

With \cmd{\istrooto} the color of a player can be changed by \xw{[option]}, such as \xw{[red]} or \xw{[blue]}.
(This is the \tikz\ way for giving options for \xw{node}.)

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: coloring players (with \istrooto)
\begin{istgame}
\istrooto(0)[red]{Child}
  \istb  \istb  \endist
\istrooto(1)(0-2)[blue]{Parent}
  \istb  \istb  \endist
\end{istgame}
\end{tcblisting}

The next example shows how you can color a whole simple tree \xw{red} or \xw{blue}.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: coloring a simple tree (with \istrooto)
\begin{istgame}
\istrooto[south,red](0)[draw=green,blue]{Child}
  \istb  \istb  \endist
\istrooto[-90,blue](1)(0-2)[draw=blue,blue]{Parent}
  \istb  \istb  \endist
\end{istgame}
\end{tcblisting}


What if you want to paint some color into the background of each oval node or box node? You can also do this simply by using the \tikz\ way for giving options for nodes.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: decorating oval/box nodes
\begin{istgame}
\istrooto(0)[top color=white,
             bottom color=blue!80!black,yellow]{Child}
  \istb  \istb  \endist
\istrooto(1)(0-2)[box node,fill=red!20,blue]{Parent}
  \istb  \istb  \endist
\end{istgame}
\end{tcblisting}


\subsection{How to put action labels}


\subsubsection{Action labels: basics}

The macro \cmd{\istb} prints a branch and its action label.
Note that action labels are printed in the math mode.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: actions labels
\begin{istgame}
\istroot(0)
  \istb{Good}[left]  \istb{Bad}  \endist
\istroot(1)(0-2)
  \istb{\text{\fbox{$\alpha$}}}[above left]  
  \istb{\text{\fbox{$\beta$}}}[above right]  
  \endist
\end{istgame}
\end{tcblisting}

By default, \cmd{\istb} prints its action label on the mid point of the corresponding branch.
You can specify the position of an action label with the positional words and their abbreviations, but not by the compass directions or degrees.

Notice that with the abbreviations the position of the action labels are (internally) adjusted to get better result (for more details, see section \ref{sec:abb}).
In the following example, the abbreviations are used.
\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: actions labels with abbreviations
\begin{istgame}
\istroot(0)
  \istb{Good}[l]  \istb{Bad}  \endist
\istroot(1)(0-2)
  \istb{\text{\fbox{$\alpha$}}}[al]  
  \istb{\text{\fbox{$\beta$}}}[ar]  
  \endist
\end{istgame}
\end{tcblisting}

\mbigskip1

\remark
The auxiliary macro \cmd{\xtActionLabel} is provided for an extra way of putting an action label (see section \ref{sec:auxmac}).

\subsubsection{Changing the color of action labels and the style of branches}

You can change the color of action labels with \tikz\ options. 
In the following example, the bracket options before an action label are for a branch and those after are only for the action label.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: color and line style
\begin{istgame}
\istroot(0)
  \istb[dashed,thick]{A}[al]
  \istb[blue,very thick]{B}[r]
  \istb[blue,very thick]{C}[above right,red]
  \endist
\end{istgame}
\end{tcblisting}

\mbigskip1
\remark It is important to remember that you cannot use the abbreviations with additional options. For example, you can do like \cmd{\itsb\{C\}[ar]}, but not \cmd{\istb\{B\}[ar,red]}. Instead, you should do \cmd{\istb\{C\}[above right,red]}.

\subsection{How to put payoffs}

\subsubsection{Payoffs: basics}

The macro \cmd{\istb} can also print a branch and the corresponding payoffs near at its endpoint.
Note also that payoffs are printed in the math mode. The payoffs are put in the direction set by \cmd{\setistgrowdirection} (\xw{south}, by default), unless it is changed by \xw{<grow keyval>} of \cmd{\istroot}.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: payoffs
\begin{istgame}
\istroot(0)
  \istb{Good}[l]{0,2}  
  \istb{Bad}  
  \endist
\istroot(1)(0-2)
  \istb{\alpha}[al]{(1,1)}
  \istb{\beta}[ar]{-1,-1}
  \endist
\end{istgame}
\end{tcblisting}

\subsubsection{Payoffs and \protect\cmd{\istgrowdirection}}

The direction of where payoffs are put from a terminal node follows \cmd{\istgrowdirection} typed in as the first optional argument of \cmd{\istroot}.
The default direction is \xw{south} and can be changed by \cmd{\setistgrowdirection}.
For example, \cmd{\setistgrwodirection\{north\}} changes the default direction to \xw{north}.

To specify the tree growing direction or the position of the payoffs to put, you can use degrees, the compass words, or the positional words and their abbreviations.

\mbigskip1
\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: grow=south (default)
\begin{istgame}
\xtShowEndPoints[box node]
\istroot(0)
  \istb[dashed,thick]{A}{\binom23}
  \istb*{}{(-2,3)}
  \istb.[blue,very thick]{B}[ar]{2,3}
  \endist
\end{istgame}
\end{tcblisting}

By default, \xw{grow=south}, so \cmd{\istgrowdirection} is \xw{south} (or \xw{below} or \xw{-90}).\par
This example shows payoffs at the south of terminal nodes.

%\mbigskip1

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: grow=right (or east or 0 degree)
\begin{istgame}
\xtShowTerminalNodes[oval node]
\istroot[right](0)
  \istb[dashed,thick]{A}{\binom23}
  \istb*{}{(-2,3)}
  \istb.[blue,very thick]{B}[al]{2,3}
  \endist
\xtHideTerminalNodes
\end{istgame}
\end{tcblisting}

\verb|grow=right=\istgrowdirection|, so the payoffs are put on the right.
%

\mbigskip1
\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: grow=north
\begin{istgame}
\setistgrowdirection{north}
\istroot(0)
  \istb[dashed,thick]{A}{\binom23}
  \istb*{}{(-2,3)}
  \istb.[blue,very thick]{B}[bl]{2,3}
  \endist
\end{istgame}
\end{tcblisting}

\verb|grow=north=\istgrowdirection|, so the payoffs are put above the terminal nodes.

\mbigskip1
\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
\begin{istgame}
\istroot[south west](0)
  \istb[dashed,thick]{A}{\binom23}
  \istb{}{(-2,3)}
  \istb[blue,very thick]{B}[right]{2,3}[b]
  \endist
\end{istgame}
\end{tcblisting}

\verb|grow=south west=\istgrowdirection|, so the payoffs are put below left of the terminal node.

\mbigskip1
You can adjust the direction of putting any payoff by specifying an option right after the payoff, like \verb|\istb[blue,very thick]{B}[right]{2,3}[below]|. 

You can use the abbreviations \xw{[l]}, \xw{[r]}, \xw{[a]}, and \xw{[b]} for \xw{[left]}, \xw{[right]}, \xw{[above]}, and \xw{[below]}, respectively.
The abbreviations \xw{[al]}, \xw{[ar]}, \xw{[bl]}, and \xw{[br]} can also be used
for \xw{[above left]}, \xw{[above right]}, \xw{[below left]}, and \xw{[below right]}, respectively,
to put payoffs (for more details about abbreviations, see section \ref{sec:abb}). 

Notice also that, instead of the positional words, you can use the compass directions or degrees, like \verb|\istb[blue,very thick]{B}[right]{2,3}[-90]|.


\subsubsection{Coloring payoffs}

You can change the color of the payoffs by giving options with the positional words. 
For example you can do like \xw{\istb...\{(1,1)\}[[blue]below]}.
This is the \tikz\ way of giving options for \xw{label}.
Notice that, in this case, you should not use the abbreviation of the positional words.

\begin{tcblisting}{listing outside text, righthand width=.2\linewidth}
% Example: payoffs
\begin{istgame}
\istroot(0)
  \istb{Good}[l]{0,2}  \istb{Bad}  \endist
\istroot(1)(0-2)
  \istb{\alpha}[al]{(1,1)}[[red]below]
  \istb{\beta}[ar]{-1,-1}[[blue]below]
  \endist
\end{istgame}
\end{tcblisting}

%\clearpage
\section{Fine-tuning positions of players, action labels, and payoffs (experimental)}

\subsection{Fine-tuning positions: owners}

If you are not satisfied the position of the owner (or a player), you can change it by using the \tikz\ options such as \xw{xshift}, \xw{yshift}, or \xw{label distance} with the angle option of \cmd{\istroot}.

Examples are \xw{<[xshift=10pt]above>\{Child\}} and \xw{<[label distance=-5pt]45>\{Parent\}}, as shown in the following. 

\begin{tcblisting}{listing outside text, righthand width=.2\linewidth}
% Example: node owner
\begin{istgame}
\istroot(0)<[xshift=10pt]above>{Child}
  \istb  \istb  \endist
\istroot(1)(0-2)<[label distance=-5pt]45>{Parent}
  \istb  \istb  \endist
\end{istgame}
\end{tcblisting}


%\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
%\begin{istgame}[scale=1.2]
%\istcntm(ctm)[green]+8mm..24mm+
%\istroot(0)(ctm){I}+8mm..8mm+
%  \istb{x}[r]
%  \istb<missing>
%  \endist
%\xtdistance{10mm}{18mm}
%\istroot(1)(0-1)<[label distance=-3pt]120>{II}
%  \istb{Y}[l]{x,1-x}
%  \istb{N}[r]{0,0}
%  \endist
%\end{istgame}
%\end{tcblisting}


\subsection{Fine-tuning positions: action labels}


\subsubsection{Abbreviations: \xw{[l]}, \xw{[r]}, \xw{[a]}, and \xw{[b]}}

As discussed in \ref{ssec:istb}, the macro \cmd{\istb} deals with the action labels.

In order to determine the direction of action labels for branches to put, you can use degrees, the compass directions, or the positional words and their abbreviations as mentioned above.
(Internally, the abbreviations for payoffs and those for action labels work slightly differently in terms of \xw{xshift} and \xw{yshift}.)


\begin{tcblisting}{listing outside text, righthand width=.2\linewidth}
% Example: action labels (default position)
\begin{istgame}[scale=1.2]
\xtShowEndPoints
\xtdistance{12mm}{16mm}
\istroot(0)[initial node]
  \istb<grow=0>{\fbox{$a$}}[a]   \istb<grow=90>{\fbox{$l$}}[l]
  \istb<grow=180>{\fbox{$b$}}[b] \istb<grow=-90>{\fbox{$r$}}[r]
  \endist
\end{istgame}
\end{tcblisting}
%\captionof{figure}{action labels by defaults with \xw{l}, \xw{r}, \xw{a}, and \xw{b}}

When you use these abbreviations you can manipulate the horizontal and/or the vertical shifts toward branches by using \icmd{\xtALPush}. (This is experimental!)

%\mbigskip1

\begin{tcblisting}{listing only}
% syntax: 
  \xtALPush{<xshift dim> for l and r}{<yshift dim> for a and b}
% default:
  {0pt}{0pt}
\end{tcblisting}

\mbigskip1
For example, \verb|\xtALPush{-3pt}{5pt}| draws the labels left and right by \xw{3pt} to the branch and push those put above and below \xw{5pt} away from the branch, as shown in the following.

\begin{tcblisting}{listing outside text, righthand width=.2\linewidth}
% Example: \xtALPush
\begin{istgame}[scale=1.2]
\xtShowEndPoints
\xtALPush{-3pt}{5pt} % look here
\xtdistance{12mm}{16mm}
\istroot(0)[initial node]
  \istb<grow=0>{\fbox{$a$}}[a]   \istb<grow=90>{\fbox{$l$}}[l]
  \istb<grow=180>{\fbox{$b$}}[b] \istb<grow=-90>{\fbox{$r$}}[r]
  \endist
\end{istgame}
\end{tcblisting}
%\captionof{figure}{action labels shifted: comparison}






\subsubsection{Abbreviations: \xw{[al]}, \xw{[ar]}, \xw{[bl]}, and \xw{[br]}}
\label{sec:abb}

You can also use the abbreviations \xw{al}, \xw{ar}, \xw{bl}, and \xw{br} to represent
\xw{above left}, \xw{above right}, \xw{below left}, and \xw{below right}, respectively,
to position action labels. Precise representation of abbreviations is as follows:
\begin{itemize}%\tightlist
\item \xw{[al]} represents \verb|[above left,xshift=1pt,yshift=-2pt,black]|
\item \xw{[ar]} represents \verb|[above right,xshift=-1pt,yshift=-2pt,black]|
\item \xw{[bl]} represents \verb|[below left,xshift=1pt,yshift=2pt,black]|
\item \xw{[br]} represents \verb|[below right,xshift=-1pt,yshift=2pt,black]|
\end{itemize}

\mbigskip1

%\begin{tcblisting}{listing outside text, righthand width=.35\linewidth}
\begin{tcblisting}{listing above text}
% Example: action labels with abbreviations
\begin{istgame}[scale=1.1]
\xtShowTerminalNodes[oval node,line width=.3pt]
\def\xbox#1{\fbox{$#1$}}  \def\ybox#1{#1}
\xtdistance{12mm}{16mm}
\istroot(0)[initial node]
  \istb<grow=0>{\ybox{a}}[a]
  \istb<grow=90>{\ybox{l}}[l]
  \istb<grow=180>{\ybox{b}}[b]
  \istb<grow=-90>{\ybox{r}}[r]
  \endist
\begin{scope}[line width=1.2]
\xtdistance{10mm}{20mm}
\istroot[90](N)(0-2)
  \istb.[red]{\xbox{br}}[br]{1,1}
  \istb.[blue,dashed]{\xbox{bl}}[bl]{2,2}
  \endist
\istroot[180](W)(0-3)
  \istb.[green]{\xbox{ar}}[ar]{0,3}
  \istb.[red]{\xbox{br}}[br]{2,1}
  \endist
\istroot[-90](S)(0-4)
  \istb.[dotted]{\xbox{al}}[al]{1,-1}
  \istb.[green]{\xbox{ar}}[ar]{-1,1}
  \endist
\istroot[0](E)(0-1)
  \istb.[blue,dashed]{\xbox{bl}}[bl]{1,3}
  \istb.[dotted]{\xbox{al}}[al]{2,0}
  \endist
\foreach \x in {1,...,4} {\xtNode(0-\x)}
\end{scope}
\end{istgame}
\end{tcblisting}
\captionof{figure}{positioning action labels with the abbreviations}\label{fig:actlabel3}


In Figure~\ref{fig:actlabel3}, \fbox{$al$}'s are put in the same position from dotted branches,
and so are the other labels from their corresponding branches, like \fbox{$bl$}'s from the blue dashed branches.

\mbigskip1

You can also use \icmd{\xtALShift} to put and push labels horizontally and vertically. (This is experimental!)

\begin{tcblisting}{listing only}
% syntax: 
  \xtALShift{<horizontal shift dim>}{<vertical shift dim>}
% defaults: 
  {1pt}{2pt}
\end{tcblisting}

\mbigskip1

When the dimensions get bigger than the defaults (\xw{1pt} and \xw{2pt}) the labels get closer to the mid points of the corresponding branches, and when the numbers get smaller the labels get farther from their branches.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: node owner
\begin{istgame}
\xtALShift{4pt}{3pt}
\istroot(0)<above>{Child} % default: <above>
  \istb{A}[al]  \istb{B}[ar]  \endist
\istroot(1)(0-2)<45>{Parent}
  \istb{L}[al]  \istb{R}[ar]  \endist
\end{istgame}
\end{tcblisting}


\subsection{Fine-tuning positions: payoffs}

You can change the position of payoffs with \tikz{} options: \xw{xshift} and \xw{yshift}.
For example, you can do as shown in the following:

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example: payoffs
\begin{istgame}
\istroot(0)
  \istb{Good}[l]{0,2}  \istb{Bad}  \endist
\istroot(1)(0-2)
  \istb{\alpha}[al]{(1,1)}[[xshift=-10pt]below]
  \istb{\beta}[ar]{-1,-1}[[yshift=-10pt]below]
  \endist
\end{istgame}
\end{tcblisting}


\section{Growing direction of trees}
\label{sec:growing}

You can draw a game tree that grows in any direction.
By default, a game tree grows down and the \xw{child} branches are arranged and named counterclockwise with respect to their parent node.
When a tree grows down, the branches are arranged from left to right.
When a tree grows to the right, the branches are arranged and named from below to above.

\mbigskip1
Sometimes you may want a tree with the branches arranged clockwise with respect to their parent node because it seems to look more natural, especially when a tree grows north or east.
In \tikz, \xw{grow'=<direction>} enables you to draw a tree developed clockwise.

To deal with the direction of the tree growth and the order of arranging branches, this package provides \icmd{\setistgrowdirection'} as well as  \icmd{\setistgrowdirection}.

\mbigskip1
\begin{tcblisting}{listing only}
% default: growing south counterclockwise
\def\xtgrow{grow}
\def\istdefault@grow{south} % tree growing direction

% \setistgrowdirection(')
\NewDocumentCommand\setistgrowdirection{t'm}
{\IfBooleanTF {#1}
  { \renewcommand\xtgrow{grow'}
    \renewcommand\istdefault@grow{#2}
  }
  { \renewcommand\xtgrow{grow}
    \renewcommand\istdefault@grow{#2}
  }
}
\end{tcblisting}


\subsection{\protect\cmd{\setistgrowdirection} -- counterclockwise}

Our first example is a tree drawn using the default values: growing \xw{south} with branches going \ixw{counterclockwise} with respect to their parent nodes (from left to right).

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example 1: \setistgrowdirection{south}
\begin{istgame}
\setistOvalNodeStyle{.6cm}
\xtShowEndPoints[oval node]
\istrooto(0){0}+{12.5mm}..{3.45cm}+
  \istb  \istb  \endist
\xtdistance{12.5mm}{11.5mm}
\istrooto(1)(0-1){1}
  \istb{}{3}[center]  \istb{}{4}[center]
  \istb{}{5}[center]  \endist
\istrooto(2)(0-2){2}
  \istb{}{6}[center]  \istb{}{7}[center]  \endist
\end{istgame}
\end{tcblisting}

By default or with \cmd{\setistgrowdirection\{south\}}, the numbers written in the child nodes increase counterclockwise with respect to their parent nodes.

\subsection{\protect\cmd{\setistgrowdirection'} -- clockwise}

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example 2: \setistgrowdirection'{south}
\begin{istgame}
\setistgrowdirection'{south}
% same code as in Example 1
\setistOvalNodeStyle{.6cm}
\xtShowEndPoints[oval node]
\istrooto(0){0}+{12.5mm}..{3.45cm}+
  \istb  \istb  \endist
\xtdistance{12.5mm}{11.5mm}
\istrooto(1)(0-1){1}
  \istb{}{3}[center]  \istb{}{4}[center]
  \istb{}{5}[center]  \endist
\istrooto(2)(0-2){2}
  \istb{}{6}[center]  \istb{}{7}[center]  \endist
\end{istgame}
\end{tcblisting}

With \cmd{\setistgrowdirection'\{south\}}, the numbers written in the child nodes increase \ixw{clockwise} with respect to their parent nodes, which does not look natural.

\subsection{Examples of rotating trees with \protect\cmd{\setistgrowdirection(')}}

This macro allows you to to rotate a game tree.

When you rotate a game tree to the north or to the east, it is a good idea to use the swap version \icmd{\setistgrowdirection'}.


\mbigskip1

\noindent\textbf{Tips:} \label{page:growtips}

Though it is not necessary, it is suggested to use the following combinations of the macros and the directions.

\xw{\setistgrowdirection\{south\}}: branches going counterclockwise (from left to right)\par
\xw{\setistgrowdirection\{west\}}: branches going counterclockwise (downward)\par
\xw{\setistgrowdirection'\{north\}}: branches going clockwise (from left to right)\par
\xw{\setistgrowdirection'\{east\}}: branches going clockwise (downward)

\subsubsection{A tree growing east -- counterclockwise}

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example 3: \setistgrowdirection{east}
\begin{istgame}
\setistgrowdirection{east}
% same code as in Example 1
\setistOvalNodeStyle{.6cm}
\xtShowEndPoints[oval node]
\istrooto(0){0}+{12.5mm}..{3.45cm}+
  \istb  \istb  \endist
\xtdistance{12.5mm}{11.5mm}
\istrooto(1)(0-1){1}
  \istb{}{3}[center]  \istb{}{4}[center]
  \istb{}{5}[center]  \endist
\istrooto(2)(0-2){2}
  \istb{}{6}[center]  \istb{}{7}[center]  \endist
\end{istgame}
\end{tcblisting}

Numbers increase upward (or counterclockwise).

\subsubsection{A tree growing east -- clockwise}

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example 4: \setistgrowdirection'{east}
\begin{istgame}
\setistgrowdirection'{east}
% same code as in Example 1
\setistOvalNodeStyle{.6cm}
\xtShowEndPoints[oval node]
\istrooto(0){0}+{12.5mm}..{3.45cm}+
  \istb  \istb  \endist
\xtdistance{12.5mm}{11.5mm}
\istrooto(1)(0-1){1}
  \istb{}{3}[center]  \istb{}{4}[center]
  \istb{}{5}[center]  \endist
\istrooto(2)(0-2){2}
  \istb{}{6}[center]  \istb{}{7}[center]  \endist
\end{istgame}
\end{tcblisting}

Here, numbers increase downward (or clockwise).
This looks more natural.

\subsubsection{A tree growing north -- counterclockwise}

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example 5: \setistgrowdirection{north}
\begin{istgame}
\setistgrowdirection{north}
% same code as in Example 1
\setistOvalNodeStyle{.6cm}
\xtShowEndPoints[oval node]
\istrooto(0){0}+{12.5mm}..{3.45cm}+
  \istb  \istb  \endist
\xtdistance{12.5mm}{11.5mm}
\istrooto(1)(0-1){1}
  \istb{}{3}[center]  \istb{}{4}[center]
  \istb{}{5}[center]  \endist
\istrooto(2)(0-2){2}
  \istb{}{6}[center]  \istb{}{7}[center]  \endist
\end{istgame}
\end{tcblisting}

Numbers increase from right to left (or counterclockwise).

\subsubsection{A tree growing north - clockwise}

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth}
% Example 6: \setistgrowdirection'{north}
\begin{istgame}
\setistgrowdirection'{north}
\setistOvalNodeStyle{.6cm}
\xtShowEndPoints[oval node]
\xtdistance{12.5mm}{11.5mm}
\istrooto(0){0}+{12.5mm}..{3.45cm}+
  \istb  \istb  \endist
\xtdistance{12.5mm}{11.5mm}
\istrooto(1)(0-1){1}
  \istb{}{3}[center]  \istb{}{4}[center]
  \istb{}{5}[center]  \endist
\istrooto(2)(0-2){2}
  \istb{}{6}[center]  \istb{}{7}[center]  \endist
\end{istgame}
\end{tcblisting}

Numbers increase from left to right (or clockwise).
This looks more natural.

\subsubsection{\protect\cmd{\setistgrowkey} for one simple tree}

\icmd{\setistgrowkey} can be used to change the key between \xw{grow} and \xw{grow'}, which is useful especially for one simple tree, not a whole tree.


\begin{tcblisting}{listing only}
% \setistgrowkey: definition
\NewDocumentCommand\setistgrowkey{m}
{ \renewcommand\xtgrow{#1}
}
% #1 is either grow or grow'
\end{tcblisting}

In the following example, by using \cmd{\setistgrowdirection'} the branches are arranged clockwise.
So you will need to use \cmd{\setistgrow\{grow\}} to locally get back to `counterclockwise.'

\begin{tcblisting}{listing outside text, righthand width=.25\linewidth}
% Example: using \setistgrowdirection' (swap version)
\begin{istgame}
\setistgrowdirection'{east}
\istroot(0) 
  \istb{a}[al]  \istb{b}[bl]  \endist
\istroot[north](1)(0-1) 
  \istb{c}[bl]  \istb{d}[br]  \endist
{\setistgrowkey{grow}
\istroot[south](2)(0-2) 
  \istb{e}[al]  \istb{f}[ar]  \endist
}
\istroot(3)(2-2) 
  \istb{g}[al]  \istb{h}[bl]  \endist
\end{istgame}
\end{tcblisting}

You can do the same thing by using \cmd{\setistgrowdirection} and \cmd{\istroot'}. See the following example, in which
you do not need to use \cmd{\setistgrowkey}.

\begin{tcblisting}{listing outside text, righthand width=.25\linewidth}
% Example: using \istroot' (swap version)
\begin{istgame}
\setistgrowdirection{east}
\istroot'(0) 
  \istb{a}[al]  \istb{b}[bl]  \endist
\istroot'[north](1)(0-1) 
  \istb{c}[bl]  \istb{d}[br]  \endist
\istroot[south](2)(0-2) 
  \istb{e}[al]  \istb{f}[ar]  \endist
\istroot'(3)(2-2) 
  \istb{g}[al]  \istb{h}[bl]  \endist
\end{istgame}
\end{tcblisting}


\section{Information sets}

\label{sec:infoset}

\subsection{Information sets: \protect\cmd{\xtInfoset(')}}

The macro \icmd{\xtInfoset} draws an information set, connecting two decision nodes.

\begin{tcblisting}{listing only}
% \xtInfoset
% syntax: from left to right
\xtInfoset[<info line type>](<from>)(<to>){<owner>}[<pos>,<node opt>]
% defaults:
[semithick,dotted]()(){}[above]
\end{tcblisting}

\begin{tcblisting}{listing outside text, righthand width=.25\linewidth}
% Example: \xtInfoset
\begin{istgame}
\istroot(0){1}+15mm..30mm+
  \istb{a} \istb{b} \endist
\istroot(1)(0-1)
  \istb{c} \istb{d} \endist
\istroot(2)(0-2)
  \istb{c'} \istb{d'} \endist
\xtInfoset(1)(2){2}
\end{istgame}
\end{tcblisting}

\mbigskip1
The swap version \icmd{\xtInfoset'} is provided, which is not very interested.

\begin{tcblisting}{listing only}
% \xtInfoset' (from right to left)
% syntax:
\xtInfoset'[<info line type>](<from>)(<to>){<owner>}[<pos>,<node opt>]
% defaults:
[semithick,dotted]()(){}[above]
\end{tcblisting}

\cmd{\xtInfoset'} connects two nodes from the coordinate \xw{(<to>)} to the coordinate \xw{(<from>)}, while \cmd{\xtInfoset} from the coordinate \xw{(<from>)} to the coordinate \xw{(<to>)}. So, basically, the two macros give the same result, without arrow tips.

\begin{tcblisting}{listing outside text, righthand width=.25\linewidth}
% Example: \xtInfoset'
\begin{istgame}
\setistgrowdirection'{east}
\istroot(0){1}+15mm..30mm+
  \istb{a} \istb{b} \endist
\istroot(1)(0-1)
  \istb{c} \istb{d} \endist
\istroot(2)(0-2)
  \istb{c'} \istb{d'} \endist
\xtInfoset'[->,very thick,red](1)(2){2}[left,blue]
\end{istgame}
\end{tcblisting}


\subsection{Information sets: \protect\cmd{\xtInfosetO(')} (experimental)}

The oval version \icmd{\xtInfosetO} prints a bubble type information set. (experimental!)


\begin{tcblisting}{listing only}
% \stInfosetO (from left to right)
% syntax:
\xtInfosetO[<info line type>](<from>)(<to>){<owner>}[<pos>,<node opt>](<sep>)
\end{tcblisting}

\cmd{\xtInfosetO} prints a dotted rectangle with rounded corners, connecting two nodes.
The size of the information set can be changes by the \xw{(<sep>)} option, whose default value is \xw{4pt}.


\begin{tcblisting}{listing outside text, righthand width=.25\linewidth}
% Example: \setistgrowdirection{south} -- default
\begin{istgame}
\istroot(0){1}+15mm..30mm+
  \istb{a} \istb{b} \endist
\istroot(1)(0-1)
  \istb{c} \istb{d} \endist
\istroot(2)(0-2)
  \istb{c'} \istb{d'} \endist
\xtInfosetO(1)(2){2}
\end{istgame}
\end{tcblisting}


\begin{tcblisting}{listing outside text, righthand width=.25\linewidth}
% Example: \setistgrowdirection'{east}
\begin{istgame}
\setistgrowdirection'{east}
\istroot(0){1}+15mm..30mm+
  \istb{a} \istb{b} \endist
\istroot(1)(0-1)
  \istb{c} \istb{d} \endist
\istroot(2)(0-2)
  \istb{c'} \istb{d'} \endist
\xtInfosetO(1)(2){2}
\end{istgame}
\end{tcblisting}

You can change the color or the size of the information set by using options, as shown in the following example:

\begin{tcblisting}{listing outside text, righthand width=.25\linewidth}
% Example: \setistgrowdirection'{north}
\begin{istgame}
\setistgrowdirection'{north}
\istroot(0){1}+15mm..30mm+
  \istb{a} \istb{b} \endist
\istroot(1)(0-1)
  \istb{c} \istb{d} \endist
\istroot(2)(0-2)
  \istb{c'} \istb{d'} \endist
\xtInfosetO[fill=blue!20](1)(2){2}(6pt){1pt}
\end{istgame}
\end{tcblisting}


\mbigskip2

The swap version \icmd{\xtInfosetO'} is also provided, which you should be aware of.

\begin{tcblisting}{listing only}
% \xtInfosetO' (from right to left)
% syntax: 
\xtInfosetO'[<info line type>](<from>)(<to>){<owner>}[<pos>,<node opt>](<sep>)
% defaults:
[semithick,densely dotted]()(){}[](4pt)
\end{tcblisting}

When do we need the swap version \cmd{\xtInfosetO'}?
Let's look at the following example, where you would not be satisfied with how the information sets look.

\begin{tcblisting}{listing outside text, righthand width=.25\linewidth}
% Example: \setistgrowdirection{north}
\begin{istgame}
\setistgrowdirection{north}
\istroot(0){1}+15mm..30mm+
  \istb{a} \istb{b} \endist
\istroot(1)(0-1)
  \istb{c} \istb{d} \endist
\istroot(2)(0-2)
  \istb{c'} \istb{d'} \endist
\xtInfosetO(1)(2){2}
\xtInfosetO'(1-1)(1-2){1}(6pt)
\end{istgame}
\end{tcblisting}


The rule of thumb for using \cmd{\xtInfosetO'} is this: whenever the bubbled information set turns out to be short, 
use the swap version. You can use \cmd{\xtInfosetO} and \cmd{\xtInfosetO'} interchangeably, to get correct results.

More precisely, if you follow the tips about the combinations of \cmd{\setistgrowdirection(')} and the compass directions, as suggested on page \pageref{page:growtips}, you will get correct results.
However, if you use the combinations other than the suggestions, you will probably get the short information set. Then, use \cmd{\xtInfosetO'}.

%\clearpage

\section{Continuum of branches}

The package \pkg{istgame} provides two types of macros to represent a \ixw{continuum of branches}: \cmd{\istcntm} and \cmd{\istcntmarc}. Each of the two macros, basically, works like \cmd{\istroot}, but just draws a background to express a continuum of branches.

\subsection{\protect\cmd{\istcntm} (standard version)}

\subsubsection{Basics}

The first type macro \icmd{\istcntm} is the standard version. This, in fact, draws a background with the optional color filled representing a continuum of branches (the default color is \verb|black!25|).
The shape of the background is a isosceles triangle, with the height of \icmd{\cntmlevdist} (\xw{8mm} by default) and the base of \icmd{\cntmsibdist} (initially \xw{3*8mm} or \xw{24mm} by default).


\begin{tcblisting}{listing only}
% \istcntm
% syntax: 
\istcntm[<grow keyval>](<coor1>)(<coor2>)[<fill color>]+<levdist>..<sibdist>+
% defaults: 
[south]()(0,0)[black!25]+8mm..3*8mm+
\end{tcblisting}

%\mbigskip1

Using \cmd{\istroot} with \cmd{\istcntm} draws a representative branch of a continuum of branches.
Note, in the following example, that the second branch of \cmd{\istroot} is \xw{missing} to express the representative branch among a continuum of branches. Again, \cmd{\cntmlevdist} is \xw{8mm} by default.

\begin{tcblisting}{listing outside text, righthand width=.25\linewidth}
% Example: \istcntm
\begin{istgame}[scale=1.2]
\istcntm(ctm)
\istroot(0)(ctm){I}+\cntmlevdist..\cntmlevdist+
  \istb{x}[r]  \istb<missing>  \endist
\xtdistance{10mm}{20mm}
\istroot(1)(0-1)<[label distance=-3pt]120>{II}
  \istb{Y}[al]{x,1-x}  \istb{N}[ar]{0,0}  \endist
\end{istgame}
\end{tcblisting}


\subsubsection{Changing the size and the color of a continuum of branches}

You can change the height (or the level distance) and the base (or the sibling distance) of the background isosceles triangle by specifying them, for example, like \xw{+10mm..20mm+}.

\begin{tcblisting}{listing outside text, righthand width=.25\linewidth}
% Example: \istcntm (changing the size)
\begin{istgame}
\istcntm(cntm)+10mm..20mm+
\istroot(0)(cntm){1}+10mm..10mm+
  \istb<missing>  \istb{x}[l]  \endist
\end{istgame}
\end{tcblisting}

Once the distances are type in as options of \cmd{\istcntm}, they internally change the default values, which apply only to the corresponding triangle.
For example, \xw{+10mm..20mm+} will result in \cmd{\cntmlevdist=10mm} and \cmd{\cntmsibdist=20mm}.
So you can get exactly the same result as previous one by doing the following:

\begin{tcblisting}{listing outside text, righthand width=.25\linewidth}
% Example: \istcntm (changing the size)
\begin{istgame}
\istcntm(cntm)+10mm..20mm+
\istroot(0)(cntm){1}+\cntmlevdist..\cntmlevdist+
  \istb<missing>  \istb{x}[l]  \endist
\end{istgame}
\end{tcblisting}

You can change the color of the background triangle by using an option as you can see in the following example:

\begin{tcblisting}{listing outside text, righthand width=.25\linewidth}
\begin{istgame}
\xtdistance{10mm}{20mm}
\istroot(0){1}
  \istb{A}[al]  \istb{B}[ar]{1,1}  \endist
\istcntm(cntm)(0-1)[green]+10mm..20mm+
\istroot(1)(cntm)<135>{2}+\cntmlevdist..\cntmlevdist+
  \istb<missing>  \istb{x}[l]  \endist
\istroot(2)(1-2)<[label distance=-4pt]45>{1}
  \istb{Y}[l]{3-x,x}  \istb{N}[r]{0,0}  \endist
\end{istgame}
\end{tcblisting}



\subsection{\protect\cmd{\istcntmarc} (arc version)}

The second type macro \icmd{\istcntmarc} is the arc version, which draws a background of two branches connected with an arc to represent a continuum of branches.

\begin{tcblisting}{listing only}
% \istcntmarc
% syntax: 
\istcntmarc[<grow keyval>](<coor1>)(<coor2>)[<color,opt>]{<num>}+levdist..sibdist+
% defaults: 
[south]()(0,0)[bend right]{.5}+8mm..3*8mm+
\end{tcblisting}

The option \xw{<num>} (\xw{0.5} by default) specifies 
the convex combination of the root and each of the background child nodes.
The smaller \xw{<num>} is, the closer is the connecting arc to the root.


\mbigskip1

\begin{tcblisting}{listing outside text, righthand width=.25\linewidth}
% Example: \istcntmarc
\begin{istgame}[scale=1.2]
\istcntmarc(ctm)
\istroot(0)(ctm){I}+\cntmlevdist..\cntmlevdist+
  \istb{x}[r]  \istb<missing>  \endist
\xtdistance{10mm}{18mm}
\istroot(1)(0-1)<[label distance=-3pt]120>{II}
  \istb{Y}[al]{x,1-x}  \istb{N}[ar]{0,0}  \endist
\end{istgame}
\end{tcblisting}

\mbigskip1

You can also change the line style and the curvature of the arc by options such as \xw{very thick}, \xw{red}, \xw{dotted}, and \xw{bend right=45}.


\begin{tcblisting}{listing outside text, righthand width=.25\linewidth}
% Example: \istcntmarc
\begin{istgame}[scale=1.2]
\istcntmarc(ctm)[bend right=45,very thick,red,dotted]{.65}
\istroot(0)(ctm){I}+\cntmlevdist..\cntmlevdist+
  \istb{x}[r]  \istb<missing>  \endist
\xtdistance{10mm}{18mm}
\istroot(1)(0-1)<[label distance=-3pt]120>{II}
  \istb{Y}[al]{x,1-x}  \istb{N}[ar]{0,0}  \endist
\end{istgame}
\end{tcblisting}

You can change the length of background branches connected by an arc in the same manner as used in \cmd{\istcntm}.


\subsection{Examples}

In the following example, the base angle of the background isosceles triangle is 30\textdegree.
 
\begin{tcblisting}{listing outside text, righthand width=.25\linewidth}
% Example: \istcntm and \istcntmarc
\begin{istgame}[scale=1.2]
\istcntm(period1)[green]+8mm..2*sqrt(3)*8mm+
\istroot(0)(period1){I}+\cntmlevdist..\cntmlevdist+
  \istb{x}[r]
  \istb<missing>
  \endist
\xtdistance{10mm}{20mm}
\istroot(1)(0-1)<[label distance=-3pt]120>{II}
  \istb{Y}[al]{x,1-x}
  \istb{N}[ar]
  \endist
%---------------------------------------------------------
\istcntmarc(period2)(1-2)%
    [thick,dashed,red]+8mm..2*sqrt(3)*8mm+
\istroot(2)(period2){II}+\cntmlevdist..\cntmlevdist+
  \istb{y}[r]
  \istb<missing>
  \endist
\xtdistance{10mm}{20mm}
\istroot(3)(2-1)<[label distance=-3pt]120>{I}
  \istb{Y}[al]{1-y,y}
  \istb{N}[ar]{0,0}
  \endist
\end{istgame}
\end{tcblisting}

\mbigskip1

You can also rotate a tree with a continuum of branches.
When it is necessary, you should use \xw{[bend left]} to get a correct result as shown in the following example:

\begin{tcblisting}{listing outside text, righthand width=.25\linewidth}
% Example: tree growing east
\begin{istgame}[scale=1.2]
\setistgrowdirection'{east}
\istcntm(period1)[green]+8mm..2*sqrt(3)*8mm+
\istroot(0)(period1)<180>{I}+\cntmlevdist..\cntmlevdist+
  \istb{x}[b]
  \istb<missing>
  \endist
\xtdistance{10mm}{20mm}
\istroot(1)(0-1)<[label distance=-3pt]120>{II}
  \istb{Y}[al]{x,1-x}
  \istb{N}[bl]
  \endist
%---------------------------------------------------------
\istcntmarc(period2)(1-2)%
    [bend left=45,thick,dashed,red]+8mm..2*sqrt(3)*8mm+
\istroot(2)(period2)<180>{II}+\cntmlevdist..\cntmlevdist+
  \istb{y}[b]
  \istb<missing>
  \endist
\xtdistance{10mm}{20mm}
\istroot(3)(2-1)<[label distance=-3pt]120>{I}
  \istb{Y}[al]{1-y,y}
  \istb{N}[bl]{0,0}
  \endist
\end{istgame}
\end{tcblisting}


\section{Auxiliary macros}

\label{sec:auxmac}

The \pkg{istgame} package also provides some auxiliary macors, which enable you to add players, action labels, payoffs, and others to your tree.

\begin{description}\tightlist
\item
\icmd{\xtInfosetOwner} is an auxiliary tool for putting the owner of an information set.
\item
\icmd{\xtActionLabel} is an auxiliary tool for putting an action label to a branch.
\item
\icmd{\xtOwner} is an auxiliary tool for putting the owner of a node (or a player).
\item
\icmd{\xtPayoff} is an auxiliary tool for putting payoffs.
\item
\icmd{\xtNode} is another tool for putting `something' into a node. This `something' could be the owner of a node. 
\item
\icmd{\xtNode*} puts `something' into a \ixw{plain node}.
\end{description}

syntax: \xw{\xtInfosetOwner(<from>)(<to>){<owner>}[<pos>,<node opt>]}

syntax: \xw{\xtActionLabel(<from>)(<to>){<action>}[<pos>,<node opt>]}

syntax: \xw{\xtOwner(<coor>){<owner>}[<pos>,<node opt>]}

syntax: \xw{\xtPayoff(<coor>){<payoff>}[<pos>,<node opt>]}

syntax: \xw{\xtNode[<opt>](<coor>)[<node style>,<node opt>]\{owner\}}

syntax: \xw{\xtNode*(<coor>)\{owner\}}

\mbigskip1
The auxiliary macros depend on the coordinates defined in the sequence of \cmd{\istroot}--\cmd{\istb}--\cmd{\endist} and print their corresponding objects on or around the specified coordinates.
So, in the above auxiliary macros, all the coordinates such as \xw{(<from>)}, \xw{(<to>)}, and \xw{(<coor>)} are mandatory arguments.

\begin{tcblisting}{}
% Example: auxiliary macros
\begin{istgame}[scale=2]
\istroot(0)[chance node]
  \istb[dashed]{A}
  \istb*
  \istb*[blue,very thick]{B}[right,xshift=2pt,yshift=2pt,red]
  \endist
\xtInfosetO(0)(0)(2.5pt)
\xtInfoset[thick](0-1)(0-2){1}
\xtInfosetO[thick,red](0-2)(0-3){2}
\xtInfoset[dashed,bend right=25](0-1)(0-3)
%-----------------
\xtActionLabel(0)(0-3){\epsilon}[bl] % action label in math mode
\xtInfosetOwner(0-1)(0-3){3}[xshift=-25pt,yshift=-25pt]
\xtOwner(0){Nash}[xshift=-5pt,left]
\xtPayoff(0-3){(u_1,u_2)}[right,xshift=5pt] % payoffs in math mode
\xtNode[dotted](0-1)[box node,fill=blue!20]{Smith}
%-----------------
\istroot[east](a)(0)[chance node]
  \istb \endist
\xtNode*(a-1){text}
\end{istgame}
\end{tcblisting}

To specify the \xw{[<pos>]} option for the above auxiliary macros (other than \cmd{\xtNode}), 
you can use the abbreviations 
\xw{[l]}, \xw{[r]}, \xw{[a]}, \xw{[b]}, \xw{[al]}, \xw{[ar]}, \xw{[bl]}, and \xw{[br]}.
Each of these abbreviations works only when used alone without any other option keys within brackets.
For example, the option \xw{[b]} or \xw{[below]} or \xw{[below,xshift=5pt]} works, but not \xw{[b,xshift=5pt]}.

\mbigskip1

\begin{tcblisting}{listing above text, righthand width=.3\linewidth,breakable}
% Example: 
\begin{istgame}[font=\scriptsize]
\xtdistance{10mm}{20mm}
\istcntm(ctm)       % period 1
\istroot(1)(ctm){1}+\cntmlevdist..10mm+
  \istb{x}[r]
  \istb<missing>
  \endist
\istroot(A1)(1-1)<[label distance=-3pt]135>{2}
  \istb{A}[al]{x,1-x}
  \istb{R}[ar]
  \endist
\xtOwner(1){period 1}[xshift=30mm]
\istcntm(ctm)(A1-2) % period 2
\istroot(2)(ctm){2}+\cntmlevdist..10mm+
  \istb{y}[r]
  \istb<missing>
  \endist
\istroot(A2)(2-1)<[label distance=-3pt]135>{1}
  \istb{A}[al]{1-y,y}
  \istb{R}[ar]
  \endist
\xtOwner(2){period 2}[xshift=25mm]
\xtPayoff(A2-1){\left(\makecell{\delta\\\delta}\right)\cdots}[below,xshift=-40pt]
\istcntm(ctm)(A2-2) % period 3
\istroot(3)(ctm){1}+\cntmlevdist..10mm+
  \istb{x}[r]
  \istb<missing>
  \endist
\istroot(A3)(3-1)<[label distance=-3pt]135>{2}
  \istb{A}[al]{x,1-x}
  \istb{R}[ar]{0,0}
  \endist
\xtOwner(3){period 3}[xshift=20mm]
\xtPayoff(A3-1){\left(\makecell{\delta^2\\\delta^2}\right)\cdots}[below,xshift=-50pt]
\end{istgame}
\end{tcblisting}

%\subsection{More supplement macros}
%
%\indent\indent 
%syntax: \xw{\xtShowEndPoints[<node style>]}
%
%syntax: \xw{\xtHideEndPoints[<node style>]}
%
%syntax: \xw{\xtShowTerminalNodes[<node style>]} % work with \istb.
%
%syntax: \xw{\xtHideTerminalNodes[<node style>]}
%
%\mbigskip2
%
%\icmd{\xtShowEndPoints} is to control the node shape of every endpoint of every simple tree. 
%(For more details, see page \pageref{page:endpoint}.)
%
%\icmd{\xtHideEndPoints} turns off the effect of \cmd{\xtShowEndPoints}.
%
%\icmd{\xtShowTerminalNodes} works only with \cmd{\istb.}\@ to control the node shape of terminal nodes. 
%(For more details, see page \pageref{page:terminalnode}.)
%
%\icmd{\xtHideTerminalNodes} turns off the effect of \cmd{\xtShowTerminalNodes}.

\section{Representing subgames}

Here is an example of a whole game tree.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth,breakable}
\begin{istgame}
\xtdistance{15mm}{30mm}
\istroot[-135](0)[initial node]<0>{1}
  \istb{A}[a]{(2,2)}[l]  \istb{D}[r]  \endist 
\istroot(1)(0-2)<135>{1}
  \istb{L}[al]  \istb{R}[ar]  \endist 
\xtdistance{10mm}{20mm}
\istroot(2)(1-1)<135>{2}
  \istb{\ell}[al]{(4,2)}  \istb{r}[ar]{(1,1)}  \endist 
\istroot(3)(1-2)<45>{2}
  \istb{\ell}[al]{(3,2)}  \istb{r}[ar]{(0,3)}  \endist 
\end{istgame}
\end{tcblisting}

\subsection{\protect\cmd{\xtSubgameBox(*)} (experimental)}

\subsubsection{\protect\cmd{\xtSubgameBox}}

\icmd{\xtSubgameBox} is for indicating a \ixw{subgame} by a box (or a rectangle) with rounded corners.

\begin{tcblisting}{listing only}
% \xtSubgameBox(*)
% syntax:
  \xtSubgame(*)(<subroot coor>){(<coor1>) (<coor2>) ... }[<opt>]
% options:
  *: filled box
  (<subroot coor>): the subroot of a subgame (mandatory)
  {(coor1) (coor2) ...}: coordinates of terminal nodes (mandatory)
  [<opt>]: color, line style
% defaults:
  (){}[rectangle,dashed,inner sep=20pt,rounded corners=15pt,black!50]
  *(){}[rectangle,inner sep=20pt,rounded corners=15pt,red!20]
\end{tcblisting}


%\begin{tcblisting}{listing only}
%% \xtSubgameBox(*)
%% syntax:
%   \xtSubgame(*)(<subroot coor>){(<coor1>) (<coor2>) ... }[<opt>]
%%% \xtSubgameBox: definition
%\def\xtdefaultsubrootshiftoval{0,-.3}
%\NewDocumentCommand\xtSubgameBox{ s r() m O{} }
%{ \IfBooleanTF #1
%  {
%  \coordinate (xtsubroot) at ($(#2)+(\xtdefaultsubrootshiftoval)$);
%  \begin{scope}[on background layer]
%    \node [rectangle,fill=red!20,inner sep=20pt,rounded corners=15pt,#4] 
%              [fit=(xtsubroot) #3] {};
%  \end{scope}
%  }
%  {
%  \coordinate (xtsubroot) at ($(#2)+(0,-.3)$);
%  \begin{scope}[on background layer]
%  \node [rectangle,draw,dashed,inner sep=20pt,rounded corners=15pt,black!50,#4] 
%            [fit=(xtsubroot) #3] {};
%  \end{scope}
%  }
%}
%\end{tcblisting}


The subgame box embraces the subroot indicated in parentheses and terminal nodes specified within curly braces.
The coordinates of terminal nodes are listed in curly braces without delimiters (spaces are allowed).
The default options for the subgame box are \xw{dashed}, \xw{inner sep=20pt}, \xw{rounded corners=15pt}, and \xw{black!50}.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth,breakable}
% subgame: rectangle
\begin{istgame}
\xtdistance{15mm}{30mm}
\istroot[-135](0)[initial node]<0>{1}
  \istb{A}[a]{(2,2)}[l]  \istb{D}[r]  \endist 
\istroot(1)(0-2)<135>{1}
  \istb{L}[al]  \istb{R}[ar]  \endist 
\xtdistance{10mm}{20mm}
\istroot(2)(1-1)<135>{2}
  \istb{\ell}[al]{(4,2)}  \istb{r}[ar]{(1,1)}  \endist 
\istroot(3)(1-2)<45>{2}
  \istb{\ell}[al]{(3,2)}  \istb{r}[ar]{(0,3)}  \endist 
\xtSubgameBox(1){(2-1)(3-2)}
\xtSubgameBox(2){(2-1)(2-2)}[solid,blue]
\end{istgame}
\end{tcblisting}

You can change the size of the box in two ways.
First, you can change it by using \xw{inner sep}, \xw{inner xsep}, or \xw{inner ysep}. Secondly, you can shift the subroot, like \xw{([xshift=5pt]1)} when the subroot is \xw{(1)}.
Of course, you can do the both at the same time.

% subgame: rectangle (inner sep,yshift)
\begin{tcblisting}{listing outside text, righthand width=.3\linewidth,breakable}
\begin{istgame}
\xtdistance{15mm}{30mm}
\istroot[-135](0)[initial node]<0>{1}
  \istb{A}[a]{(2,2)}[l]  \istb{D}[r]  \endist 
\istroot(1)(0-2)<135>{1}
  \istb{L}[al]  \istb{R}[ar]  \endist 
\xtdistance{10mm}{20mm}
\istroot(2)(1-1)<135>{2}
  \istb{\ell}[al]{(4,2)}  \istb{r}[ar]{(1,1)}  \endist 
\istroot(3)(1-2)<45>{2}
  \istb{\ell}[al]{(3,2)}  \istb{r}[ar]{(0,3)}  \endist 
\xtSubgameBox(1){(2-1)(3-2)}
\xtSubgameBox([yshift=5pt]2){(2-1)(2-2)}%
    [solid,blue,inner sep=10pt]
\end{istgame}
\end{tcblisting}


\subsubsection{\protect\cmd{\xtSubgameBox*}}

The starred version \icmd{\xtSubgameBox*} produces a subgame box with background color (by default \xw{red!20}).
In the following example, where the tree grows east, the size of the filled subgame box is adjusted by manipulating \xw{inner sep} and \xw{xshift}.

\begin{tcblisting}{listing outside text, righthand width=.3\linewidth,breakable}
% subgame: rectangle*
\begin{istgame}
\setistgrowdirection'{east}
\xtdistance{15mm}{30mm}
\istroot[45](0)[initial node]<180>{1}
  \istb{A}[l]{(2,2)}[a]  \istb{D}[b]  \endist 
\istroot(1)(0-2)<135>{1}
  \istb{L}[al]  \istb{R}[bl]  \endist 
\xtdistance{10mm}{20mm}
\istroot(2)(1-1)<135>{2}
  \istb{\ell}[al]{(4,2)}  \istb{r}[bl]{(1,1)}  \endist 
\istroot(3)(1-2)<-135>{2}
  \istb{\ell}[al]{(3,2)}  \istb{r}[bl]{(0,3)}  \endist 
\xtSubgameBox*([xshift=20pt]1){(2-1)(3-2)}%
    [inner xsep=30pt]
\end{istgame}
\end{tcblisting}


\subsection{\protect\cmd{\xtSubgameOval(*)} (experimental)}

\icmd{\xtSubgameOval} and \icmd{\xtSubgameOval*} are also provided.

\begin{tcblisting}{listing only}
% \xtSubgameOval(*)
% syntax:
  \xtSubgameOval(*)(<subroot coor>){(<coor1>) (<coor2>) ... }[<opt>]
% options:
  *: filled box
  (<subroot coor>): the subroot of a subgame (mandatory)
  {(coor1) (coor2) ...}: coordinates of terminal nodes (mandatory)
  [<opt>]: color, line style
% defaults:
  (){}[ellipse,dashed,inner sep=20pt,rounded corners=15pt,black!50]
  *(){}[ellipse,inner sep=20pt,rounded corners=15pt,red!20]
\end{tcblisting}


%\begin{tcblisting}{listing only}
%% \xtSubgameOval(*)
%% syntax:
%   \xtSubgame(*)(<subroot coor>){(<coor1>) (<coor2>) ... }[<opt>]
%%% \xtSubgameOval: definition
%\def\xtdefaultsubrootshiftoval{0,-.7}
%\DeclareDocumentCommand\xtSubgameOval{ s r() m O{}}
%{ \IfBooleanTF #1
%  {
%  \coordinate (xtsubroot) at ($(#2)+(\xtdefaultsubrootshiftoval)$);
%  \begin{scope}[on background layer]
%    \node [ellipse,fill=red!20,inner sep=15pt,#4] 
%              [fit=(xtsubroot) #3] {};
%  \end{scope}
%  }
%  {
%  \coordinate (xtsubroot) at ($(#2)+(0,-.7)$);
%  \begin{scope}[on background layer]
%  \node [ellipse,draw,dashed,inner sep=15pt,black!50,#4] 
%            [fit=(xtsubroot) #3] {};
%  \end{scope}
%  }
%}
%\end{tcblisting}

\cmd{\xtSubgameOval(*)} works just like \cmd{\xtSubgameBox(*)}, except for one thing: an oval instead of a rectangle.
\cmd{\xtSubgameOval} draws an oval (or an ellipse) to represent a subgame, and \cmd{\xtSubgameOval*} draws a filled oval with \xw{red!20} by default.


\begin{tcblisting}{listing outside text, righthand width=.4\linewidth,breakable}
% subgame: ellipse
\begin{istgame}
\xtdistance{15mm}{30mm}
\istroot[-135](0)[initial node]<0>{1}
  \istb{A}[a]{(2,2)}[l]
  \istb{D}[r]
  \endist 
\istroot(1)(0-2)<135>{1}
  \istb{L}[al]
  \istb{R}[ar]
  \endist 
\xtdistance{10mm}{20mm}
\istroot(2)(1-1)<135>{2}
  \istb{\ell}[al]{(4,2)}
  \istb{r}[ar]{(1,1)}
  \endist 
\istroot(3)(1-2)<45>{2}
  \istb{\ell}[al]{(3,2)}
  \istb{r}[ar]{(0,3)}
  \endist 
\xtSubgameOval(1){(2-1)(3-2)}
\xtSubgameOval(2){(2-1)(2-2)}
\end{istgame}
\end{tcblisting}

\mbigskip1

The way of changing the size of the subgame oval is the same as with \cmd{\xtSubgameBox}: first, changing inner sep, and secondly, shifting the subroot.
In the following example, the options \xw{inner xsep=25pt} and \xw{([xshift=30pt]1)} are used to change the size of the subgame oval. Its color is changed by \xw{blue!20}.

\begin{tcblisting}{listing outside text, righthand width=.4\linewidth,breakable}
% subgame: ellipse*
\begin{istgame}
\setistgrowdirection'{east}
\xtdistance{15mm}{30mm}
\istroot[45](0)[initial node]<180>{1}
  \istb{A}[l]{(2,2)}[a]
  \istb{D}[b]
  \endist 
\istroot(1)(0-2)<135>{1}
  \istb{L}[al]
  \istb{R}[bl]
  \endist 
\xtdistance{10mm}{20mm}
\istroot(2)(1-1)<135>{2}
  \istb{\ell}[al]{(4,2)}
  \istb{r}[bl]{(1,1)}
  \endist 
\istroot(3)(1-2)<-135>{2}
  \istb{\ell}[al]{(3,2)}
  \istb{r}[bl]{(0,3)}
  \endist 
\xtSubgameOval*([xshift=30pt]1){(2-1)(3-2)}%
    [inner xsep=25pt,blue!20]
\end{istgame}
\end{tcblisting}

\subsection{More examples}

You can change the shape of a subgame repesentation to other shapes such as \xw{semicircle} and \xw{circle} or even \xw{star}. You will need to change the size of the shape by using \xw{inner sep} and by shifting the subroot to get the result you want.

\begin{tcblisting}{listing outside text, righthand width=.4\linewidth,breakable}
% subgame: half circle
\begin{istgame}
\xtdistance{15mm}{30mm}
\istroot[-135](0)[initial node]<0>{1}
  \istb{A}[a]{(2,2)}[l]
  \istb{D}[r]
  \endist 
\istroot(1)(0-2)<135>{1}
  \istb{L}[al]
  \istb{R}[ar]
  \endist 
\xtdistance{10mm}{20mm}
\istroot(2)(1-1)<135>{2}
  \istb{\ell}[al]{(4,2)}
  \istb{r}[ar]{(1,1)}
  \endist 
\istroot(3)(1-2)<45>{2}
  \istb{\ell}[al]{(3,2)}
  \istb{r}[ar]{(0,3)}
  \endist 
\xtSubgameBox([yshift=-2cm]1){(2-1)(3-2)}%
    [semicircle,inner sep=15pt]
\end{istgame}
\end{tcblisting}


%\begin{tcblisting}{listing outside text, righthand width=.4\linewidth,breakable}
%% subgame: half circle*
%\begin{istgame}
%\setistgrowdirection'{east}
%\xtdistance{15mm}{30mm}
%\istroot[45](0)[initial node]<180>{1}
%  \istb{A}[l]{(2,2)}[a]
%  \istb{D}[b]
%  \endist 
%\istroot(1)(0-2)<135>{1}
%  \istb{L}[al]
%  \istb{R}[bl]
%  \endist 
%\xtdistance{10mm}{20mm}
%\istroot(2)(1-1)<135>{2}
%  \istb{\ell}[al]{(4,2)}
%  \istb{r}[bl]{(1,1)}
%  \endist 
%\istroot(3)(1-2)<-135>{2}
%  \istb{\ell}[al]{(3,2)}
%  \istb{r}[bl]{(0,3)}
%  \endist 
%\xtSubgameBox*([xshift=2cm]1){(2-1)(3-2)}%
%    [semicircle,rotate=90,inner sep=0pt]
%\end{istgame}
%\end{tcblisting}

Here is one more example, which shows how to draw a rectangle and circles to represent subgames.

\begin{tcblisting}{listing outside text, righthand width=.4\linewidth,breakable}
% subgame: rectangle*
\begin{istgame}
\xtdistance{15mm}{30mm}
\istroot[-135](0)[initial node]<0>{1}
  \istb{A}[a]{(2,2)}[l]
  \istb{D}[r]
  \endist 
\istroot(1)(0-2)<135>{1}
  \istb{L}[al]
  \istb{R}[ar]
  \endist 
\xtdistance{10mm}{20mm}
\istroot(2)(1-1)<135>{2}
  \istb{\ell}[al]{(4,2)}
  \istb{r}[ar]{(1,1)}
  \endist 
\istroot(3)(1-2)<45>{2}
  \istb{\ell}[al]{(3,2)}
  \istb{r}[ar]{(0,3)}
  \endist 
\xtSubgameBox*(1){(2-1)(3-2)}
\xtSubgameOval*(2){(2-1)(2-2)}%
  [circle,blue!20,inner xsep=9pt]
\xtSubgameOval(3){(3-1)(3-2)}%
  [circle,inner xsep=9pt]
\end{istgame}
\end{tcblisting}



\section{Miscellany}

\subsection{Various branch types, directions, and lengths} 

What follows is an example of how to deal with various line types, directions, and lengths of branches.

\mbigskip1
\begin{tcblisting}{breakable}
\begin{istgame}
\istroot(0)[chance node]<[blue]>{N}+10mm..30mm+
  \istb[->,shorten >=.8pt]{p}[above left,red]
  \istb[->,shorten >=.8pt]{1-p}[ar]
  \endist
\istroot(1)(0-1)+15mm..30mm+
  \istb<level distance=7mm,sibling distance=14mm>{L}[al]
  \istb*[->>>]{R}[ar]
  \endist
\istroot(2)(0-2)+10mm..15mm+
  \istb[->,dashed]{A}
  \istb<grow=30,level distance=30mm>[red]{a}[al]{(1,-1)}[[blue]right]
  \istb*<grow=-45>[blue,text=red,thick]{b}[ar]{(u_1,u_2)}[[green]-90]
  \endist
\end{istgame}
\end{tcblisting}


\subsection{Code reuse}

\subsubsection{Drawing subgames}

Suppose that you have the following tree as a whole game.

\begin{tcblisting}{listing outside text, righthand width=.4\linewidth,breakable}
% Example: a whole game
\begin{istgame}
\xtdistance{15mm}{30mm}
\istroot[-135](0)[initial node]<0>{1}
  \istb{A}[a]{(2,2)}[l]
  \istb{D}[r]
  \endist 
\istroot(1)(0-2)<left>{1}
  \istb{L}[al]
  \istb{R}[ar]
  \endist 
\xtdistance{10mm}{20mm}
\istroot(2)(1-1)<135>{2}
  \istb{\ell}[al]{(4,2)}
  \istb{r}[ar]{(1,1)}
  \endist 
\istroot(3)(1-2)<45>{2}
  \istb{\ell}[al]{(3,2)}
  \istb{r}[ar]{(0,3)}
  \endist 
\end{istgame}
\end{tcblisting}



It is easy to draw a subgame if you use the existing codes for a whole game.
To get a subgame, just comment out the codes for the rest of the subgame.

\begin{tcblisting}{listing outside text, righthand width=.4\linewidth,breakable}
% Example: a subgame
\begin{istgame}
\xtdistance{15mm}{30mm}
%\istroot[-135](0)[initial node]<0>{1}
%  \istb{A}[a]{(2,2)}[l]
%  \istb{D}[r]
%\endist 
\istroot(1)(0-2)<left>{1}
  \istb{L}[al]
  \istb{R}[ar]
  \endist 
\xtdistance{10mm}{20mm}
\istroot(2)(1-1)<135>{2}
  \istb{\ell}[al]{(4,2)}
  \istb{r}[ar]{(1,1)}
  \endist 
\istroot(3)(1-2)<45>{2}
  \istb{\ell}[al]{(3,2)}
  \istb{r}[ar]{(0,3)}
  \endist 
\end{istgame}
\end{tcblisting}

\mbigskip1

\remark If you copy and paste the previous codes alone and try to complie to get a subgame, you will get an error message: 

\verb+! Package pgf Error: No shape named 0-2 is known.+

\noindent 
This is because the first active \cmd{\istroot} refers to the undefined coordinate \xw(0-2). In this case you need to change the line as:

\verb+\istroot(1)(0,0)<left>{1}+

\noindent
However, if you have the codes for a whole game before the codes with some lines commented out for a subgame, you will not get the error message when you compile the file (because the coordinate \xw{(0-2)} is already defined in the whole game). 
Therefore, most of the time you will not get the error message by commenting out some lines to get a subgame.

\mbigskip1

A smaller subgame is also easy to get by commenting out the rest of the subgame you want.

\begin{tcblisting}{listing outside text, righthand width=.4\linewidth,breakable}
% Example: a smaller subgame
\begin{istgame}
%\xtdistance{15mm}{30mm}
%\istroot[-135](0)[initial node]<0>{1}
%  \istb{A}[a]{(2,2)}[l]
%  \istb{D}[r]
%\endist 
%\istroot(1)(0-2)<left>{1}
%  \istb{L}[al]
%  \istb{R}[ar]
%\endist 
\xtdistance{10mm}{20mm}
\istroot(2)(1-1)<135>{2}
  \istb{\ell}[al]{(4,2)}
  \istb{r}[ar]{(1,1)}
  \endist 
%\istroot(3)(1-2)<45>{2}
%  \istb{\ell}[al]{(3,2)}
%  \istb{r}[ar]{(0,3)}
%\endist 
\end{istgame}
\end{tcblisting}


It is not possible to make a subgame stay put where it appears in a whole game. 
(Repalce \xw{[black!5]} with \xw{[white]} to make the rest of the game disappear in the following example.)

\mbigskip1

\begin{tcblisting}{listing outside text, righthand width=.4\linewidth,breakable}
% Example: a subgame stays put
\begin{istgame}
\setistDecisionNodeStyle[black!5]
\xtdistance{15mm}{30mm}
\istroot[-135](0)%[initial node]<0>{1}
  \istb[black!5]%{A}[a]{(2,2)}[l]
  \istb[black!5]%{D}[r]
  \endist 
\istroot(1)(0-2)%<left>{1}
  \istb[black!5]%{L}[al]
  \istb[black!5]%{R}[ar]
  \endist 
\setistDecisionNodeStyle
\xtdistance{10mm}{20mm}
\istroot(2)(1-1)<135>{2}
  \istb{\ell}[al]{(4,2)}
  \istb{r}[ar]{(1,1)}
  \endist 
\setistDecisionNodeStyle[black!5]
\istroot(3)(1-2)%<45>{2}
  \istb[black!5]%{\ell}[al]{(3,2)}
  \istb[black!5]%{r}[ar]{(0,3)}
  \endist 
\end{istgame}
\end{tcblisting}



\subsubsection{Backward induction}

It is also easy to illustrate the procedure of backward induction, when you analyze an extensive game.
By using \cmd{\istb} with options, you can change the color and the style of a line representing a branch and an arrow tip to it.

\mbigskip1

\begin{tcblisting}{listing outside text, righthand width=.4\linewidth,breakable}
% Example: backward induction
\begin{istgame}
\xtdistance{15mm}{30mm}
\istroot[-135](0)[initial node]<0>{1}
  \istb[dashed]{A}[a]{(2,2)}[l]
  \istb[very thick]{D}[r]
  \endist 
\istroot(1)(0-2)<left>{1}
  \istb[very thick]{L}[al]
  \istb[dashed]{R}[ar]
  \endist 
\xtdistance{10mm}{20mm}
\istroot(2)(1-1)<135>{2}
  \istb[->>>,very thick,blue]{\ell}[al]{(4,2)}
  \istb[thick,dotted]{r}[ar]{(1,1)}
  \endist 
\istroot(3)(1-2)<45>{2}
  \istb[thick,dotted]{\ell}[al]{(3,2)}
  \istb[very thick,blue]{r}[ar]{(0,3)}
  \endist 
\end{istgame}
\end{tcblisting}


%\clearpage
\subsubsection{Code reusability}

Chen(2013)'s work is good to understand how drawing a game tree with \tikz works.

\begin{tcblisting}{listing above text}
% Chen (2013)
\begin{tikzpicture}[scale=1,font=\footnotesize]
\tikzstyle{solid node}=[circle,draw,inner sep=1.5,fill=black]
\tikzstyle{hollow node}=[circle,draw,inner sep=1.5]
\tikzstyle{level 1}=[level distance=15mm,sibling distance=3.5cm]
\tikzstyle{level 2}=[level distance=15mm,sibling distance=1.5cm]
\tikzstyle{level 3}=[level distance=15mm,sibling distance=1cm]
\node(0)[solid node,label=above:{$P1$}]{}
child{node[solid node,label=above left:{$P2$}]{}
child{node[hollow node,label=below:{$(1,2)$}]{} edge from parent node[left]{$C$}}
child{node[hollow node,label=below:{$(1,-1)$}]{} edge from parent node[left]{$D$}}
child{node[hollow node,label=below:{$(0,2)$}]{} edge from parent node[right]{$E$}}
edge from parent node[left,xshift=-5]{$A$}
}
child{node[solid node,label=above right:{$P2$}]{}
child{node[hollow node,label=below:{$(2,2)$}]{} edge from parent node[left]{$F$}}
child{node[hollow node,label=below:{$(1,3)$}]{} edge from parent node[right]{$G$}}
edge from parent node[right,xshift=5]{$B$}
};
\end{tikzpicture}
\end{tcblisting}

%\mbigskip1

You can get a quite similar (actually the same) result by using the \pkg{istgame} package.

\begin{tcblisting}{listing outside text, righthand width=.4\linewidth}
% istgame
\begin{istgame}[scale=1,font=\footnotesize]
\setistDecisionNodeStyle{4pt}
\xtdistance{15mm}{3.5cm}
\istroot(0){$P1$}
\istb{A}[al]
\istb{B}[ar]
\endist
\xtShowEndPoints[oval node]
\xtdistance{15mm}{1.5cm}
\istroot(1)(0-1)<135>{$P2$}
\istb{C}[l]{(1,2)}
\istb{D}[l]{(1,-1)}
\istb{E}[r]{0,2)}
\endist
\istroot(2)(0-2)<45>{$P2$}
\istb{F}[l]{(2,2)}
\istb{G}[r]{(1,3)}
\endist
\end{istgame}
\end{tcblisting}


The \pkg{istgame} package enhances simplicity and readability, and hence it is easy to reuse codes. You can easily read and modify game tree codes even if you go over them after a while.

%\clearpage
\section{Game tree examples}

This section provides some examples of extensive games.
Before we start, let us change the default fontsize of the \env{istgame} environment by stating
\cmd{\setistgamefontsize\{\cmd{\footnotesize\}}} outside of the environment. (Right here!)

\setistgamefontsize{\footnotesize}

\subsection{Simple examples}


\begin{tcblisting}{listing outside text, righthand width=.4\linewidth,breakable}
\begin{istgame}[->,>=stealth,shorten >=.8pt]
\xtdistance{15mm}{30mm}
\istroot(0)[initial node]{Child}
  \istb{Good}[left]{(0,2)}
  \istb{Bad}[right]
  \endist
\istroot(1)(0-2)<30>{Parent}
  \istb{Forgive}[left]{(1,1)}
  \istb{Punish}[right]{(-1,-1)}
  \endist 
\end{istgame}
\end{tcblisting}

\medskip 

\begin{tcblisting}{listing outside text, righthand width=.4\linewidth}
\begin{istgame}
\xtdistance{10mm}{30mm}
\istroot(0){1}
  \istb{L}[al]
  \istb{R}[ar]
  \endist
\xtdistance{7mm}{15mm}
\istroot(1a)(0-1)
  \istb{a}[al]{1,0}
  \istb{b}[ar]{2,3}
  \endist
\istroot(1b)(0-2)
  \istb{c}[al]{0,1}
  \istb{d}[ar]{-1,0}
  \endist
\xtInfoset(1a)(1b){2}
\end{istgame}
\end{tcblisting}

\begin{tcblisting}{listing outside text, righthand width=.4\linewidth}
\begin{istgame}
\xtShowEndPoints[oval node]
\xtdistance{10mm}{30mm}
\istroot(0){1}
  \istb{L}[al]
  \istb{R}[ar]
  \endist
\xtdistance{7mm}{15mm}
\istroot(1a)(0-1)
  \istb{a}[al]{1,0}
  \istb{b}[ar]{2,3}
  \endist
\istroot(1b)(0-2)
  \istb{c}[al]{0,1}
  \istb{d}[ar]{-1,0}
  \endist
\xtInfoset[bend left=30](1a)(1b){2}
\end{istgame}
\end{tcblisting}

\medskip 

\begin{tcblisting}{listing outside text, righthand width=.4\linewidth,breakable}
\begin{istgame}
\xtdistance{15mm}{30mm}
\istroot[-135](0)[initial node]<0>{1}
  \istb{A}[a]{(2,2)}[l]
  \istb{D}[r]
  \endist 
\istroot(1)(0-2)<left>{1}
  \istb{L}[al]
  \istb{R}[ar]
  \endist 
\xtInfosetO(1-1)(1-2){2}(6pt)
\xtdistance{10mm}{20mm}
\istroot(2)(1-1)
  \istb{\ell}[al]{(4,2)}
  \istb{r}[ar]{(1,1)}
  \endist 
\istroot(3)(1-2)
  \istb{\ell}[al]{(3,2)}
  \istb{r}[ar]{(0,3)}
  \endist 
\end{istgame}
\end{tcblisting}


\begin{tcblisting}{listing outside text, righthand width=.4\linewidth}
% IGT 218.1 (Osborne, 2004b)
\begin{istgame}[font=\normalsize]
\xtdistance{10mm}{20mm}
\istroot(0){Vote}
  \istb{a}[al]{x}
  \istb{b}[ar]
  \endist
\istroot(1)([yshift=-1.5em]0-2){Vote}
  \istb{c}[al]{y}
  \istb{d}[ar]{z}
  \endist
\end{istgame}
\end{tcblisting}



\subsection{A game tree with a strategic game}

\begin{tcblisting}{listing outside text, righthand width=.4\linewidth}
%\usepackage{tabu}
%\NewExpandableDocumentCommand\xcol{mO{c|}m}
%  {\multicolumn{#1}{#2}{\ensuremath{#3}}}
\begin{istgame}
\xtdistance{10mm}{40mm}
\istroot(0)[initial node]{1}
  \istb{Book}[al]{2,2}
  \istb{Concert}[ar]
  \endist
\xtPayoff(0-2){
  \begin{tabu}spread0pt{X[$c1]*2{|X[$c2]}|}
  \xcol1[c]{~} & \xcol1[c]{B} & \xcol1[c]{S} \\\tabucline{2-}
  B   & 3,1     & 0,0    \\\tabucline{2-}
  S   & 0,0     & 1,3    \\\tabucline{2-}
  \end{tabu}
  }
\end{istgame}
\end{tcblisting}


%\clearpage

\subsection{Larger game trees}

\begin{tcblisting}{}
\begin{istgame}
\xtShowEndPoints
\xtdistance{10mm}{40mm}
\istroot(0)[initial node]{1}  \istb  \istb  \istb  \endist
\xtdistance{10mm}{10mm}
\istroot(1)(0-1)  \istb  \istb  \istb  \endist
\istroot(2)(0-2)  \istb  \istb  \istb  \endist
\xtdistance{10mm}{20mm}
\istroot(3)(0-3){2}  \istb  \istb  \endist
\xtdistance{10mm}{7mm}
\istroot(a)(1-3){3}  \istb  \istb  \istb  \endist
\xtdistance{10mm}{14mm}
\istroot(b)(2-3)  \istb  \istb  \endist
\istroot(c)(3-1)  \istb  \istb  \endist
\istroot(d)(3-2){3}  \istb  \istb  \endist
\xtInfoset(1)(2){2}  
\xtInfosetO(2-3)(3-1){3}
\xtInfosetO(3-2)(3-2)
\end{istgame}
\end{tcblisting}


\begin{tcblisting}{}
\begin{istgame}
\xtdistance{10mm}{40mm}
\istroot(0)[initial node]{1}  \istb  \istb  \istb  \istb \endist
\xtdistance{10mm}{10mm}
\istroot(1)(0-1)  \istb  \istb  \istb  \endist
\istroot(2)(0-2)  \istb  \istb  \istb  \endist
\xtdistance{10mm}{20mm}
\istroot(3)(0-3){2}  \istb  \istb  \endist
\xtdistance{10mm}{7mm}
\istroot(a)(1-3)  \istb  \istb  \istb  \endist
\istroot(b)(2-3)  \istb  \istb  \endist
\istroot(c)(3-1)  \istb  \istb  \istb  \endist
\istroot(d)(0-4)  \istb  \istb  \endist
\xtInfosetO(1)(2){2} 
\xtInfoset[bend right=10](a)(c){3}[below,yshift=-8pt]
\xtInfoset[bend left=10](b)(d){3}[xshift=20pt,yshift=13pt]
\end{istgame}
\end{tcblisting}



%\clearpage
\subsection{Tic-tac-toe (sketch)}

% tic-tac-toe
\begin{tcblisting}{}
% tic-tac-toe (sketch)
\begin{istgame}[scale=1.7,font=\tiny]
\xtdistance{20mm}{7mm}
\istroot(0) \istb \istb \istb \istb \istb \istb{\dots} \istb \istb \istb{9}[r] \endist
\foreach \x in {1,...,4}
{\xtActionLabel(0)(0-\x){\x}[l]}
\xtdistance{10mm}{3mm}
\istroot(a1)(0-1) \istb{2}[l] \istb \istb \istb \istb \istb \istb \istb{9}[r] \endist
\istroot(a7)(0-7) \istb{1}[l] \istb \istb \istb \istb \istb \istb \istb{9}[r] \endist
\xtdistance{10mm}{2mm}
\istroot(A)(a1-3) \istb{2}[l] \istb \istb \istb \istb \istb \istb{9}[r] \endist
\istroot(B)(a1-8) \istb{2}[l] \istb \istb \istb \istb \istb \istb{8}[r] \endist
\istroot(C)(a7-8) \istb{1}[l] \istb \istb \istb \istb \istb \istb{8}[r] \endist
\istroot(Bx)(B-7) \istb{2}[l] \istb \istb \istb \istb \istb{7}[r] \endist
\istroot(By)(Bx-1) \istb{3}[l] \istb \istb \istb \istb{7}[r]  \endist
\istroot(Bz)(By-1) \istb{4}[l] \istb \istb \istb{7}[r]  \endist
\xtPayoff(Bz-4){\vdots}
\xtPayoff(Bz-4){\cdots}[xshift=10pt,right]
\end{istgame}
\end{tcblisting}


%\clearpage

\subsection{Selten's horse}

\begin{tcblisting}{listing outside text, righthand width=.4\linewidth}
% Selten's horse: IGT 331.2 (Osborne, 2004b)
\begin{istgame}
\xtdistance{8mm}{16mm}
\istroot[-45](0)[initial node]{1}
  \istb{D}[r]
  \istb<grow=east,level distance=30mm>{C}[a]
  \endist
\istroot(1)(0-1)+10mm..20mm+
  \istb{L}[al]{3,3,2}
  \istb{R}[ar]{0,0,0}
  \endist
\istroot[-45](a)(0-2){2}
  \istb{d}[r]
  \istb<grow=0,level distance=20mm>{c}[a]{1,1,1}[r]
  \endist
\istroot(a1)(a-1)+10mm..20mm+
  \istb{L}[al]{4,4,0}
  \istb{R}[ar]{0,0,1}
  \endist
\xtInfoset(1)(a1){3}
\end{istgame}
\captionof{figure}{IGT 331.2}
\end{tcblisting}


\subsection{Centipede game}

\begin{tcblisting}{}
% centipede
\begin{istgame}[scale=1.5]
\setistgrowdirection{south east}
\xtdistance{10mm}{20mm}
\istroot(0)[initial node]{1}
  \istb{Take}[r]{(2,0)}[b]  \istb{Pass}[a]  \endist
\istroot(1)(0-2){2}
  \istb{Take}[r]{(1,3)}[b]  \istb{Pass}[a]  \endist
\istroot(2)(1-2){1}
  \istb{Take}[r]{(4,2)}[b]  \istb{Pass}[a]  \endist
\xtInfoset(2-2)([xshift=5mm]2-2)
%-------------
\istroot(3)([xshift=5mm]2-2){2}
  \istb{Take}[r]{(97,99)}[b]  \istb{Pass}[a]  \endist
\istroot(4)(3-2){1}
  \istb{Take}[r]{(100,98)}[b]  \istb{Pass}[a]  \endist
\istroot(5)(4-2){2}
  \istb{Take}[r]{(99,101)}[b]  \istb{Pass}[a]{(100,100)}[r]  \endist
\end{istgame}
\end{tcblisting}



%\clearpage
\subsection{Poker game}


% poker
\begin{tcblisting}{}
% poker: growing south
\begin{istgame}[scale=1.7]
\xtShowEndPoints
\xtdistance{15mm}{30mm}
\istroot(0)[chance node]{N}
  \istb{Black}[al]
  \istb{Red}[ar]
  \endist
\xtdistance{15mm}{30mm}
\istroot(1-1)(0-1){1}
  \istb<grow=-135,level distance=10mm>{Fold}[al]{1,-1}
  \istb{Raise}[ar]
  \endist
\xtdistance{10mm}{20mm}
\istroot(1)(1-1-2)
  \istb{Pass}[al]{1,-1}
  \istb{Meet}[ar]{2,-2}
  \endist
\xtdistance{15mm}{30mm}
\istroot(1-2)(0-2){1}
  \istb<grow=-135,level distance=10mm>{Fold}[al]{-1,1}
  \istb{Raise}[ar]
  \endist
\xtdistance{10mm}{20mm}
\istroot(2)(1-2-2){}
  \istb{Pass}[al]{1,-1}
  \istb{Meet}[ar]{-2,2}
  \endist
\xtInfoset(1)(2){2}
\xtActionLabel(0)(0-1){[\frac12]}[br]
\xtActionLabel(0)(0-2){[\frac12]}[bl]
\end{istgame}
\end{tcblisting}


\subsection{Poker game: growing to the right}
\label{p:poker-right}

\begin{tcblisting}{}
% poker: growing east -- counterclockwise
\begin{istgame}[scale=1.3]
\setistgrowdirection{0}   % default grow-direction is 'east' from now on
\xtdistance{15mm}{30mm}
\istroot(0)[chance node]<left>{N}
  \istb{Black}[bl]
  \istb{Red}[al]
  \endist
\xtdistance{15mm}{30mm}
\istroot(1-1)(0-1)<left>{1}
  \istb<grow=-45,level distance=10mm>{Fold}[bl]{1,-1}
  \istb{Raise}[al]
  \endist
\xtdistance{12mm}{24mm}
\istroot(1)(1-1-2)
  \istb{Pass}[bl]{1,-1}
  \istb{Meet}[al]{2,-2}
  \endist
\xtdistance{15mm}{30mm}
\istroot(1-2)(0-2)<left>{1}
  \istb<grow=-45,level distance=10mm>{Fold}[bl]{-1,1}[[xshift=5pt]below]
  \istb{Raise}[al]
  \endist
\xtdistance{12mm}{24mm}
\istroot(2)(1-2-2)
  \istb{Pass}[bl]{1,-1}
  \istb{Meet}[al]{-2,2}
  \endist
\xtInfosetO'(1-1-2)(1-2-2){2}  % \xtInfosetO'
\xtActionLabel(0)(0-1){[\frac12]}[ar]
\xtActionLabel(0)(0-2){[\frac12]}[br]
\end{istgame}
\end{tcblisting}

\begin{tcblisting}{}
% poker: growing east -- clockwise (swap version)
\begin{istgame}[scale=1.3]
\setistgrowdirection'{0}   % \setistgrowdirection'
\xtdistance{15mm}{30mm}
\istroot(0)[chance node]<left>{N}
  \istb{Black}[al]
  \istb{Red}[bl]
  \endist
\xtdistance{15mm}{30mm}
\istroot(1-1)(0-1)<left>{1}
  \istb<grow=45,level distance=10mm>{Fold}[al]{1,-1}
  \istb{Raise}[bl]
  \endist
\xtdistance{12mm}{24mm}
\istroot(1)(1-1-2)
  \istb{Pass}[al]{1,-1}
  \istb{Meet}[bl]{2,-2}
  \endist
\xtdistance{15mm}{30mm}
\istroot(1-2)(0-2)<left>{1}
  \istb<grow=45,level distance=10mm>{Fold}[al]{-1,1}
  \istb{Raise}[bl]
  \endist
\xtdistance{12mm}{24mm}
\istroot(2)(1-2-2)
  \istb{Pass}[al]{1,-1}
  \istb{Meet}[bl]{-2,2}
  \endist
\xtInfosetO[fill=red!20](1-1-2)(1-2-2){2} 
\xtActionLabel(0)(0-1){[\frac12]}[br]
\xtActionLabel(0)(0-2){[\frac12]}[ar]
\end{istgame}
\end{tcblisting}

\subsection{Signaling games}

\begin{tcblisting}{listing above text,halign lower=center}
% signaling game: IGT 337.1 (Osborne, 2004b)
\begin{istgame}
\setistgrowdirection'{right}
% game start: choice of chance
\xtdistance{20mm}{20mm}
\istroot(0)[chance node]<180>{Chance}
  \istb<grow=north>{H}[l]
  \istb<grow=south>{L}[l]
  \endist
\istroot(H0)(0-1)<180>{F}
  \istb{(p_1,E)}[a]
  \endist
\istroot(L0)(0-2)<180>{F}
  \istb{(p_1,E)}[a]
  \endist
\xtdistance{10mm}{20mm}
% subtree after H is chosen
\istroot(H)(H0-1)
  \istb{Buy}[br]
  \istb{Refrain}[ar]{-E,0}
  \endist
\istcntm(cntm)(H-1)+10mm..20mm+
\istroot(H1)(cntm)+10mm..8mm+
  \istb{p_2^H}[b]
  \istb<missing>
  \endist
\istroot(CH)(H1-1)<[label distance=-4pt]135>{C}
  \istb{Buy}[br]{p_1-E-c_H+p_2^H-c_H, 2H-p_1-p_2^H}
  \istb{Refrain}[ar]{p_1-E-c_H, H-p_1}
  \endist
% subtree after L is chosen
\istroot(L)(L0-1)
  \istb{Buy}[br]
  \istb{Refrain}[ar]{-E,0}
  \endist
\istcntm(cntm)(L-1)+10mm..20mm+
\istroot(L1)(cntm)+10mm..8mm+
  \istb<missing>
  \istb{p_2^L}[a]
  \endist
\istroot(CL)(L1-2)<[label distance=-4pt]-135>{C}
  \istb{Buy}[br]{p_1-E-c_L+p_2^L-c_L, 2L-p_1-p_2^L}
  \istb{Refrain}[ar]{p_1-E-c_L, L-p_1}
  \endist
\xtInfoset(H)(L){C}[left]
\xtActionLabel(0)(0-1){\pi}[r]
\xtActionLabel(0)(0-2){1-\pi}[r]
\end{istgame}
\end{tcblisting}

\mbigskip2

\begin{tcblisting}{listing outside text, righthand width=.5\linewidth}
% signaling game
\begin{istgame}[scale=1.3]
\xtdistance{20mm}{20mm}
\istroot(0)[chance node]{$c$}
  \istb<grow=left>{\frac12}[a]
  \istb<grow=right>{\frac12}[a]
  \endist
\xtdistance{10mm}{20mm}
\istroot(1)(0-1)<180>{1}
  \istb<grow=north>{a}[l]
  \istb<grow=south>{b}[l]
  \endist
\istroot(2)(0-2)<0>{1}
  \istb<grow=north>{a}[r]
  \istb<grow=south>{b}[r]
  \endist
\istroot'[north](a1)(1-1)
  \istb{L}[bl]{-1,0}
  \istb{R}[br]{0,-1}
  \endist
\istroot(b1)(1-2)
  \istb{L}[al]{2,0}
  \istb{R}[ar]{0,2}
  \endist
\istroot(a2)(2-2)
  \istb{L}[al]{3,0}
  \istb{R}[ar]{0,3}
  \endist
\istroot'[north](b2)(2-1)
  \istb{L}[bl]{1,0}
  \istb{R}[br]{0,1}
  \endist
\xtInfoset(a1)(b2){2}
\xtInfoset(b1)(a2){2}
\end{istgame}
\end{tcblisting}



%\clearpage
\setsecnumdepth{chapter}
\section{Version history}

\begin{itemize}
\item v\tmpversion (\tmpdate) This version, to be submitted to CTAN
  \begin{itemize}
  \item introduced \cmd{\cntmlevdist} and \cmd{\cntmsibdist}
  \item introduced \cmd{\cntmdistance} (for internal use)
  \item redefined related marcos.
  \item package document done
  \end{itemize}
\item v0.99g (2017/08/21)
  \begin{itemize}
  \item redefined the \env{istgame} environment to add \xw{>=stealth} as an option
  \item added \xw{text depth=.25ex} as an option to \cmd{\istb} to get better alignment of action labels
  \end{itemize}
\item v0.99f (2017/08/02)
  \begin{itemize}
  \item redefined \cmd{\xtInfosetO(')}
    \begin{itemize}
    \item added \verb+\begin{scope}[on background layer]...\end{scope}+
    \end{itemize}
  \end{itemize}
\item v0.99e (2017/08/01)
  \begin{itemize}
  \item introduced the prime(\xw{'}) versions to deal with \xw{grow'} (this is the swap version in \tikz)
  \item redefined \cmd{\istroot(')}
  \item defined \cmd{\istrooto(')} to replace \cmd{\istroot*}
    \begin{itemize}
    \item \cmd{\istroot*} completely replaced by \cmd{\istrooto}
    \end{itemize}
  \item redefinde \cmd{\istcntm}
  \item defined \cmd{\istcntmarc}
    \begin{itemize}
    \item \cmd{\istcntm*} completely replaced by \cmd{\istcntmarc}
    \end{itemize}
  \item redefined \cmd{\xtInfoset(')} and \cmd{\xtInfosetOwner(')}
  \item introduced \cmd{\xtInfosetO(')}
    \begin{itemize}
    \item \cmd{\xtInfoset*} completely replaced by \cmd{\xtInfosetO}
    \end{itemize}
  \item introduced \cmd{\xtgrowprime} introduced
  \item redefined \cmd{\xtNode} accordingly
  \end{itemize}
\item v0.99d (2017/07/27)
  \begin{itemize}
  \item defined \cmd{\xtSubgameBox(*)} and \cmd{\xtSubgameOval(*)} to express a subgame
  \end{itemize}
\item v0.99c (2017/07/20)
  \begin{itemize}
  \item defined \cmd{\xtgrow} to deal with going `clockwise' of branch arrangement
  \item defined \cmd{\setistgrowkey} to change between \xw{grow} and \xw{grow'}
  \item introduced \cmd{\setistgrowdirection'} by redefining \cmd{\setistgrowdirection}
  \item updated `related macros' accordingly
  \end{itemize}
\item v0.99b (2017/07/16)
  \begin{itemize}
  \item renamed \xw{zero node} as \xw{plain node}
  \item added \cmd{\setistPlainNodeStyle}
  \item defined \cmd{\xtNode*} (for a terminal node text with a plain node)
  \item redefined \cmd{\xt<...>NodeStyle} (now all arguments are optional)
  \item renamed \cmd{\isthorizontallabelshift} as \cmd{\istactionlabelxshift}, with default \xw{1pt}
  \item renamed \cmd{\istverticallabelshift} as \cmd{\istactionlabelyshift}, with default \xw{2pt}
  \end{itemize}
\item v0.99a (2017/03/10)
  \begin{itemize}
  \item started rewriting package manual
  \item introduced \cmd{\istb.}\ (for terminal nodes)
  \item redefined \cmd{\xtShowTerminalNodes}
  \item introduced \cmd{\xtShowEndPoints} and \cmd{\xtHideEndPoints}
  \item redefined \cmd{\xtInfoset*}, with \cmd{\xtdefaultinfosep} added
  \end{itemize}
\item v0.9 (2017/02/13)
  \begin{itemize}
  \item some internal macro names changed (\cmd{\xtnode}, \cmd{\xttnode},\cmd{\xtshowtnode})
%  \item conflict with \pkg{tikz-qtree} resolved. (\env{istgame} differs from \env{tikzpicture} with \pkg{tikz-qtree})
%  \item \cmd{\setistbranchanchors} added
  \item added \xw{zero node}
  \end{itemize}
\item v0.8 (2017/01/17)
  \begin{itemize}
  \item macro names changed
    \begin{itemize}
      \item \cmd{\xtdistance}: prefix `\xw{x}' changed to `\xw{xt}' meaning `extensive tree'
      \item \cmd{\xtInfoset(*)}, \cmd{\xtInfosetOwner}, \cmd{\xtActionLabel}, \cmd{xtOwner}, \cmd{\xtPayoff}, \cmd{\xtNode}
      \item \cmd{\xtShowTerminalNodes}, \cmd{\xtHideTerminalNodes}
      \item \cmd{\xtlevdist}, \cmd{\xtsibdist}
    \end{itemize}
  \item \cmd{\xtNode} redefined
  \item some internal macro names changed (including \cmd{\xtpayff}, \cmd{\xtmove})
  \item node styles redefined
  \item \cmd{\setist<Solid>NodeStyle} added for <Various> node styles
  \item \cmd{\setistdefaultnodecolor}, \cmd{setistdefaultnodebgcolor} added
  \end{itemize}
\end{itemize}


\section{Acknowledgement}

The basic idea of the \pkg{istgame} package came from Osborne's \pkg{egameps} package and Chen (2013). A special thanks goes to Kangsoo Kim from KTUG for his great help in using \pkg{expl3} to simplify the appearance and the usage of the macros.


\section{References}
\hpara{}Chen, H.~K.~(2013), ``Drawing Game Trees with \tikz,'' \url{http://www.sfu.ca/~haiyunc/notes/Game_Trees_with_TikZ.pdf}.

\hpara{}Cho, I-S.~(2017), ``\pkg{istgame}: Drawing Game Trees with \tikz,'' in Korean TeX Society, \textit{\TeX, Beyond the World of Typesetting}, Seoul: Kyungmoonsa, 203--237.

\hpara{}Osborne, M.~J.~(2004a), ``Manual for \pkg{egameps.sty},'' Version 1.1, \url{http://texdoc.net/texmf-dist/doc/latex/egameps/egameps.pdf}

\hpara{}\uline{\hphantom{Osborne, M.~J}}~(2004b), \textit{An Introduction of Game Theory}, New York: Oxford.

\hpara{}Tantau, T.~(2015), ``\tikz\ and PGF: Manual for version 3.0.1a,'' \url{http://sourceforge.net/projects/pgf}.

%\section*{Discussions (in Korean) on KTUG board}
%
%\begin{itemize}
%\item Drawing Game Trees 1: \url{http://www.ktug.org/xe/index.php?document_srl=207287}
%
%\item Drawing Game Trees 1-1: \url{http://www.ktug.org/xe/index.php?document_srl=207513}
%
%\item Drawing Game Trees 1-2:
%\url{http://www.ktug.org/xe/index.php?document_srl=208286}
%
%\item Drawing Game Trees 2: \url{http://www.ktug.org/xe/index.php?document_srl=212043}
%
%\item Drawing Game Trees 2-1:
%\url{http://www.ktug.org/xe/index.php?document_srl=212225}
%
%\item Drawing Game Trees 2-2:
%\url{http://www.ktug.org/xe/index.php?document_srl=212319}
%\end{itemize}
