This project is a solver for the Cauchy problem proposed on my master's degree final project, still to be published, and is under the MIT License. hrgames.py is a module with two functions, one that receives the adjacency matrix, payoff matrices, relationship matrix and initial state of the system to return the increments in each strategy for each vertex, the second receives the same parameters plus a time interval and number of steps and returns the state of the system after the game is played through that time interval. examples.py has a collection of examples made by myself and contributors.
To run the hrgames module you must have Numpy installed. To run any examples from examples.py you'll need Numpy, Matplotlib and the hrgames module. You can import the hyper-rational evolutionary game module using:
import hrgames as hrg
You can run the examples from examples.py using:
python examples.py example_name
Where example_name
can be any of the following:
simulations_madeo_mocenni
You can change any parameter directly on the script code. It's all commented and easily accessible for anyone.
Alternatively, you can import the examples script as a module using:
import examples as ex
Then run any example as a function. This way you can send in the optional parameters R
, tf
and xini
for the relationship matrix, final time and initial conditions, respectively. For example, one could use:
>>> import examples as ex
>>> finalTime = 200
>>> initialCond = np.divide(np.ones(3,2), 2)
>>> ex.k3_love_triangle(R = np.eye(3), tf = finalTime, xini = initialCond)
With this you'd get the plotted results from a love triangle game where all players are selfish with half probability of using either strategy for 200 time iterations.
There are many interesting games out there that were still not simulated as a hyper-rational game, so feel free to add any new or different examples!
This script solves the replicator equation Cauchy problem given by:
Where is the chance of the vertex player v to use strategy s and is the initial condition for every vertex and strategy. The hyper-rational payoff function is given by:
We define as the payment of the pure strategy s and as the expected payoff of the mixed strategy of v.
While most examples were made to be accessible and easy to use for everyone, the simulations_madeo_mocenni
example is a batch with 27 simulations that Madeo and Mocenni do on their original article, Game Interactions and Dynamics on Networked Populations, but with hyper-rational agents that use half of their energy for their profit and the other half is divided equally between their neighbors. Unlike the other examples, this batch of simulations are all written to text files that can be printed using my graph-print project, more specifically with the madeomocenniPrint script, that reads and prints all graphs at once. This example was made as a comparison between both models and the results are presented on my master's project.