In[ ]payoffStravinsky = {{3, 0}, {0, 5}}; (*Define the payoff matrices*)payoffBach = {{5, 0}, {0, 3}}; payoffStravinsky = {{3, 0}, {0, 5}}; (*Display the payoff matrices*) MatrixForm /@ {payoffBach, payoffStravinsky} (*Calculate and display the Nash equilibria*) nashEquilibrium[matrix_] := Module[{rowMax, colMax, equilibria}, rowMax = Max /@ matrix; colMax = Max /@ Transpose[matrix]; equilibria = Select[Flatten[ Table[{i, j}, {i, 1, Length[rowMax]}, {j, 1, Length[colMax]}], 1], matrix[[Sequence @@ #]] == rowMax[[#[[1]]]] && matrix[[Sequence @@ #]] == colMax[[#[[2]]]] &]; If[Length[equilibria] == 0, "No Nash Equilibrium", equilibria]]; nashBach = nashEquilibrium[payoffBach]; nashStravinsky = nashEquilibrium[payoffStravinsky]; (*Define the equilibrium analysis function*) equilibriumAnalysis[player_, nash_] := If[nash == "No Nash Equilibrium", "No Nash Equilibrium", "Equilibrium analysis for " <> player <> " Game: " <> If[Length[nash] == 1, "Pure Nash Equilibrium at " <> ToString[nash[[1]]], "Mixed Nash Equilibrium"]] (*Display the equilibrium analysis*) equilibriumAnalysis["Bach", nashBach] equilibriumAnalysis["Stravinsky", nashStravinsky] **Payoff Matrices Output ** {\!\(\* TagBox[ RowBox[{"(", "", GridBox[{ {"5", "0"}, {"0", "3"} }, GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}}], "", ")"}], Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\), \!\(\* TagBox[ RowBox[{"(", "", GridBox[{ {"3", "0"}, {"0", "5"} }, GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}}], "", ")"}], Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\)} (*Bach Equilibrium Analysis Output*) If[{{1, 1}, {2, 2}} == "No Nash Equilibrium", "No Nash Equilibrium", "Equilibrium analysis for " <> "Bach" <> " Game: " <> If[Length[{{1, 1}, {2, 2}}] == 1, "Pure Nash Equilibrium at " <> ToString[{{1, 1}, {2, 2}}[[1]]], "Mixed Nash Equilibrium"]] (*Stavinsky Equilibrium Analysis Output*) If[{{1, 1}, {2, 2}} == "No Nash Equilibrium", "No Nash Equilibrium", "Equilibrium analysis for " <> "Stravinsky" <> " Game: " <> If[Length[{{1, 1}, {2, 2}}] == 1, "Pure Nash Equilibrium at " <> ToString[{{1, 1}, {2, 2}}[[1]]], "Mixed Nash Equilibrium"]] ###3D payoff matrices## (*Define the payoff matrices*)payoffBach = {{5, 0}, {0, 3}}; payoffStravinsky = {{3, 0}, {0, 5}}; (*Define the utility functions*) utilityPlayer1[x_, y_, matrix_] := matrix[[1, 1]] x + matrix[[1, 2]] y; utilityPlayer2[x_, y_, matrix_] := matrix[[2, 1]] x + matrix[[2, 2]] y; (*Plot the payoff functions*) Plot3D[{utilityPlayer1[x, y, payoffBach], utilityPlayer2[x, y, payoffBach]}, {x, 0, 1}, {y, 0, 1}, PlotRange -> All, AxesLabel -> {"Player 1 Choice", "Player 2 Choice", "Payoff"}, PlotLabel -> "Payoff Functions for Bach Game"] Plot3D[{utilityPlayer1[x, y, payoffStravinsky], utilityPlayer2[x, y, payoffStravinsky]}, {x, 0, 1}, {y, 0, 1}, PlotRange -> All, AxesLabel -> {"Player 1 Choice", "Player 2 Choice", "Payoff"}, PlotLabel -> "Payoff Functions for Stravinsky Game"]