Author | leonardo galdames |
Submission date | 2016-04-12 02:07:41.804520 |
Rating | 2783 |
Matches played | 440 |
Win rate | 25.23 |
Use rpsrunner.py to play unranked matches on your computer.
#!/usr/bin/env python
import random
opciones = ["S","R","P"]
vencedores = {'S':'R','R':'P','P':'S'}
tabla = {'S':1,'R':1,'P':1}
def actualizarTabla(output):
tabla[output] += 1
def dameMaximo():
maximo = 0
dato = ""
for k,v in tabla.items():
if v > maximo:
maximo = v
dato = k
return dato
def evitarPrediccion():
v1 = vencedores[dameMaximo()]
return vencedores[v1]
if (input == ""):
output = random.choice(opciones)
else:
if(input == vencedores[output]):
# actualizarTabla(input)
output = evitarPrediccion()
else:
actualizarTabla(input)
output = vencedores[dameMaximo()]