#OK to post homework #George Spahn, 1-30-2022, Assignment 3 with(combinat): # 3 # a # output of RandDisGame(4,4) # [[[13, 8], [14, 6], [11, 4], [6, 5]], [[9, 10], [1, 11], [16, 3], [7, 9]], # [[3, 2], [2, 7], [12, 15], [5, 1]], [[4, 13], [10, 16], [8, 12], [15, 14]]] # i # row 1: [13,8] # row 2: [1,11] # row 3: [12,15] # row 4: [10,16] # Therefore row 1 is the row players best move, and the outcome is [13,8] # ii # col 1: [13,8] # col 2: [14, 6] # col 3: [16, 3] # col 4: [15, 14] # Therefore col 4 is the col players best move, and the outcome is [15,14] # iii # set of Nash equilibria {[row 1, col 1]} # There is a single Nash equilibrium #b # output of RandDisGame(5,7) # [[[30, 28], [16, 13], [15, 21], [11, 2], [17, 23], [29, 15], [28, 33]], # [[32, 27], [1, 35], [26, 17], [31, 16], [12, 11], [9, 19], [22, 1]], # [[18, 6], [13, 9], [24, 29], [8, 26], [25, 32], [33, 34], [10, 10]], # [[34, 30], [27, 25], [2, 12], [23, 20], [20, 22], [4, 8], [14, 24]], # [[21, 3], [6, 5], [3, 4], [19, 31], [5, 7], [7, 14], [35, 18]]] # i # row 1: [28, 33] # row 2: [1, 35] # row 3: [33, 34] # row 4: [34, 30] # row 5: [19, 31] # Therefore row 4 is the row players best move, and the outcome is [34, 30] # ii # col 1: [34, 30] # col 2: [27, 25] # col 3: [26, 17] # col 4: [31, 16] # col 5: [25, 32] # col 6: [33, 34] # col 7: [35, 18] # Therefore col 6 is the col players best move, and the outcome is [33, 34] # iii # set of Nash equilibria {[row 3, col 6], [row 4, col 1]} # There are two Nash equilibrium # 4 # AllGames(a,b) # inputs positive integers a and b and outputs the st of (a*b)!^2 games where # each player's payoffs are distinct and drawn from {1, ..., a*b} AllGames:=proc(a,b) local p1: p1 := permute(a*b): {seq(seq( #the below line of code was copied from RandDisGame in C3.txt [seq([seq([pi1[b*i1+j1],pi2[b*i1+j1]],j1=1..b)],i1=0..a-1)] , pi2 in p1), pi1 in p1)}: end: # 5 FullStat:=proc(a,b) local g,toRet,n,rc,cr: toRet := [0,0,0,0,0,0]: for g in AllGames(a,b) do n := nops(PureNashEqui(g)): if n = 0 then toRet[1] := toRet[1]+1: elif n = 1 then toRet[2] := toRet[2]+1: elif n = 2 then toRet[3] := toRet[3]+1: fi: rc := DynRC(g)[2]: cr := DynCR(g)[2]: if rc[1] < cr[1] then toRet[4] := toRet[4]+1: fi: if rc[2] > cr[2] then toRet[5] := toRet[5]+1: fi: if rc = cr then toRet[6] := toRet[6]+1: fi: od: toRet: end: # 6 SampleStat:=proc(a,b,K) local i,toRet,g,n,rc,cr: toRet := [0,0,0,0,0,0]: for i from 1 to K do g:= RandDisGame(a,b): n := nops(PureNashEqui(g)): if n = 0 then toRet[1] := toRet[1]+1: elif n = 1 then toRet[2] := toRet[2]+1: elif n = 2 then toRet[3] := toRet[3]+1: fi: rc := DynRC(g)[2]: cr := DynCR(g)[2]: if rc[1] < cr[1] then toRet[4] := toRet[4]+1: fi: if rc[2] > cr[2] then toRet[5] := toRet[5]+1: fi: if rc = cr then toRet[6] := toRet[6]+1: fi: od: [seq(evalf(k/K), k in toRet)]: end: