Пример #1
0
class TestAcceptsCube(unittest.TestCase):
    def setUp(self) -> None:
        # Redefine for every test as state persists otherwise
        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]

        self.game = Game(MAP_DESCRIPTOR, PLAYERS, STRUCTURES)

    def test_rejects_when_cube_present(self) -> None:

        self.game.place_cube(1, 1)

        self.assertFalse(
            self.game.accepts_cube(1, 1),
            msg="Cubes cannot be placed on tiles with other cubes")

    def test_accepts_when_no_cube_present(self) -> None:

        self.assertTrue(self.game.accepts_cube(1, 1),
                        msg="Cubes can be placed on tiles with other cubes")
Пример #2
0
                    print(player.clue)
                else:
                    for clue in player.possible_clues(game.map):
                        print(clue)

                print("")

        elif cmd == "infer cube placement":

            player = game.current_player()
            before_placement = player.possible_clues(game.map)

            placement_alternatives = {}

            for tile in game.map:
                if game.accepts_cube(tile.x, tile.y):

                    # Does not account for impossible clues - that is cannot produce clue-combination
                    # that singles out a tile.

                    clues_after_placement = infer.possible_clues_after_cube_placement(
                        game.map, player, (tile.x, tile.y))

                    placement_reduces_clues = len(
                        before_placement.difference(clues_after_placement))
                    placement_alternatives[tile] = placement_reduces_clues

            minimum_reveal = sorted(placement_alternatives.items(),
                                    key=lambda x: x[1])[0]

            print("Place cube on x:{} y:{} to reduce {} clues".format(