コード例 #1
0
ファイル: tests.py プロジェクト: sourcery-ai-bot/baraja
 def test_naipe_init_cases(self):
     '''Revisa si el init de la clase Naipe funciona como fue disenado
     Naipe tiene que funcionar tanto con un par ordenado como con otro 
     objeto Naipe'''
     nn = Naipe((5, 2))
     nnnn = Naipe(nn)
     self.assertTrue(nn.numero == nnnn.numero and nn.palo == nnnn.palo)
コード例 #2
0
ファイル: tests.py プロジェクト: sourcery-ai-bot/baraja
 def test_swap_2_cards(self):
     B = Baraja()
     B.swap_2_cards((1, 0), Naipe((13, 3)))
     self.assertEqual(B.index((13, 3)), 0)
     self.assertEqual(B.index((1, 0)), 51)
     # Swap same card
     B.swap_2_cards((1, 0), Naipe((1, 0)))
     self.assertEqual(B.index((1, 0)), 51)
コード例 #3
0
ファイル: tests.py プロジェクト: sourcery-ai-bot/baraja
 def test_repr_naipes(self):
     #Revisa si la representasion esta funcionando para la guaya
     self.assertTrue(
         Naipe((1, 0)).repr_naipe() == "\N{PLAYING CARD ACE OF SPADES}")
     self.assertTrue(
         Naipe((5, 3)).repr_naipe() == "\N{PLAYING CARD FIVE OF DIAMONDS}")
     self.assertTrue(
         Naipe((11, 2)).repr_naipe() == "\N{PLAYING CARD JACK OF CLUBS}")
     self.assertTrue(
         Naipe((13, 1)).repr_naipe() == "\N{PLAYING CARD KING OF HEARTS}")
コード例 #4
0
ファイル: tests.py プロジェクト: sourcery-ai-bot/baraja
    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)
コード例 #5
0
ファイル: tests.py プロジェクト: sourcery-ai-bot/baraja
 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())
コード例 #6
0
ファイル: tests.py プロジェクト: sourcery-ai-bot/baraja
 def test_repr_naipes2(self):
     #Revisa si la representasion esta funcionando para la guaya
     self.assertTrue(
         Naipe.from_int(0).repr_naipe() == "\N{PLAYING CARD ACE OF SPADES}")
     self.assertTrue(
         Naipe.from_int(51).repr_naipe() ==
         "\N{PLAYING CARD KING OF DIAMONDS}")
     self.assertTrue(
         Naipe.from_int(30).repr_naipe() ==
         "\N{PLAYING CARD FIVE OF CLUBS}")
     self.assertTrue(
         Naipe.from_int(20).repr_naipe() ==
         "\N{PLAYING CARD EIGHT OF HEARTS}")
コード例 #7
0
ファイル: tests.py プロジェクト: sourcery-ai-bot/baraja
 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())
コード例 #8
0
ファイル: tests.py プロジェクト: sourcery-ai-bot/baraja
 def test_naipe_init_str(self):
     with self.assertRaisesRegex(ValueError,
                                 "The string \w has incorrect format"):
         Naipe('A')
         Naipe('ACC')
         Naipe('AAC')
         Naipe('AZ')
         Naipe('ACC')
         Naipe('11C')
         Naipe('99C')
         Naipe('0C')
         Naipe('1C')
コード例 #9
0
ファイル: tests.py プロジェクト: sourcery-ai-bot/baraja
    def test_random_1(self):
        '''
        Probamos la distribucion uniforme de la funcion revolver.
        '''
        n = 10e3
        p = 1 / 52.0
        # z_{\alpha/2} donde \alpha = 95%
        z = 1.95996398454
        stdev = sqrt(p * (1 - p) / n)

        B = Baraja()
        X = 0.0
        for _ in range(int(n)):
            B.revolver()
            if Naipe((1, 0)) == B.sacar_lista_naipes(1)[0]:
                X += 1.0
        #print('lo que se esta probando %s < %s < %s'%(p - z*stdev, X/n, p + z*stdev))
        self.assertTrue(p - z * stdev < X / n < p + z * stdev)
コード例 #10
0
ファイル: tests.py プロジェクト: sourcery-ai-bot/baraja
 def test_naipe_is_idempotent(self):
     self.assertIsInstance(Naipe('KD'), Naipe)
     self.assertIsInstance(Naipe(Naipe('KD')), Naipe)
コード例 #11
0
ファイル: tests.py プロジェクト: sourcery-ai-bot/baraja
 def test_randSample(self):
     B = Baraja()
     s = B.randSample(1, after=51)[0]
     self.assertEqual(Naipe('KD'), Naipe(s))
コード例 #12
0
ファイル: tests.py プロジェクト: sourcery-ai-bot/baraja
 def test_baraja_index2(self):
     B = Baraja()
     carta = Naipe((2, 0))
     ind = B.index(carta)
     self.assertEqual(ind, 4)
コード例 #13
0
ファイル: tests.py プロジェクト: sourcery-ai-bot/baraja
 def test_naipe_has_inverse(self):
     '''
     Revisa que la operacion de Naipe se pueda invertir
     '''
     prueba = Naipe((2, 3)).get_as_tuple() == (2, 3)
     self.assertTrue(prueba)
コード例 #14
0
ファイル: tests.py プロジェクト: sourcery-ai-bot/baraja
 def test_naipe_init_str2(self):
     str_lst = ['10C', '7D', 'AH', 'KH', '2H']
     for s in str_lst:
         self.assertEqual(s, Naipe(s).repr_image_name())
コード例 #15
0
ファイル: tests.py プロジェクト: sourcery-ai-bot/baraja
 def test_int_naipe_conversion(self):
     n = Naipe((2, 2))
     self.assertTrue(Naipe.from_int(n.get_as_int()) == n)
     self.assertTrue(Naipe.from_int(43).get_as_int() == 43)
     self.assertTrue(n.get_as_tuple() == (2, 2))
     self.assertTrue(
         Naipe.from_int(n.get_as_int()).get_as_tuple() == (2, 2))
     n = Naipe((1, 2))
     self.assertTrue(n.get_as_tuple() == (1, 2))
     with self.assertRaises(AssertionError):
         n = Naipe((0, 2))  # numero comienza de 1 no de cero
     with self.assertRaises(AssertionError):
         Naipe((14, 1))
     with self.assertRaises(AssertionError):
         Naipe((2, -1))
     with self.assertRaises(AssertionError):
         Naipe((2, 4))
コード例 #16
0
B.play(18, rand_sampling=False)

# + jupyter={"outputs_hidden": true}
# %%time
b = Baraja()
b.start_with(map(Naipe,['AS', 'QS', 'QD', 'JS', '10S']))
res = []
for i in range(32):
    res.append((act.actions[i], b.evaluate(i, sample_size=100)))
{k: v for k, v in sorted(res, key=lambda item: -item[1])}
# -

[i for i in range(5) if i not in act.actions[29] ], act.actions[29] 

for n in iter(m):
    print(Naipe(n).repr_naipe())

m = b.revolver().sacar_mano(5)
print(m)
m.hay_premio()

'jacks' in m.hay_premio().lower()

list(filter(lambda x: x[0] == 1, mac))[0]

n=0
#conjunto = set()
b.revolver()
while True and n<10000:
    b.revolver()
    ma = b.sacar_mano(5)