#OK to post #Rebecca Embar, 2-8-2022, Homework 6 read `C6.txt`: #1 testgame := proc() local G,i,j,p1,p2,payoff: G:=RG(2,2,1000); print(G): for i from 1 to 3 do p1:=rand(0..100)()/100: p2:=rand(0..100)()/100: print(p1,p2): for j from 1 to 5 do print(SimulateMG(G,p1,p2,10000)): od: payoff := PayOffG(G,p1,p2): print(evalf(payoff)): od: end: #RESULTS #First game #G := [[[933, 496], [300, 242]], [[271, 112], [500, 860]]] #p1 := 9/100, p2 := 7/10 #SimulateMG results #[374.5375000, 344.8106000] #[379.2939000, 349.6838000] #[375.5151000, 341.5912000] #[376.2373000, 346.6706000] #[376.8238000, 345.4926000] #PayoffG results: [376.0060000, 343.9060000] #p1 := 59/100, p2 := 53/100 #SimulateMG results #[529.0202000, 411.9032000] #[528.0772000, 409.9782000] #[529.8955000, 414.1250000] #[526.9886000, 416.0566000] #[528.7303000, 414.3704000] #PayoffG results: [530.1774000, 412.2654000] #p1 := 67/100, p2 := 1/100 #SimulateMG results #[367.2382000, 439.9396000] #[368.6685000, 441.4578000] #[367.7500000, 441.1322000] #[369.4338000, 444.9978000] #[369.4050000, 442.8826000] #PayoffG results: [369.4854000, 445.1734000] #Second game #G := [[[715, 614], [309, 142]], [[382, 555], [347, 670]]] #p1 := 59/100, p2 := 24/25 #SimulateMG results #[565.1518000, 579.6364000] #[569.0752000, 581.8106000] #[570.2661000, 580.4711000] #[565.4986000, 580.0918000] #[570.5954000, 581.2604000] #PayoffG results: [568.3144000, 580.5568000] #p1 := 19/20, p2 := 16/25 #SimulateMG results #[557.2054000, 449.7042000] #[558.9980000, 451.5190000] #[559.6601000, 454.1179000] #[560.6701000, 452.7767000] #[557.2689000, 450.5749000] #PayoffG results: [558.8680000, 451.6960000] #p1 := 11/100, p2 := 1/20 #SimulateMG results #[346.9993000, 610.8215000] #[346.4851000, 606.2741000] #[346.9782000, 609.5546000] #[347.2125000, 606.7389000] #[347.1059000, 611.5811000] #PayoffG results: [346.6105000, 609.3985000] #Third game #G := [[[368, 685], [480, 427]], [[396, 3], [677, 429]]] #p1 := 81/100, p2 := 83/100 #SimulateMG results #[396.7711000, 536.1516000] #[397.9837000, 537.3192000] #[397.0134000, 536.7094000] #[397.4420000, 531.4290000] #[397.4164000, 536.5544000] #PayoffG results: [397.8187000, 533.6532000] #p1 := 29/100, p2 := 17/100 #SimulateMG results #[582.3419000, 391.7284000] #[579.0861000, 388.7776000] #[579.2854000, 388.5464000] #[580.4231000, 389.3206000] #[579.9926000, 390.1166000] #PayoffG results: [580.4317000, 389.7212000] #p1 := 21/25, p2 := 37/100 #SimulateMG results #[460.1561000, 482.1906000] #[459.6234000, 485.3834000] #[459.2087000, 482.9702000] #[458.7625000, 484.9420000] #[460.0514000, 484.1534000] #PayoffG results: [460.0752000, 482.2872000] #Fourth game #G := [[[658, 235], [183, 542]], [[35, 498], [306, 612]]] #p1 := 59/100, p2 := 29/50 #SimulateMG results #[332.5253000, 437.7920000] #[328.3918000, 439.8538000] #[331.1129000, 439.2826000] #[329.0682000, 439.9640000] #[327.4461000, 440.6678000] #PayoffG results: [331.5312000, 438.5354000] #p1 := 16/25, p2 := 7/50 #SimulateMG results #[256.4660000, 534.8960000] #[256.8322000, 532.3813000] #[257.9431000, 533.2326000] #[258.2428000, 533.2167000] #[258.4144000, 532.3204000] #PayoffG results: [256.1816000, 533.9472000] #p1 := 67/100, p2 := 47/100 #SimulateMG results #[329.9286000, 452.3630000] #[331.3161000, 449.6802000] #[333.6836000, 448.4982000] #[333.6477000, 447.2855000] #[333.4242000, 449.7255000] #PayoffG results: [331.1354000, 450.7443000] #Fifth game #G := [[[716, 512], [681, 421]], [[3, 738], [49, 303]]] #p1 := 23/100, p2 := 1/20 #SimulateMG results #[193.8125000, 347.9056000] #[195.4834000, 348.3676000] #[191.1887000, 347.0736000] #[192.7499000, 347.5277000] #[191.6892000, 348.0837000] #PayoffG results: [192.9915000, 347.9340000] #p1 := 3/10, p2 := 69/100 #SimulateMG results #[226.7547000, 567.1548000] #[228.8640000, 564.3337000] #[222.6189000, 566.1630000] #[223.3816000, 568.9501000] #[227.4324000, 568.2235000] #PayoffG results: [223.6270000, 567.3420000] #p1 := 23/100, p2 := 39/50 #SimulateMG results #[169.1551000, 609.3469000] #[167.2128000, 607.8881000] #[173.5829000, 608.4774000] #[169.7790000, 610.1648000] #[170.6424000, 605.0473000] #PayoffG results: [173.0114000, 607.7264000] #3 TragedyOfTheCommons:= proc(v,G,c,n) local vdiff: vdiff := diff(v,G): return fsolve(v+(1/n)*G*vdiff-c,G): end: #v(G):=sqrt(1-G) #0.4108027069, 0.5240408206, 0.5790991062, 0.6120715420, 0.6341606640, 0.6500444109, 0.6620396765, 0.6714307918, 0.6789893673, 0.6852079369 #v(G):=(1-G)^(1/4) #0.5980909164, 0.7159713145, 0.7695811633, 0.8009276122, 0.8217454810, 0.8366883478, 0.8479928247, 0.8568756419, 0.8640589838, 0.8700002405 #v(G):=(1-G)^(3/4) #0.3111336476, 0.4083516515, 0.4565628023, 0.4855049838, 0.5048474518, 0.5187020389, 0.5291205867, 0.5372433987, 0.5437555690, 0.5490938253