# OK to post homework # Vikrant, Feb 13 2022, Assignment 6 # ================================================================================ # 0. Code that has been given. # ================================================================================ read("C6.txt"): # ================================================================================ # 1. Simulate five mixed 2-strategy 2-player games with three random mixed strategies each. # ================================================================================ (* randomize(1307804445): r:= rand(0.0..1.0): for i from 1 to 5 do G:= RG(2,2,1000): print(matrix(G)): print(): for j from 1 to 3 do p1:= r(): p2:= r(): print(cat(p1,", ",p2)): p1:= convert(p1, rational): p2:= convert(p2, rational): print(cat("Simulated: ",SimulateMG(G,p1,p2,10^4))): print(cat("Exact: ",evalf(PayOffG(G,p1,p2)))): print(): od: od: *) # ================================================================================ # 2. Read and understand 1.2D of Gibbons. # ================================================================================ # Done. # ================================================================================ # 3. Tragedy of the Commons. # ================================================================================ TragedyOfTheCommons:= proc(v,G,c,n) local i,V,Cs: V:= subs(G=add(g[i],i=1..n),v): Cs:= {0<=add(g[i],i=1..n),add(g[i],i=1..n)<=1}: for i from 1 to n do Cs:= Cs union {0<=g[i],V+g[i]*diff(V,g[i])-c=0} od: solve(Cs,{seq(g[i],i=1..n)}): end: SociallyOptimal:= proc(v,G,c) solve({v+G*diff(v,G)-c=0,0<=G,G<=1},{G}): end: (* # The difference between the number of goats in the Nash Equilibrium and socially optimal solution indeed increases with the number of farmers. c:= 0.5: Vs:= [sqrt(1-G),(1-G)^(1/4),(1-G)^(3/4)]: for v in Vs do print(v): for sol in seq(TragedyOfTheCommons(v,G,c,n),n=1..10) do print(rhs(add(sol)-SociallyOptimal(v,G,c)[1])): od: print(): od: *)