Um cientista louco acabou de criar uma nova espécie de bactéria! Ele decidiu nomear Noblus Gentlemanus, depois de observar seu comportamento. No entanto, suas bactérias ficaram sem comida e declararam guerra, pois são capazes de colher cadáveres de outras bactérias por comida suficiente para criar cópias de si mesmas. Existem várias subespécies diferentes dessa bactéria, que têm estratégias diferentes para jogar o Dilema do Prisioneiro, seu jogo favorito. Existem cinco bactérias de cada subespécie diferente. No dilema do prisioneiro, cada um dos dois jogadores escolhe simultaneamente o defeito ou coopera. Se um jogador escolhe cooperar e o outro escolhe o padrão, o inadimplente recebe 2 pontos e o cooperador perde 3 pontos. Se ambos os jogadores escolherem cooperar, ambos ganham 1 ponto. Se ambos os jogadores escolherem o padrão, ambos perderão 1 ponto.
Sendo nobres senhores, as bactérias decidiram travar esta guerra jogando 200 rodadas de jogos do Dilema Iterado do Prisioneiro. O perdedor de cada duelo cometerá suicídio, permitindo que o vencedor se clone. Em caso de empate, ambas as bactérias permanecerão vivas, mas nenhuma delas poderá se clonar. Além disso, todas as bactérias de uma partida transportam mais de 10% de seus pontos para a próxima partida. Um clone transporta os pontos da bactéria pela qual foi clonado. Além disso, há uma chance em dez a cada turno de uma bactéria se transformar em outra subespécie, com 0 pontos de bônus (se eu receber reclamações sobre a aleatoriedade disso, posso removê-la). Depois que as bactérias jogam um número desses duelos igual ao número de subespécies de bactérias vezes dez, o cientista louco acidentalmente derruba a placa de Petri em que as bactérias residem, e todas as bactérias adquirem novas fontes de alimento, terminando seus duelos. Isso é diferente de um concurso de dilemas de prisioneiros iterados comuns, pois envolve duelos 1x1 com pontos de transição, em vez de simplesmente tentar obter o máximo de pontos no geral. Isso faz uma grande diferença na eficácia de uma determinada estratégia.
Cada bactéria receberá entrada no início de seu turno no formato: (número do turno, pontos atuais, pontos inimigos, seus movimentos anteriores [em uma sequência, usando o caractere "c" para cooperar e o caractere "d" para defeito) ], movimentos anteriores dos inimigos [no mesmo formato]).
Aqui estão quatro exemplos de estratégias que serão inseridas. Na verdade, acho que o Defector pode vencer, mesmo que seja extremamente simples.
Olho por olho
def titfortatfunc(counter, mypoints, enpoints, mylist, enlist):
if counter==0 or enlist[counter-1] == "c":
return "c"
else:
return "d"
RandomPick
from random import choice
def randompickfunc(counter, mypoints, enpoints, mylist, enlist):
if counter == 199:
return "d"
else:
return choice(["d", "c"])
Cooperador
def cooperatorfunc(counter, mypoints, enpoints, mylist, enlist):
return "c"
Defector
def defectorfunc(counter, mypoints, enpoints, mylist, enlist):
return "d"
Todos os envios devem estar na forma de uma função Python 2.7, com o nome sendo o nome do envio sem espaços, com func
no final. Se alguém quiser enviar uma resposta em um idioma diferente, digite-o no pseudo-código, para que eu possa converter para Python em uma edição da sua resposta assim que tiver tempo, ou me dê instruções sobre como fazer a interface do seu idioma com o meu controlador que encontra-se abaixo, configurado para todos os envios a partir de 4 de junho.
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:
Este concurso está concluído
Se você quiser adicionar uma resposta, verei se consigo adicionar um placar pós-desafio abaixo do dos competidores originais. Eu adicionarei um assim que o programa de teste terminar (provavelmente mais 2-3 dias).
PONTOS FINAIS !!!!!
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
Então, parece que Perfect Gentleman é o vencedor. Parabéns a Draco18, que definitivamente merece sua marca de seleção verde.