def sp_strategies():
    """The list of strategies used in Stewart and Plotkin's 2012 tournament."""

    strategies = [
        axelrod.Cooperator(),  # ALLC
        axelrod.Defector(),  # ALLD
        axelrod.GTFT(),
        axelrod.GoByMajority(soft=False),  # HARD_MAJO
        #axelrod.GoByMajority(soft=True), # SOFT_MAJO
        axelrod.TitFor2Tats(),  # TFT2
        axelrod.HardTitFor2Tats(),  # HARD_TFT2
        axelrod.Random(),  # RANDOM
        axelrod.WinStayLoseShift(),  # WSLS
        axelrod.TitForTat(),
        axelrod.HardTitForTat(),  # HARD_TFT
        axelrod.Grudger(),  # GRIM
        axelrod.Joss(),  # HARD_JOSS
        axelrod.ZDGTFT2(),
        axelrod.ZDExtort2(),
        axelrod.Prober(),
        axelrod.Prober2(),
        axelrod.Prober3(),
        axelrod.HardProber(),
        axelrod.Calculator(),
    ]
    return strategies
Beispiel #2
0
def main():
    strategies = [
        axelrod.Cooperator(),
        axelrod.Defector(),
        axelrod.Random(0.4),
        axelrod.Random(0.5),
        axelrod.Random(0.9),
        axelrod.Alternator(),
        axelrod.TitForTat(),
        axelrod.GTFT(),
        axelrod.WinStayLoseShift(),
        axelrod.ZDGTFT2(),
        axelrod.ZDExtort2(),
        axelrod.TitFor2Tats(),
        axelrod.TwoTitsForTat(),
        axelrod.CyclerCCD(),
        axelrod.CyclerCCCD(),
        axelrod.CyclerCCCCCD(),
        axelrod.HardTitForTat(),
        axelrod.AntiCycler(),
        axelrod.Grudger()
    ]

    for opponent in strategies:
        data_dict, test_results, estimate = infer_depth(opponent)

        print opponent
        print "-" * len(str(opponent))
        print "Collected Data"
        print_dict(data_dict)
        C_count = sum(v[0] for (k, v) in data_dict.items())
        D_count = sum(v[1] for (k, v) in data_dict.items())
        print "C count, D count: %s, %s" % (C_count, D_count)
        print "\nFisher Exact Tests"
        print_dict(test_results)
        print "\nEstimated Memory One Probabilities"
        print_dict(estimate)
        print
Beispiel #3
0
selfScore = []
oppScore = []
selfAvgList = []
oppAvgList = []
avgScore = []
oppAvgScore = []

evolveCode = [0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0,\
 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0]     # For final experiments

singEvolveCode = [0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1,\
 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0]

# strategies = [axelrod.Cooperator(), axelrod.Defector()]
# strategies = [axelrod.TitFor2Tats(), axelrod.SuspiciousTitForTat(), axelrod.TitForTat(), axelrod.Prober()]
strategies = [axelrod.Cooperator(), axelrod.Defector(), axelrod.CyclerCCD(),axelrod.HardTitForTat(),\
axelrod.TitFor2Tats(), axelrod.SuspiciousTitForTat(), axelrod.Random(), axelrod.TitForTat(), axelrod.Prober()]

learner = axelrod.LearnerAxel(memory_depth=2, exploreProb=0.1, learnerType=2)
multAxel = axelrod.EvolveAxel(3, evolveCode, 'MULT')
singAxel = axelrod.EvolveAxel(3, evolveCode, 'SING')

ply = learner

# print ply

for p in strategies:
    print "Currently playing against strategy:", p
    for turn in range(numTurns):
        ply.play(p)
    selfList = map(ScoreMatrix, zip(ply.history, p.history))
Beispiel #4
0
    axl.MoreGrofman(),
    axl.MoreTidemanAndChieruzzi(),
    axl.RichardHufford(),
    axl.Tester(),
    axl.Tranquilizer(),
    axl.Weiner(),
    axl.White(),
    axl.WmAdams(),
    axl.Yamachi()
]

# The list of agents playing in the Stewart-Plotkin's tournament.
steward_plotkin_players = [
    axl.ZDExtort2(),
    axl.HardGoByMajority(),
    axl.HardTitForTat(),
    axl.HardTitFor2Tats(),
    axl.GTFT(),
    axl.ZDGTFT2(),
    axl.Calculator(),
    axl.Prober(),
    axl.Prober2(),
    axl.Prober3(),
    axl.HardProber(),
    axl.NaiveProber()
]

# The list of agents playing in the Case's simulation
case_players = [
    axl.Cooperator(),
    axl.Defector(),
Beispiel #5
0
scores['C']['D'] = (0, 5)
scores['D']['D'] = (1, 1)


def ScoreMatrix(moves):
    moveA = moves[0]
    moveB = moves[1]
    return scores[moveA][moveB][0]


# strategies = [s() for s in axelrod.basic_strategies]
#strategies = [axelrod.Cooperator(), axelrod.Defector(), axelrod.CyclerCCCD(), axelrod.CyclerCCD(), \
# axelrod.HardGoByMajority(), axelrod.GoByMajority(), axelrod.HardTitForTat(), axelrod.Random(), axelrod.TitForTat(), \
# axelrod.SuspiciousTitForTat(), axelrod.TitFor2Tats(), axelrod.Prober(), axelrod.Prober2(), axelrod.Prober3()]

strategies = [axelrod.Cooperator(), axelrod.Defector(), axelrod.CyclerCCD(), axelrod.HardGoByMajority(), axelrod.GoByMajority(), \
axelrod.HardTitForTat(), axelrod.TitFor2Tats(), axelrod.SuspiciousTitForTat(), axelrod.Random(), axelrod.TitForTat(), axelrod.Prober()]

creator.create(
    "FitnessMax", base.Fitness,
    weights=(1.0, ))  #Weight is a tuple, so here we use a single objective
creator.create(
    "Individual", list,
    fitness=creator.FitnessMax)  #Define the structure of the individuals

toolbox = base.Toolbox()  #Initialize it?

memLength = 3

toolbox.register("attr_bool", random.randint, 0, 1)  # Random boolean
toolbox.register(
    "individual", tools.initRepeat, creator.Individual, toolbox.attr_bool,