def test_can_chow(self): h = hand.Hand(0) h.main_hand = [0,0,1,1,0,0,0,1,1,0, 0,0,0,0,1,0,1,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,1,1,0,1,0,0] self.assertIs(h.can_chow(1), True) self.assertIs(h.can_chow(2), False) self.assertIs(h.can_chow(6), True) self.assertIs(h.can_chow(8), False) self.assertIs(h.can_chow(9), True) self.assertIs(h.can_chow(15), True) self.assertIs(h.can_chow(30), False) self.assertIs(h.can_chow(33), False)
def test_calc_shanten_normal(self): h = hand.Hand(0) h.main_hand = [0,1,1,1,0,0,0,0,2,2, 0,0,0,0,1,1,1,0,0,0, 0,0,0,0,0,0,0,1,1,1, 0,0,0,0,0,0,0] self.assertEqual(hand.calc_shanten_normal(h), 0) h.main_hand = [0,1,1,1,0,0,0,1,1,0, 0,0,0,0,1,1,1,0,0,0, 0,0,1,0,1,0,0,1,1,1, 0,0,0,0,0,0,0] self.assertEqual(hand.calc_shanten_normal(h), 1) h.main_hand = [0,1,1,1,0,0,0,1,1,0, 0,0,0,0,1,1,1,0,0,0, 0,0,0,0,0,0,0,1,1,1, 0,0,2,0,0,0,0] self.assertEqual(hand.calc_shanten_normal(h), 0) h.main_hand = [0,1,1,0,1,1,0,0,0,0, 0,0,0,0,0,1,1,1,0,0, 0,1,1,1,0,1,1,0,1,1, 0,0,0,0,0,0,0] self.assertEqual(hand.calc_shanten_normal(h), 2) h.main_hand = [0,1,1,0,1,1,0,0,0,0, 0,0,0,0,0,1,1,1,0,0, 0,1,1,1,0,1,1,0,2,0, 0,0,0,0,0,0,0] self.assertEqual(hand.calc_shanten_normal(h), 1) h.main_hand = [0,0,0,0,0,0,0,0,0,0, 0,1,1,1,0,0,0,0,0,0, 0,0,0,1,3,1,1,1,0,0, 0,0,0,1,0,2,0] self.assertEqual(hand.calc_shanten_normal(h), 1) h.main_hand = [0,3,1,1,1,1,1,1,1,3, 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] self.assertEqual(hand.calc_shanten_normal(h), 0)
def __init__(self, id): self.id = id self.hand = hand.Hand(id) self.point = 0
def test_kakan(self): h = hand.Hand(0) h.open_sets[0][1] = 3 h.kakan(1) self.assertEqual(h.open_sets[0][1], 4)
def test_can_ankan(self): h = hand.Hand(0) h.main_hand[1] = 2 self.assertIs(h.can_ankan(1), False) h.main_hand[1] = 3 self.assertIs(h.can_ankan(1), True)
def test_can_kakan(self): h = hand.Hand(0) h.open_sets[0][1] = 1 self.assertIs(h.can_kakan(1), False) h.open_sets[0][1] = 3 self.assertIs(h.can_kakan(1), True)
def test_calc_shanten(self): h = hand.Hand(0) # seven_pair h.main_hand = [0,0,0,0,0,0,0,0,0,0, 0,0,2,2,0,1,0,0,0,0, 0,0,2,1,0,1,0,0,0,0, 0,0,2,1,0,1,0] self.assertEqual(hand.calc_shanten(h), 2) h.main_hand = [0,0,0,0,0,0,0,0,0,0, 0,0,2,2,0,0,0,0,0,0, 0,0,2,2,0,0,0,0,0,0, 0,0,2,2,2,0,0] self.assertEqual(hand.calc_shanten(h), -1) # kokushi h.main_hand = [0,1,0,0,0,0,0,0,0,1, 0,1,0,0,0,0,0,0,0,1, 0,1,0,0,0,0,0,0,0,1, 1,1,2,3,0,0,0] self.assertEqual(hand.calc_shanten(h), 2) h.main_hand = [0,1,0,0,0,0,0,0,0,1, 0,1,0,0,0,0,0,0,0,1, 0,1,0,0,0,0,0,0,0,1, 1,1,1,1,1,1,2] self.assertEqual(hand.calc_shanten(h), -1) # normal h.main_hand = [0,0,1,2,1,1,0,2,0,0, 0,0,2,0,0,0,0,1,0,1, 0,0,0,0,0,0,0,0,0,0, 0,1,0,0,1,0,0] self.assertEqual(hand.calc_shanten(h), 2) h.main_hand = [0,1,1,1,0,0,0,0,2,2, 0,0,0,0,1,1,1,0,0,0, 0,0,0,0,0,0,0,1,1,1, 0,0,0,0,0,0,0] self.assertEqual(hand.calc_shanten(h), 0) h.main_hand = [0,1,1,1,0,0,0,1,1,0, 0,0,0,0,1,1,1,0,0,0, 0,0,1,0,1,0,0,1,1,1, 0,0,0,0,0,0,0] self.assertEqual(hand.calc_shanten(h), 1) h.main_hand = [0,1,1,1,0,0,0,1,1,0, 0,0,0,0,1,1,1,0,0,0, 0,0,0,0,0,0,0,1,1,1, 0,0,2,0,0,0,0] self.assertEqual(hand.calc_shanten(h), 0) h.main_hand = [0,1,1,0,1,1,0,0,0,0, 0,0,0,0,0,1,1,1,0,0, 0,1,1,1,0,1,1,0,1,1, 0,0,0,0,0,0,0] self.assertEqual(hand.calc_shanten(h), 2) h.main_hand = [0,1,1,0,1,1,0,0,0,0, 0,0,0,0,0,1,1,1,0,0, 0,1,1,1,0,1,1,0,2,0, 0,0,0,0,0,0,0] self.assertEqual(hand.calc_shanten(h), 1) h.main_hand = [0,0,0,0,0,0,0,0,0,0, 0,1,1,1,0,0,0,0,0,0, 0,0,0,1,3,1,1,1,0,0, 0,0,0,1,0,2,0] self.assertEqual(hand.calc_shanten(h), 1) h.main_hand = [0,3,1,1,1,1,1,1,1,3, 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] self.assertEqual(hand.calc_shanten(h), 0) h.main_hand = [0,3,0,0,3,0,3,0,0,0, 0,0,0,0,0,0,3,0,0,0, 0,0,0,1,0,0,0,0,0,0, 0,0,0,0,0,0,0] self.assertEqual(hand.calc_shanten(h), 0) # pong h2 = hand.Hand(0) h2.main_hand = [0,3,0,0,3,0,3,0,0,0, 0,0,0,0,0,0,2,0,0,0, 0,0,0,1,0,0,0,0,0,0, 0,0,0,0,0,0,0] h2.claim([16,16], 16, 1) self.assertEqual(hand.calc_shanten(h2), 0) # daiminkan h2.claim([1,1,1], 1, 2) self.assertEqual(hand.calc_shanten(h2), 0) # chow h2 = hand.Hand(0) h2.main_hand = [0,3,0,0,3,0,3,0,0,0, 0,0,0,0,0,0,1,0,0,0, 0,0,0,1,1,0,0,0,0,0, 0,0,0,0,0,0,0] h2.claim([23,24], 25, 1) self.assertEqual(hand.calc_shanten(h2), 0) h2.main_hand[16] = 2 self.assertEqual(hand.calc_shanten(h2), -1)
def test_add(self): h = hand.Hand(0) h.add(1) self.assertEqual(h.main_hand[1], 1) h.add(1) self.assertEqual(h.main_hand[1], 2)