Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/python
- # -*- coding: utf-8 -*-
- # Modadicto Aleatorio
- # idea por Marcos
- import sys
- from random import choice, randint
- A_TOTAL = 700.0
- B_TOTAL = 300.0
- times_won = {"A" : 0, "B": 0}
- # En el primer turno, la probabilidad de cada feudo es 1/2.
- print choice(["A", "B"])
- sys.stdout.flush()
- while(True):
- # Siempre elige un feudo aleatorio, pero la probabilidad de elegir cada
- # feudo será proporcional a la cantidad de veces que ese feudo dio más
- # dinero a cada familia
- # Ejemplo: si pasaron 19 turnos y el feudo A dio más plata 13 turnos y
- # el B dio más plata 6 turnos, la probabilidad de ir al A serán 13 / 19
- # y la de ir al B serán 6 / 19.
- a,b = sys.stdin.readline().strip().split(" ")
- best_payer = "A" if int(a) == 0 else "B"
- if "0" not in [a,b]:
- best_payer = "A" if (A_TOTAL/int(a))>(B_TOTAL/int(b)) else "B"
- times_won[best_payer] += 1
- r = randint(0, times_won["A"] + times_won["B"] - 1)
- print "A" if r < times_won["A"] else "B"
- sys.stdout.flush()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement