示例#1
0
    def test_enumerate_options_bankrupt(self):
        # simulate having only one die left and rolling a 3
        s = State(2)
        s.rolled_dice = [Dice(3)]
        s.can_roll = 0

        assert s.enumerate_options() == []
示例#2
0
 def test_enumerate_finds_straight(self):
     s = State(2)
     s.can_roll
     s.rolled_dice = [Dice(i) for i in range(1, 7)]
     actions = s.enumerate_options()
     want = Action({i: 1 for i in range(1, 7)}, "1-2-3-4-5-6", 3000)
     assert want in actions
示例#3
0
    def test_enumerate_finds_three_pairs(self):
        s = State(2)
        s.rolled_dice = [Dice(2), Dice(2), Dice(3), Dice(3), Dice(4), Dice(4)]
        s.can_roll = 0
        actions = s.enumerate_options()

        want = [Action({2: 2, 3: 2, 4: 2}, "Three pairs", 1500)]
        assert len(actions) == len(want)
        assert all(a in want for a in actions)
示例#4
0
    def test_enumerate_finds_three_singles(self):
        s = State(2)
        s.can_rol = 0

        for num in range(1, 7):
            other = 2 if num != 2 else 3
            s.rolled_dice = [Dice(num)] * 3 + [Dice(other)] * 3
            actions = s.enumerate_options()
            points = 1000 if num == 1 else num * 100
            want = Action({num: 3}, f"Three {num}'s", points)
            assert want in actions
示例#5
0
 def test_enumerate_finds_four_five_six_kind(self):
     s = State(2)
     s.can_roll = 0
     for num in range(1, 7):
         for n in range(4, 7):
             other = 2 if num != 2 else 3
             s.rolled_dice = [Dice(num)] * n + [Dice(other)] * (6 - n)
             actions = s.enumerate_options()
             name = {4: "Four", 5: "Five", 6: "Six"}[n]
             points = {4: 1000, 5: 2000, 6: 3000}[n]
             want = Action({num: n}, f"{name} {num}'s", points)
             assert want in actions
示例#6
0
def two_player_played_all():
    s = State(2)
    s.can_roll = 6
    s.rolled_dice = []
    s.turn_sum = 400
    return s
示例#7
0
def two_player_state():
    s = State(2)
    s.turn_sum = 200
    s.can_roll = 2
    s.rolled_dice = [Dice(5)] * 4
    return s
示例#8
0
def two_player_can_score_all():
    s = State(2)
    s.can_roll = 5
    s.rolled_dice = [Dice(1)]
    s.turn_sum = 300
    return s
示例#9
0
def two_player_scored_1_5_5():
    s = State(2)
    s.can_roll = 3
    s.rolled_dice = [Dice(i) for i in range(2, 5)]
    s.turn_sum = 200
    return s
示例#10
0
def two_player_scored_1():
    s = State(2)
    s.can_roll = 5
    s.rolled_dice = [Dice(i) for i in range(2, 6)] + [Dice(5)]
    s.turn_sum = 100
    return s
示例#11
0
def two_player_just_rolled():
    s = State(2)
    s.turn_sum = 0
    s.can_roll = 0
    s.rolled_dice = [Dice(i) for i in range(1, 6)] + [Dice(5)]
    return s