2x2 Ordinal Games

Manipulate[
rankings=Permutations[{1,2,3,4}];
alternatives={"C","N"};
strategyPairs=Tuples[alternatives,2];
outcomes=Row/@Tuples[alternatives,2];
Switch[game,
pd,
rowRank={3,1,4,2};colRank={3,4,1,2},
chicken,
rowRank={3,2,4,1};colRank={3,4,2,1}];

dominantStrategyForRow={};
dominantStrategyForCol={};

rankTable=Flatten/@Table[{strategyPairs[[i]],outcomes[[i]],rowRank[[i]],colRank[[i]]},{i,4}];
rankTableDisplay=Style[TableForm[rankTable,TableHeadings->{None,{"player 1's\nchoice","player 2's\nchoice","outcome\nof game","player 1's\nranking","player 2's\nranking"}}],16];

rowsMatrix=Partition[rowRank,2];
colsMatrix=Partition[colRank,2];
gameMatrix=Table[{rowsMatrix[[i,j]],colsMatrix[[i,j]]},{i,2},{j,2}];gameMatrixDisplay=Style[Grid[{{"",Row[{"   ",Framed["player 2",Background->Gray]}]},{Framed["player 1",Background->Gray],Style[Grid[{{"","C","N"},{"C",gameMatrix[[1,1]],gameMatrix[[1,2]]},{"N",gameMatrix[[2,1]],gameMatrix[[2,2]]}},Dividers->{{False,2->True},{False,2->True}}],Bold,20]}}, Frame -> True],Bold,20];


Which[rowsMatrix[[1,1]]<rowsMatrix[[2,1]]&&rowsMatrix[[1,2]]<rowsMatrix[[2,2]],dominantStrategyForRow={"N"},
rowsMatrix[[1,1]]>rowsMatrix[[2,1]]&&rowsMatrix[[1,2]]>rowsMatrix[[2,2]],dominantStrategyForRow={"C"}];


Which[colsMatrix[[1,1]]<colsMatrix[[1,2]]&&colsMatrix[[2,1]]<colsMatrix[[2,2]],dominantStrategyForCol={"N"},colsMatrix[[1,1]]>colsMatrix[[1,2]]&&colsMatrix[[2,1]]>colsMatrix[[2,2]],dominantStrategyForCol={"C"}];

NEqTester=rowsMatrix[[#1,#2]]>rowsMatrix[[3-#1,#2]]&&colsMatrix[[#1,#2]]>colsMatrix[[#1,3-#2]]&;
NEqTestResults={NEqTester[1,1],NEqTester[1,2],NEqTester[2,1],NEqTester[2,2]};
NashEquilibria=Pick[outcomes,NEqTestResults];

Pane[
Text@Style[Column[{rankTableDisplay,"",gameMatrixDisplay,"",
If[dominantStrategyForRow≠{},Row[{"The dominant strategy for player 1 is ",dominantStrategyForRow,"."}],Row[{"Player 1 does not have a dominant strategy in this game."}]],If[dominantStrategyForCol≠{},Row[{"The dominant strategy for player 2 is ",dominantStrategyForCol,"."}],Row[{"Player 2 does not have a dominant strategy in this game."}]],If[NashEquilibria≠{},Row[{"The Nash equilibria correspond to outcome(s) ",NashEquilibria,"."}],Row[{"There are no Nash equilibria in this game."}]]
},Left],Bold,16],{400,400}],
{{game,pd},{pd->"prisoner's dilemma",chicken->"chicken",any->"choose your own"},ControlType->PopupMenu},
{{rowRank,{3,1,4,2},"player 1's ranking"},Permutations[{1,2,3,4}],Enabled->game==any,ControlPlacement->Left},
{{colRank,{3,4,1,2},"player 2's ranking"},Permutations[{1,2,3,4}],Enabled->game==any,ControlPlacement->Left},TrackedSymbols->True,AutorunSequencing->{1}]

A 2×2 ordinal game consists of two players, each with the strategy options of cooperation or noncooperation with the other player (these options are denoted C and N, respectively, in this Demonstration). Each player then ranks the four possible resulting outcomes from four (most desirable for that player) down to 1 (least desirable). The game is summarized in a 2×2 matrix of ordered pairs, with the entries in each ordered pair being the rankings of the corresponding outcome by player 1 and player 2, respectively. A dominant strategy for a player is a strategy (a choice of C or N) with the property that such a choice results in a more favorable outcome for that player than the other choice would, regardless of the other player's choice of strategy. A Nash equilibrium is a choice of strategy by each player with the property that a unilateral change of strategy by either player is unfavorable to that player.

The two most famous examples of 2×2 ordinal games are "The Prisoner's Dilemma", which is shown in the thumbnail, and "Chicken", which is shown in snapshot 1. Snapshot 2 illustrates a game in which one player has a dominant strategy while the other does not, and snapshot 3 illustrates a game in which there is no Nash equilibrium.

For further details, see A. D. Taylor, Mathematics and Politics—Strategy, Voting, Power and Proof, New York: Springer–Verlag, 1995.

Contributed by: Marc Brodie (Wheeling Jesuit University)