| Server IP : 172.64.80.1 / Your IP : 108.162.241.67 Web Server : Apache System : Linux mail.federalpolyede.edu.ng 5.10.0-32-amd64 #1 SMP Debian 5.10.223-1 (2024-08-10) x86_64 User : federalpolyede.edu.ng_idh35skikv ( 10000) PHP Version : 7.4.33 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/federalpolyede.edu.ng/phd_code/old/ |
Upload File : |
import numpy as np
import nashpy as nash
# Define the payoff matrices for each player
r=10; ca0=0
ca1=2;ca2=4
cd0=0;cd1=4;cd2=6
a11=0;a12=0;a13=0
a21=r-ca1;a22=-ca1;a23=-ca1
a31=r-ca2;a32=r-ca2;a33=-ca2
d11=r;d12=r-cd1;d13=r-cd2
d21=-r;d22=r-cd1;d23=r-cd2
d31=-r;d32=-r-cd1;d33=r-cd2
player1_payoffs = np.array([[a11, a12, a13], [a21, a22, a23], [a31, a32, a33]])
player2_payoffs = np.array([[d11, d12, d13], [d21, d22, d23], [d31, d32, d33]])
# Create the game
game = nash.Game(player1_payoffs, player2_payoffs)
# Find the Nash equilibria
equilibria = game.support_enumeration()
# Simulate the game with specific strategies
player1_strategy = [0.7, 0.15, 0.15]
player2_strategy = [0.2, 0.2, 0.6]
payoffs = game[player1_strategy, player2_strategy]
# Analyze the results
print("Nash Equilibria:")
for eq in equilibria:
print("Player 1 strategy:", eq[0])
print("Player 2 strategy:", eq[1])
print()
print("Simulated Payoffs:")
print("Player 1 payoff:", payoffs[0])
print("Player 2 payoff:", payoffs[1])