一位疯狂的科学家刚刚创造出一种新细菌!他决定将其命名为Noblus Gentlemanus,观察其行为后。但是,他的细菌已经用完了食物,并宣战了,因为它们能够收获其他细菌的尸体以获取足够的食物来复制自身。该细菌有许多不同的亚种,在玩他们最喜欢的囚徒困境时有不同的策略。每个不同亚种都有5种细菌。在《囚徒困境》中,两个玩家中的每一个都同时选择缺憾或合作。如果一个玩家选择合作,而另一个选择默认,则默认者获得2分,而合作者则损失3分。如果双方选择合作,双方将获得1分。如果两个玩家都选择默认值,则两个玩家都将失去1分。
作为贵族绅士,这种细菌决定通过玩200轮漫长的囚徒困境游戏来打赢这场战争。每个决斗的失败者都会自杀,从而使胜利者得以自我克隆。如果打成平手,两种细菌都将保持存活,但两者均无法克隆。此外,一场比赛中的所有细菌都会将其点数的10%携带到下一场比赛中。克隆携带克隆它的细菌的各个点。同样,每轮细菌有十分之一的机会突变为另一种亚种,获得0分(如果我收到对此随机性的投诉,可以将其删除)。在细菌打出的决斗数量等于细菌的亚种数量乘以十之后,疯狂的科学家不小心掉落了细菌所在的培养皿,所有细菌都获得了新的食物来源,结束了决斗。这与普通的迭代囚徒困境竞赛不同,因为它涉及带有结转分数的1v1决斗,而不是简单地尝试总体上获得最高分数。这在给定策略的有效性方面有很大的不同。
每个细菌将在回合开始时以以下格式输入:(回合编号,当前点,敌人点,您之前的举动[以字符串形式,以字符“ c”表示合作,以字符“ d”表示缺陷) ],敌人先前的举动[格式相同])。
这里将输入四个样本策略。我实际上认为Defector可能会获胜,尽管它非常简单。
针锋相对
def titfortatfunc(counter, mypoints, enpoints, mylist, enlist):
if counter==0 or enlist[counter-1] == "c":
return "c"
else:
return "d"
随机选择
from random import choice
def randompickfunc(counter, mypoints, enpoints, mylist, enlist):
if counter == 199:
return "d"
else:
return choice(["d", "c"])
合作者
def cooperatorfunc(counter, mypoints, enpoints, mylist, enlist):
return "c"
偏转器
def defectorfunc(counter, mypoints, enpoints, mylist, enlist):
return "d"
所有提交都必须采用Python 2.7函数的形式,名称是提交的名称,不带空格,并func
在末尾。如果有人想用其他语言提交答案,请用伪代码输入答案,以便我有时间后在对您的答案进行编辑时转换为Python,或者给我有关将语言与控制器交互的说明,可在6月4日之前为所有提交设置以下内容。
from titfortat import titfortatfunc
from randompick import randompickfunc
from cooperator import cooperatorfunc
from defector import defectorfunc
from luckytitfortat import luckytitfortatfunc
from randomtitfortat import randomtitfortatfunc
from remorsefulaggressor import remorsefulaggressorfunc
from everyother import everyotherfunc
from niceguy import niceguyfunc
from titfortatbackstab import titfortatbackstabfunc
from gentleDefector import gentleDefectorfunc
from anticapitalist import anticapitalistfunc
from grimtrigger import grimtriggerfunc
from bizzaro import bizzarofunc
from neoanticapitalist import neoanticapitalistfunc
from bittertat import bittertatfunc
from teamer import teamerfunc
from copyfirst import copyfirstfunc
from exploitivetat import exploitativetatfunc
from defectorv2 import defectorv2func
from crazytat import crazytatfunc
from randomchoicev2 import randomchoicev2func
from twotitsforatat import twotitsforatatfunc
from threetitsforatat import threetitsforatatfunc
from fourtitsforatat import fourtitsforatatfunc
from fivetitsforatat import fivetitsforatatfunc
from sixtitsforatat import sixtitsforatatfunc
from tentitsforatat import tentitsforatatfunc
from theelephant import theelephantfunc
from xbittertat import xbittertatfunc
from fifteentitsforatat import fifteentitsfortatfunc
from twentytitsforatat import twentytitsforatatfunc
from fox import foxfunc
from onehundredfortysixtitsforatat import onehundredfourtysixtitsforatatfunc
from gameofthrones import gameofthronesfunc
from boy import boyfunc
from grimace import grimacefunc
from fiftytitsforatat import fiftytitsfortatfunc
from soreloser import soreloserfunc
from everyotherd import everyotherdfunc
from fiftythreetitsfortat import fiftythreetitsfortatfunc
from twentyfivetitsfortat import twentyfivetitsfortatfunc
from handshake import handshakefunc
from anty import antyfunc
from fiftyfourtitsforatat import fiftyfourtitsfortatfunc
from kindatitsfortat import kindatitsfortatfunc
import random
players = 38
rounds = players*10
def runcode(num, points1, points2, history1, history2, cell):
ans = ""
if cell == 0:
ans = titfortatfunc(num, points1, points2, history1, history2)
elif cell == 1:
ans = randompickfunc(num, points1, points2, history1, history2)
elif cell == 2:
ans = cooperatorfunc(num, points1, points2, history1, history2)
elif cell == 3:
ans = defectorfunc(num, points1, points2, history1, history2)
elif cell == 4:
ans = luckytitfortatfunc(num, points1, points2, history1, history2)
elif cell == 5:
ans = randomtitfortatfunc(num, points1, points2, history1, history2)
elif cell == 6:
ans = remorsefulaggressorfunc(num, points1, points2, history1, history2)
elif cell == 7:
ans = everyotherfunc(num, points1, points2, history1, history2)
elif cell == 8:
ans = niceguyfunc(num, points1, points2, history1, history2)
elif cell == 9:
ans = titfortatbackstabfunc(num, points1, points2, history1, history2)
elif cell == 10:
ans = gentleDefectorfunc(num, points1, points2, history1, history2)
elif cell == 11:
ans = anticapitalistfunc(num, points1, points2, history1, history2)
elif cell == 12:
ans = grimtriggerfunc(num, points1, points2, history1, history2)
elif cell == 13:
ans = bizzarofunc(num, points1, points2, history1, history2)
elif cell == 14:
ans = neoanticapitalistfunc(num, points1, points2, history1, history2)
elif cell == 15:
ans = tentitsforatatfunc(num, points1, points2, history1, history2)
elif cell == 16:
ans = bittertatfunc(num, points1, points2, history1, history2)
elif cell == 17:
ans = copyfirstfunc(num, points1, points2, history1, history2)
elif cell == 18:
ans = exploitativetatfunc(num, points1, points2, history1, history2)
elif cell == 19:
ans = sixtitsforatatfunc(num, points1, points2, history1, history2)
elif cell == 20:
ans = fifteentitsfortatfunc(num, points1, points2, history1, history2)
elif cell == 21:
ans = fivetitsforatatfunc(num, points1, points2, history1, history2)
elif cell == 22:
ans = twentytitsforatatfunc(num, points1, points2, history1, history2)
elif cell == 23:
ans = threetitsforatatfunc(num, points1, points2, history1, history2)
elif cell == 24:
ans = fiftyfourtitsfortatfunc(num, points1, points2, history1, history2)
elif cell == 25:
ans = theelephantfunc(num, points1, points2, history1, history2)
elif cell == 26:
ans = xbittertatfunc(num, points1, points2, history1, history2)
elif cell == 27:
ans = foxfunc(num, points1, points2, history1, history2)
elif cell == 28:
ans = gameofthronesfunc(num, points1, points2, history1, history2)
elif cell == 29:
ans = boyfunc(num, points1, points2, history1, history2)
elif cell == 30:
ans = grimacefunc(num, points1, points2, history1, history2)
elif cell == 31:
ans = soreloserfunc(num, points1, points2, history1, history2)
elif cell == 32:
ans = everyotherdfunc(num, points1, points2, history1, history2)
elif cell == 33:
ans = twentyfivetitsfortatfunc(num, points1, points2, history1, history2)
elif cell == 34:
ans = fiftythreetitsfortatfunc(num, points1, points2, history1, history2)
elif cell == 35:
ans = handshakefunc(num, points1, points2, history1, history2)
elif cell == 36:
ans = antyfunc(num, points1, points2, history1, history2)
elif cell == 37:
ans = kindatitsfortatfunc(num, points1, points2, history1, history2)
return ans
def fight(l1,l2):
num1,num2=l1[0],l2[0]
points1,points2=l1[1],l2[1]
history1 = ""
history2 = ""
for num in range(200):
p1 = runcode(num, points1, points2, history1, history2, num1)
p2 = runcode(num, points2, points1, history2, history1, num2)
history1+=p1
history2+=p2
if p1 == "c" and p2 == "c":
points1 += 1
points2 += 1
elif p1 == "c" and p2 == "d":
points1 -= 3
points2 += 2
elif p1 == "d" and p2 == "c":
points1 += 2
points2 -= 3
elif p1 == "d" and p2 == "d":
points1 -= 1
points2 -= 1
if points1 > points2:
return [l1[0], points1/10], [l1[0], points1/10]
elif points1 < points2:
return [l2[0], points2/10], [l2[0], points2/10]
else:
return [l1[0], points1/10], [l2[0], points2/10]
def rounddoer(bots):
bots2=[]
for x in range(len(bots)):
if x%2==0:
out1, out2 = fight(bots[x], bots[x-1])
bots2.append(out1)
bots2.append(out2)
return bots2
def gamedoer():
bots=[[0,0],[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0],[8,0],[9,0],[10,0],[11,0],[12,0],[13,0],[14,0],[15,0],[16,0],[17,0],[18,0],[19,0],[20,0],[21,0],[22,0],[23,0],[24,0],[25,0],[26,0],[27,0],[28,0],[29,0],[30,0],[31,0],[32,0],[33,0],[34,0],[35,0],[36,0],[37,0],[0,0],[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0],[8,0],[9,0],[10,0],[11,0],[12,0],[13,0],[14,0],[15,0],[16,0],[17,0],[18,0],[19,0],[20,0],[21,0],[22,0],[23,0],[24,0],[25,0],[26,0],[27,0],[28,0],[29,0],[30,0],[31,0],[32,0],[33,0],[34,0],[35,0],[36,0],[37,0],[0,0],[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0],[8,0],[9,0],[10,0],[11,0],[12,0],[13,0],[14,0],[15,0],[16,0],[17,0],[18,0],[19,0],[20,0],[21,0],[22,0],[23,0],[24,0],[25,0],[26,0],[27,0],[28,0],[29,0],[30,0],[31,0],[32,0],[33,0],[34,0],[35,0],[36,0],[37,0],[0,0],[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0],[8,0],[9,0],[10,0],[11,0],[12,0],[13,0],[14,0],[15,0],[16,0],[17,0],[18,0],[19,0],[20,0],[21,0],[22,0],[23,0],[24,0],[25,0],[26,0],[27,0],[28,0],[29,0],[30,0],[31,0],[32,0],[33,0],[34,0],[35,0],[36,0],[37,0],[0,0],[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0],[8,0],[9,0],[10,0],[11,0],[12,0],[13,0],[14,0],[15,0],[16,0],[17,0],[18,0],[19,0],[20,0],[21,0],[22,0],[23,0],[24,0],[25,0],[26,0],[27,0],[28,0],[29,0],[30,0],[31,0],[32,0],[33,0],[34,0],[35,0],[36,0],[37,0]]
random.shuffle(bots)
counter=0
while counter < rounds:
counter += 1
bots = rounddoer(bots)
if random.randint(0,10) == 9:
bots[random.randint(0, players*5)-1] = [random.randint(0, players-1), 0]
random.shuffle(bots)
## for item in bots:
## print str(item[0]) + " with " + str(item[1]) + " bonus points."
return bots
a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33,a34,a35,a36,a37,mycounter=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
while mycounter < 1000:
mycounter += 1
bots = gamedoer()
print "Game: " + str(mycounter)
for item in bots:
if item[0]==0:
a0 += 1
if item[0]==1:
a1 += 1
if item[0]==2:
a2 += 1
if item[0]==3:
a3 += 1
if item[0]==4:
a4 += 1
if item[0]==5:
a5 += 1
if item[0]==6:
a6 += 1
if item[0]==7:
a7 += 1
if item[0]==8:
a8 += 1
if item[0]==9:
a9 += 1
if item[0]==10:
a10 += 1
if item[0]==11:
a11 += 1
if item[0]==12:
a12 += 1
if item[0]==13:
a13 += 1
if item[0]==14:
a14+=1
if item[0]==15:
a15+=1
if item[0]==16:
a16+=1
if item[0]==17:
a17+=1
if item[0]==18:
a18 += 1
if item[0]==19:
a19+=1
if item[0]==20:
a20+=1
if item[0]==21:
a21+=1
if item[0]==22:
a22+=1
if item[0]==23:
a23+=1
if item[0]==24:
a24+=1
if item[0]==25:
a25+=1
if item[0]==26:
a26+=1
if item[0]==27:
a27+=1
if item[0]==28:
a28+=1
if item[0]==29:
a29+=1
if item[0]==30:
a30+=1
if item[0]==31:
a31+=1
if item[0]==32:
a32+=1
if item[0]==33:
a33+=1
if item[0]==34:
此竞赛现已结束
如果您想添加一个答案,我将看看是否可以在原始参赛者之一的下方添加一个挑战后记分板。我将在测试程序完成后(大概再2-3天)添加一个。
最终得分!!!!
Tit for Tat: 18
Random Pick: 28
Cooperator: 19
Defector: 24
Lucky Tit for Tat: 23
Random Tit for Tat: 23
Remorseful Aggressor: 22
Every Other C: 23
Nice Guy: 18
Tit for Tat Backstab: 15
Gentle Defector: 22
Anticapitalist: 27
Grim Trigger: 19
Bizzaro: 21
NeoAnticapitalist: 24
Ten Tits for a Tat: 240
Bitter Tat: 12
Copy First: 30
Exploitative Tat: 19
Six Tits for a Tat: 16
Thirty Tits for Tat: 4129
Five Tits for a Tat: 22
Forty Tits for a Tat: 1972
Three Tits for a Tat: 22
Fifty Four Tits for a Tat: 25805
The Elephant: 31
Extra Bitter Tat: 28
Fox: 35
Game of Thrones: 11297
The Boy: 31
Grimace: 26
Sore Loser: 39
Every Other D: 18
Twenty Five Tits for a Tat: 2399
Fifty Three Tits for a Tat: 5487
Handshake: 28
Anty: 26
Kinda Tits for Tat: 20
Prudent Defector: 154539
Bizzarro Trigger: 25
Young Mathematician: 21
Older Mathematician: 16
Perfect Gentleman: 1953341
因此,看来完美绅士是胜利者。恭喜Draco18,他绝对值得其绿色复选标记。