#OK to post #Rebecca Embar, 1-28-2022, Homework 3 read `hw2RebeccaEmbar.txt`: read `C3.txt`: #3 #(a) G := RandDisGame(4,4): matrix(G); #Output matrix #[[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) #[[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]] #If Player Row goes first, Player Row will pick strategy 1 #The game is then reduced to the one player game [8,6,4,5] #Player Column will pick strategy 1, and the outcome will be [13,8] #(ii) #[[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]] #If Player Column goes first, Player Column will pick strategy 4 #The game is then reduced to the one player game [6,7,5,15] #Player Row will pick strategy 4, and the outcome will be [15,14] #(iii) #[[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]] #The set of pure Nash equilibria is {[1,1]} #(b) G:= RandDisGame(5,7): matrix(G); #Output matrix #[[11,15] [6,35] [17,23] [34,26] [18,20] [21,17] [5,29] ] #[[23,9] [16,2] [28,25] [22,3] [12,21] [10,12] [27,34]] #[[24,5] [1,10] [19,16] [20,7] [26,8] [15,24] [2,28] ] #[[30,30] [7,6] [13,33] [14,19] [8,1] [35,27] [32,32]] #[[3,18] [9,13] [29,22] [31,11] [25,31] [4,14] [33,4] ] #(i) #[[11,15] [6,35*] [17,23] [34,26] [18,20] [21,17] [5,29] ] #[[23,9] [16,2] [28,25] [22,3] [12,21] [10,12] [27,34*]] #[[24,5] [1,10] [19,16] [20,7] [26,8] [15,24] [2,28*] ] #[[30,30] [7,6] [13,33*] [14,19] [8,1] [35,27] [32,32] ] #[[3,18] [9,13] [29,22] [31,11] [25,31*] [4,14] [33,4] ] #If Player Row goes first, Player Row will pick strategy 2 #The game is then reduced to the one player game [9,2,25,3,21,12,34] #Player Column will pick strategy 7, and the outcome will be [27,34] #(ii) #[[11,15] [6,35] [17,23] [34*,26] [18,20] [21,17] [5,29] ] #[[23,9] [16*,2] [28,25] [22,3] [12,21] [10,12] [27,34]] #[[24,5] [1,10] [19,16] [20,7] [26*,8] [15,24] [2,28] ] #[[30*,30] [7,6] [13,33] [14,19] [8,1] [35*,27] [32,32]] #[[3,18] [9,13] [29*,22] [31,11] [25,31] [4,14] [33*,4]] #If Player Column goes first, Player Column will pick strategy 1 #The game is then reduced to the one player game [11,23,24,30,3] #Player Row will pick strategy 4, and the outcome will be [30,30] #(iii) #[[11,15] [6,35*] [17,23] [34*,26] [18,20] [21,17] [5,29] ] #[[23,9] [16*,2] [28,25] [22,3] [12,21] [10,12] [27,34*]] #[[24,5] [1,10] [19,16] [20,7] [26*,8] [15,24] [2,28*] ] #[[30*,30] [7,6] [13,33*] [14,19] [8,1] [35*,27] [32,32] ] #[[3,18] [9,13] [29*,22] [31,11] [25,31*] [4,14] [33*,4] ] #There are no pure Nash equilibria #4 with(combinat): AllGames := proc(a,b) local payoff,payoffchoices,games,c,p1,p2,i,j: payoff := permute(a*b): payoffchoices := permute(nops(payoff),2): games := {}: for c from 1 to nops(payoffchoices) do p1 := payoff[payoffchoices[c,1]]: p2 := payoff[payoffchoices[c,2]]: games := games union {[seq([seq([p1[b*i+j],p2[b*i+j]],j=1..b)],i=0..a-1)]}: od: return(games); end: #5 FullStat := proc(a,b) local payoff,payoffchoices,l,c,p1,p2,i,j,game,nash,rc,cr: payoff := permute(a*b): payoffchoices := permute(nops(payoff),2): l := [0,0,0,0,0,0]: for c from 1 to nops(payoffchoices) do p1 := payoff[payoffchoices[c,1]]: p2 := payoff[payoffchoices[c,2]]: game := [seq([seq([p1[b*i+j],p2[b*i+j]],j=1..b)],i=0..a-1)]: nash := PureNashEqui(game): rc := DynRC(game): cr := DynRC(game): #Number of nash equilibria if nops(nash) = 0 then l[1] := l[1]+1 elif nops(nash) = 1 then l[2] := l[2]+1 elif nops(nash) = 2 then l[3] := l[3]+1 fi: #Row player better off playing second if cr[2,1] > rc[2,1] then l[4] := l[4]+1 fi: #Column player better off playing second if rc[2,2] > cr[2,2] then l[5] := l[5]+1 fi: #DynRC(G) = DynCR(G) if rc = cr then l[6] := l[6]+1 fi: od: return(l); end: #(i) [72,416,64,0,0,552] #(ii) [86400,345240,86040,0,0,517680] #6 SampleStat := proc(a,b,K) local l,c,game,nash,rc,cr,i: l := [0,0,0,0,0,0]: for c from 1 to K do game := RandDisGame(a,b): nash := PureNashEqui(game): rc := DynRC(game): cr := DynRC(game): #Number of nash equilibria if nops(nash) = 0 then l[1] := l[1]+1 elif nops(nash) = 1 then l[2] := l[2]+1 elif nops(nash) = 2 then l[3] := l[3]+1 fi: #Row player better off playing second if cr[2,1] > rc[2,1] then l[4] := l[4]+1 fi: #Column player better off playing second if rc[2,2] > cr[2,2] then l[5] := l[5]+1 fi: #DynRC(G) = DynCR(G) if rc = cr then l[6] := l[6]+1 fi: od: for i from 1 to 6 do l[i] := l[i]/K: od: return evalf(l): end: #[0.3327,0.4158,0.1918,0,0,1] #[0.3364,0.4104,0.1928,0,0,1] #[0.3283,0.4089,0.2021,0,0,1] #[0.3365,0.4053,0.1986,0,0,1] #[0.3225,0.4201,0.1992,0,0,1]