These illustrations are suggested in the endnotes of *Political Games*. This document sets up the code and implements all these analyses. You can replicateâ€“or modifyâ€“any figure using the code fragments below.

First open R or Rstudio and install the hop package from github:

`::install_github("macartan/hop") devtools`

Then load it up:

`library(hop)`

Some normal form games: PD (#1), with and without equilibrium marked

```
<- matrix(c(2,3,0,1),2)
payoffs gt_bimatrix(payoffs, labels1=c("C","D"))
```

`gt_bimatrix(payoffs, labels1=c("C","D"), nash=F, arrow1=F)`

Chicken (#2): Pure strategy equilibriums marked

```
<- matrix(c(2,3,1,0),2)
payoffs gt_bimatrix(payoffs, labels1=c("C","D"))
```

Assurance (#3): Pure strategy equilibriums marked

```
<- matrix(c(3,2,0,1),2)
payoffs gt_bimatrix(payoffs, labels1=c("C","D"))
```

Illustrating the folk theorems (#4) for the Prisonerâ€™s Dilemma:

```
<- matrix(c(2,3,0,1),2)
payoffs gt_folk(payoffs)
```

â€¦and for the Assurance Game

```
<- matrix(c(3,2,0,1),2)
payoffs gt_folk(payoffs)
```

Condorcet Jury (#10): Gives an illustration of the law of large numbers

`gt_jury(n_voters=7, probability_correct=.6)`

Power indices (#13): Shows mapping between raw votes and power for two seemingly similar committees

`gt_plot_banzhaf(weights = c(1, 1, 3,7,9,9), q_rule = .5)`

`gt_plot_banzhaf(weights = c(1, 1, 3,7,9,10), q_rule = .6)`

Plott (#14): Illustrating the absence of stable points

```
<- matrix(c(0, 0, .5, 1, 1, 0), 2)
ideals gt_majority_phase(ideals)
```

```
<- matrix(c(.2, .2, .5, .9, 1, 0), 2)
ideals gt_majority_phase(ideals, raylengths=c(.5, .2))
```

Cycles (#15): Majority rule cycling

`gt_cycles(n_voters = 3, n_motions = 25)`

Legislative bargaining (#18): Returns equilibrium returns given recognition probabilities

```
<- c(.8,.2,0)
probabilities gt_leg_barg(probabilities)
```

`## [1] "Anything goes: one of multiple equilibria selected"`

`## [1] "allocations: 0.796, 0.199, 0.005"`

Cascades (#22): Where you end up after 50,000 random orderings

```
<- c(1,1,1,1,1,1,0,0,0)
signals <- replicate(50000, gt_cascade(sample(signals))$Declarations)
D mean(D[9,])
```

`## [1] 0.89524`

Nash bargaining (#27)

`gt_nbs(u1 = function(x) x^.5, u2 = function (x) 1 - x)`

Simple version with equilibrium only marked.

`gt_nbs(solution_only = T)`

Two Coase theorem illustrations (#31)

```
<- matrix(c(2,3,0,1),2)
payoffs gt_coase(payoffs, bargain = T, SQ = "minimax")
```