# pastebin

Paste Search Dynamic
Recent pastes
payoff player
1. import numpy as np
2. from scipy.optimize import linprog
3.
4. # Payoff matrix for Player 1
5. payoff_player1 = np.array([[0, 25, 10],
6.                           [-25, 0, 5],
7.                           [-10, -5, 0]])
8.
9. # Payoff matrix for Player 2
10. payoff_player2 = -payoff_player1.T
11.
12. # Solve linear programming model for Player 1
13. c_player1 = [-25, -10]
14. A_ub_player1 = [[-1, 0], [0, -1], [0, 0]]
15. b_ub_player1 = [-1, -1, 1]
16. bounds_player1 = [(0, 1), (0, 1)]
17. result_player1 = linprog(c_player1, A_ub=A_ub_player1, b_ub=b_ub_player1, bounds=bounds_player1)
18.
19. # Optimal strategy and payoff for Player 1
20. optimal_strategy_player1 = result_player1.x
21. payoff_player1 = -result_player1.fun
22.
23. # Solve linear programming model for Player 2
24. c_player2 = [25, 10]
25. A_ub_player2 = [[1, 0], [0, 1], [0, 0]]
26. b_ub_player2 = [1, 1, -1]
27. bounds_player2 = [(0, 1), (0, 1)]
28. result_player2 = linprog(c_player2, A_ub=A_ub_player2, b_ub=b_ub_player2, bounds=bounds_player2)
29.
30. # Optimal strategy and payoff for Player 2
31. optimal_strategy_player2 = result_player2.x
32. payoff_player2 = result_player2.fun
33.
34. # Print the results
35. print("Optimal strategy for Player 1:", optimal_strategy_player1)
36. print("Payoff for Player 1:", payoff_player1)
37. print()
38. print("Optimal strategy for Player 2:", optimal_strategy_player2)
39. print("Payoff for Player 2:", payoff_player2)
40. # your code goes here
Parsed in 0.022 seconds