예제 #1
0
    def test_accepted_tiles_comparison(self) -> None:

        a = Clue(1, set(["bear", "cougar"]), clue_type="animal")
        b = Clue(1, set(["bear", "cougar"]), clue_type="animal")

        self.assertEqual(a, b, msg="Instances of same clue should evaluate to be equal")

        PLAYER_1 = Player("orange", clues.by_booklet_entry("alpha", 2), teamname="alpha")
        PLAYER_2 = Player("cyan", None, teamname="beta")
        PLAYER_3 = Player("purple", None, teamname="epsilon")

        PLAYERS = [PLAYER_1, PLAYER_2, PLAYER_3]

        game = Game(MAP_DESCRIPTOR, PLAYERS, STRUCTURES)

        _ = b.accepted_tiles(game.map)

        self.assertEqual(a, b, msg="Invoking class methods should not change equality comparison of Clue instance")
예제 #2
0
    def test_accepted_tiles_maintains_hash(self) -> None:

        a = Clue(1, set(["bear", "cougar"]), clue_type="animal")
        b = Clue(1, set(["bear", "cougar"]), clue_type="animal")

        self.assertEqual(hash(a), hash(b), msg="Fresh clues with same parameters should be comparable")

        PLAYER_1 = Player("orange", clues.by_booklet_entry("alpha", 2), teamname="alpha")
        PLAYER_2 = Player("cyan", None, teamname="beta")
        PLAYER_3 = Player("purple", None, teamname="epsilon")

        PLAYERS = [PLAYER_1, PLAYER_2, PLAYER_3]

        game = Game(MAP_DESCRIPTOR, PLAYERS, STRUCTURES)

        _ = b.accepted_tiles(game.map)

        self.assertEqual(hash(a), hash(b), msg="Invoking class methods should not change the hash of a clue")
예제 #3
0
    def test_set_unpacking_order_does_not_change_hash(self) -> None:

        a = set(["bear", "cougar"])
        b = set(["bear", "cougar"])

        tupled_a = (*a, )
        tupled_b = (*b, )

        i = 0

        while (tupled_a != tupled_b):

            b = set(["bear", "cougar"])
            tupled_b = (*b, )

            i += 1

            if i >= 1000:
                self.fail("Did not find sets with different unpacking order")

        clue_a = Clue(1, a, clue_type="animal")
        clue_b = Clue(1, b, clue_type="animal")

        self.assertEqual(hash(clue_a), hash(clue_b), msg="Clue hash should be independent of set-unpacking order")
예제 #4
0
    def test_new_objects_evaluate_same_hash(self) -> None:
        a = Clue(1, set(["bear", "cougar"]), clue_type="animal")
        b = Clue(1, set(["bear", "cougar"]), clue_type="animal")

        self.assertEqual(hash(a), hash(b), msg="Fresh clues with same parameters should be comparable")
예제 #5
0
    def test_set_creation_order_does_not_change_equality(self) -> None:

        a = Clue(1, set(["bear", "cougar"]), clue_type="animal")
        b = Clue(1, set(["cougar", "bear"]), clue_type="animal")

        self.assertEqual(a, b, msg="Order of distance_from set should not change equality")
예제 #6
0
    def test_different_instances_of_same_clues_evaluate_to_be_same(self) -> None:

        a = Clue(1, set(["bear", "cougar"]), clue_type="animal")
        b = Clue(1, set(["bear", "cougar"]), clue_type="animal")

        self.assertEqual(a, b, msg="Instances of same clue should evaluate to be equal")
예제 #7
0
import copy
from cryptidsolver.clue import Clue

# TODO Is there a way to provide new Clue instance on every call

FOREST_OR_DESERT = Clue(0, set(["F", "D"]))
FOREST_OR_WATER = Clue(0, set(["F", "W"]))
FOREST_OR_SWAMP = Clue(0, set(["F", "S"]))
FOREST_OR_MOUNTAIN = Clue(0, set(["F", "M"]))
DESERT_OR_WATER = Clue(0, set(["D", "W"]))
DESERT_OR_SWAMP = Clue(0, set(["D", "S"]))
DESERT_OR_MOUNTAIN = Clue(0, set(["D", "M"]))
WATER_OR_SWAMP = Clue(0, set(["W", "S"]))
WATER_OR_MOUNTAIN = Clue(0, set(["W", "M"]))
SWAMP_OR_MOUNTAIN = Clue(0, set(["S", "M"]))

ONE_FROM_FOREST = Clue(1, set(["F"]))
ONE_FROM_DESERT = Clue(1, set(["D"]))
ONE_FROM_SWAMP = Clue(1, set(["S"]))
ONE_FROM_MOUNTAIN = Clue(1, set(["M"]))
ONE_FROM_WATER = Clue(1, set(["W"]))
ONE_FROM_ANIMAL = Clue(1, set(["cougar", "bear"]), clue_type="animal")

TWO_FROM_STANDING_STONE = Clue(2, set(["stone"]), clue_type="structure")
TWO_FROM_ABANDONED_SHACK = Clue(2, set(["shack"]), clue_type="structure")
TWO_FROM_COUGAR = Clue(2, set(["cougar"]), clue_type="animal")
TWO_FROM_BEAR = Clue(2, set(["bear"]), clue_type="animal")

THREE_FROM_BLUE = Clue(3, set(["blue"]), clue_type="structure")
THREE_FROM_WHITE = Clue(3, set(["white"]), clue_type="structure")
THREE_FROM_GREEN = Clue(3, set(["green"]), clue_type="structure")