Menu

horizontal strategy transmission in Demographic PD

2016-05-23
2016-05-23
  • Anfisa Rekina

    Anfisa Rekina - 2016-05-23

    Hy, dear collegues,

    First of all, sorry for my english and a silly question (I am an ambitious zero in programming) .

    I am working with Epstein,s original code of "Demographic prisoner,s dilemma". His code assumes vertical strategy transmission, while I am also interested in horizontal transmission (an agent compares his payoff with a payoff of a random neighbor after every iterartion, if neighbor,s payoff is higher, agent changes his strategy on the one of neighbor in the next iteration).
    Here is what I have done - after an original description of "Play one round of the game with another agent" I have added some code "my art").
    And I want to ask you, is it right? does it satisfy what I wanted it to do? There are no errors in Eclipse, and visually there are some changes in a final model in Ascape. But still, I am not qualified enough (at all) to be sure it is right.

    // Play one round of the game with another agent.

    public void play(Agent partner) {
        if (this.strategy == PD2D.COOPERATE) {
            if (((Player) partner).strategy == PD2D.COOPERATE) {
                this.wealth += ((PD2D) scape.getRoot()).getPayoff_C_C();
                ((Player) partner).wealth += ((PD2D) scape.getRoot()).getPayoff_C_C();
    
            } else { //partner defects
                this.wealth += ((PD2D) scape.getRoot()).getPayoff_C_D();
                ((Player) partner).wealth += ((PD2D) scape.getRoot()).getPayoff_D_C();}
    
        } else { //this defects
            if (((Player) partner).strategy == PD2D.COOPERATE) {
                this.wealth += ((PD2D) scape.getRoot()).getPayoff_D_C();
                ((Player) partner).wealth += ((PD2D) scape.getRoot()).getPayoff_C_D();
    
            } else { //partner defects
                this.wealth += ((PD2D) scape.getRoot()).getPayoff_D_D();
                ((Player) partner).wealth += ((PD2D) scape.getRoot()).getPayoff_D_D();
    

    ** // my art!**

                { List neighbors = findNeighborsOnHost();
                for (Object neighbor : neighbors) {
            if (this.wealth < ((Player) neighbor).wealth) {             
                this.strategy = ((Player) neighbor).strategy;}
            }
    
        }}}
        }
    
     

    Last edit: Anfisa Rekina 2016-05-23
  • Deuce Thevenow

    Deuce Thevenow - 2020-05-08
    Post awaiting moderation.

Log in to post a comment.

MongoDB Logo MongoDB