# OK to post homework # RDB, 2022-01-30, HW2 read "C2.txt": # 1. I continue to identify as someone who knows Maple. # 2. (* for k from 1 to 5 do G := Rand2PlayerGame(3, 3, 10)[1]: print(Matrix(G)): print(`Best responses for row player are`, BR1v(G)): print(`Best responses for column player are`, BR2v(G)): od: *) # 3. Done! # 4. IsNash := (G, a1, a2) -> a1 in BR1(G, a2) and a2 in BR2(G, a1): # 5. PureNashEqui := proc(G) local row_best, col_best: row_best := BR1v(G): col_best := BR2v(G): equi := {}: for row_strat from 1 to nops(col_best) do col_responses := col_best[row_strat]: for col_response in col_responses do if row_strat in row_best[col_response] then equi := equi union {[row_strat, col_response]}: fi: od: od: for col_strat from 1 to nops(row_best) do row_responses := row_best[col_strat]: for row_response in row_responses do if col_strat in col_best[row_response] then equi := equi union {[row_response, col_strat]}: fi: od: od: equi: end: (* for k from 1 to 5 do G := Rand2PlayerGame(10, 12, 10)[1]: # Maple isn't a fan of printing big matrices, and I don't remember how to change its mind. # print(Matrix(G)): print(`Nash equilibria are`, PureNashEqui(G)): od: *)