Giter Site home page Giter Site logo

uvaaxelrod's Introduction

UvA Axelrod

Simulating world trade relations based on the Axelrod tournament

Quick Start Guide

This package is written in Python, using libraries: NumPy, GeoPy, NetworkX which should be installed.

First Create a Jupyter notebook in the directory that also contains the UvAAxelrod folder. In this notebook we can import the package as follows:

    from UvAAxelrod import *
    import numpy as np
    import matplotlib.pyplot as plt

    np.random.seed(265)

% Unit test not yet runnable

To run an fast tournament: tournament = Tournament.create_play_tournament(G8, 100, [cooperate, defect, tit_for_tat])

The example above uses the G8 list of countries. Other parameters can be given to this method too, you should consult the dock string in the source code for that.

We draw a graph showing the evolution of the strategies

draw_stack(tour, xSize = 40)

We draw a graph illustrating the change in fitness of the population

draw_fitness_graph(tour, delta=True,wholePopulation=True,xSize=40)

Self reward

Countries can be set to receive fitness from their internal market. This is done by setting the self_reward parameter of the Tournament.play method equal to a function. The default value of this parameter in the Tournament.create_play_tournament method is defined in payoff_functions.py. If this parameter is set to None, then countries receive no fitness from their internal market.

mini tutorial notebook:

Execute the following code sequentially in a notebook

from UvAAxelrod import *
# important to have the .csv files in the directory of this notebook
WTO_2017 = get_WTO_countries(2017)
tournament_2017 = Tournament.create_play_tournament(
                 countries=WTO_2017, 
                 max_rounds=400, 
                 strategy_list=[defect, tit_for_tat, generous_tit_for_tat, cooperate], 
                 payoff_functions=default_payoff_functions, 
                 distance_function = lambda d: d, # defaults to just the identity
                 surveillance_penalty = True,
                 self_reward = selfreward, #default function
                 playing_each_other=True,
                 nr_strategy_changes = 1,
                 mutation_rate =0.1,
                 init_fitnes_as_m=False,
                 noise = 0.05
                 )
C_D_ratios_per_round(tournament_2017, x_size= 10, y_size=10)
outcome_ratios_per_round(tournament_2017, x_size=10, y_size=10)
draw_stack(tournament_2017)
mean_C(tournament_2017)
standard_deviation_C(tournament_2017)

uvaaxelrod's People

Contributors

rickgroeneweg avatar vocelik avatar skrapohl avatar

Stargazers

 avatar Marc avatar

Forkers

vocelik skrapohl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.