spd_ex v0.1.0 SpdEx

Main module

Link to this section Summary

Functions

Check whether the calculation is converged or not

Generate n agents with continuous ID from 1 to n

Return fraction of cooepartors

From the given agent_list, search agents whose ID is in the given neighbors_id

Decide the next strategy by Imitation-Max rule

Set initial cooperators

Add neighbors to all agents. Only neighbor’s id is provided to focal agents

Main function

Count payoff obtained in one timestep

Decide the next strategy by PW-Fermi rule

Time evolution loop. The entire procedure is as follows;

  1. Agents get payoff
  2. Decide the next strategy based on PW-Fermi
  3. Update strategy
  4. Count the fraction of cooperators
  5. Check whether converged or not
  6. If converged, stop the calculation with a given dilemma setting. If not, go to the next timestep

Insert next strategy into current strategy

Write the fraction of cooperators to csv file

Link to this section Functions

Link to this function converged?(fc_list)

Check whether the calculation is converged or not.

Link to this function generate_agents(n)

Generate n agents with continuous ID from 1 to n

Link to this function get_fraction(agent_list)

Return fraction of cooepartors

Link to this function get_neighbors(agent_list, neighbors_id)

From the given agent_list, search agents whose ID is in the given neighbors_id

Link to this function im_update(result)

Decide the next strategy by Imitation-Max rule

Link to this function init_strategy(result, init_cid)

Set initial cooperators

Main function

Count payoff obtained in one timestep

Link to this function pf_update(result)

Decide the next strategy by PW-Fermi rule

Link to this function timestep(result, time)

Time evolution loop. The entire procedure is as follows;

  1. Agents get payoff
  2. Decide the next strategy based on PW-Fermi
  3. Update strategy
  4. Count the fraction of cooperators
  5. Check whether converged or not
  6. If converged, stop the calculation with a given dilemma setting. If not, go to the next timestep.
Link to this function update_strategy(result)

Insert next strategy into current strategy

Link to this function write_to_csv(result)

Write the fraction of cooperators to csv file