Esempio n. 1
0
    def test_start_with(self):
        B = Baraja()
        B.revolver()
        start_lst = [Naipe((1, 2)), Naipe((3, 0)), Naipe((6, 1))]
        B.start_with(start_lst)
        self.assertEqual(B.sacar_lista_naipes(3), start_lst)

        start_lst = [
            Naipe((1, 2)),
        ]
        B.start_with(start_lst)
        self.assertEqual(B.sacar_lista_naipes(1, start_at_0=True), start_lst)
Esempio n. 2
0
 def test_premios5(self):
     B = Baraja()
     B.revolver()
     start_lst = [
         Naipe('AH'),
         Naipe('AS'),
         Naipe('JH'),
         Naipe('JD'),
         Naipe('KH')
     ]
     B.start_with(start_lst)
     man = B.sacar_mano(5)
     self.assertEqual('two pair', man.hay_premio().lower())
Esempio n. 3
0
 def test_premios4(self):
     B = Baraja()
     B.revolver()
     start_lst = [
         Naipe('AH'),
         Naipe('QH'),
         Naipe('JH'),
         Naipe('10H'),
         Naipe('KH')
     ]
     B.start_with(start_lst)
     man = B.sacar_mano(5)
     self.assertEqual('royal flush', man.hay_premio().lower())
     self.assertEqual('royal flush', man.hay_premio().lower())
Esempio n. 4
0
 def test_play(self):
     B = Baraja()
     B.start_with(list(map(Naipe, ['2S', '2D', '3S', '2H', '2C'])))
     self.assertEqual(Prize.Poker, B.play(28))
     B.start_with(list(map(Naipe, ['2S', '2D', '3S', '3H', '2C'])))
     self.assertEqual(Prize.FullHouse, B.play(31))
     B = Baraja()
     B.start_with(map(Naipe, ['4S', '2C', '8S', 'QC', '4D']))
     self.assertEqual(Prize.TwoPair, B.play(18, rand_sampling=False))
Esempio n. 5
0
 def test_approx_best_move(self):
     b = Baraja()
     b.start_with(map(Naipe, ['AS', 'QS', 'JS', 'KS', '10S']))
     self.assertEqual(b.approx_best_move(sample_size=200)[0], 31)
Esempio n. 6
0
# ---

import random as r
import itertools as itt
import sys
from scipy.stats import chi2
# %load_ext autoreload
# %autoreload 2
import actions as act
from collections import Counter
from baraja import Naipe, Mano, Baraja, Prize
# #%run ~/code/EfedEquis/Efedequis/poquer/baraja/baraja

# %%time
b = Baraja()
b.start_with(map(Naipe,['6D', 'QH', '7H', '7S', '10C']))
#b.evaluate(13, sample_size=5000000)
prize_counter = Counter()
for _ in range(1000):
    prize_counter.update([b.play(13)])
print(prize_counter.most_common())
b.approx_best_move(sample_size=300)

# %%time
b = Baraja()
b.start_with(map(Naipe,['3S', 'QS', 'JD', '7S', '6S']))
res = []
for i in range(32):
    res.append((act.actions[i], b.evaluate_eff(i, sample_size=10)))
{k: v for k, v in sorted(res, key=lambda item: -item[1])}
best = b.approx_best_move(sample_size=100)