403Webshell
Server IP : 172.64.80.1  /  Your IP : 172.69.58.221
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/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhosts/federalpolyede.edu.ng/phd_code/gen_game.py
import numpy as np

# Assuming there are two players and three strategies for each player
num_players = 2
num_strategies = 3

#payoff matrix Data
player1_payoffs = np.array([[0, 0, 0], [8, -2, -2], [6, 6, -4]])
player2_payoffs = np.array([[10, 7, 4], [-10, 7, 4], [-10, -13, 4]])

# Example probabilities associated with a Nash equilibrium
#p0=player1_payoffs[0,0]
#p1=1
#p2=2
#q0=3
#q1=4
#q2=5
nash_equilibrium_probs = np.array([[0.2, 0.2, 0.6],[0.7, 0.15, 0.15] ])

# Number of simulations or iterations
num_simulations = 128000
attack_count_0=0
attack_count_1=0
attack_count_2=0
defend_count_0=0
defend_count_1=0
defend_count_2=0

# Simulate strategies
for _ in range(num_simulations):
    chosen_strategies = []
    for player in range(num_players):
        random_num = np.random.random()  # Generate a random number between [0, 1]

        cumulative_probs = np.cumsum(nash_equilibrium_probs[player])
        chosen_strategy = np.argmax(random_num <= cumulative_probs)
        chosen_strategies.append(chosen_strategy)
        if (chosen_strategies[0]==0):
            attack_count_0+=1
            # print(attack_count_0/2)
            # print(chosen_strategies[0])
        if (chosen_strategies[0]==1):
            attack_count_1+=1
        if (chosen_strategies[0]==2):
            attack_count_2+=1
        if (chosen_strategies[-1]==0):
            defend_count_0=defend_count_0+1
        if (chosen_strategies[-1]==1):
            defend_count_1=defend_count_1+1
        if (chosen_strategies[-1]==2):
            defend_count_2=defend_count_2+1
    print("Chosen Strategies:", chosen_strategies)
    # print(chosen_strategies[0],chosen_strategies[-1])
#indices = max(enumerate(chosen_strategies), key=lambda x: x[1])[0]
# print(indices)
attack_0=attack_count_0/num_simulations*.5
attack_1=attack_count_1/num_simulations*.5
attack_2=attack_count_2/num_simulations*.5
defend_0=defend_count_0/num_simulations*.5
defend_1=defend_count_1/num_simulations*.5
defend_2=defend_count_2/num_simulations*.5
# print(attack_0, attack_1,attack_2,attack_count_2/2,num_simulations)
# print(defend_0,defend_1,defend_2,defend_count_2/2,num_simulations)
print(attack_0, attack_1,attack_2)
print(defend_0,defend_1,defend_2)
# print(attack_count_0)




Youez - 2016 - github.com/yon3zu
LinuXploit