Пример #1
0
def detail_advance(board_width, board_height, hives, flowers, inflight,
                   turn_num, cmd):
    board = Board(game_params=DEFAULT_GAME_PARAMETERS,
                  board_width=board_width,
                  board_height=board_height,
                  hives=[Hive(*i) for i in hives],
                  flowers=[Flower.from_json(i) for i in flowers],
                  neighbours={
                      'N': 1,
                      'S': 1,
                      'E': 1,
                      'W': 1,
                      'NW': 1,
                      'SE': 1,
                  },
                  inflight={
                      volant_id: volant_from_json(volant)
                      for volant_id, volant in inflight.items()
                  },
                  dead_bees=0)

    board._connect_to_neighbours([board, _OtherBoard()])
    board.apply_command(cmd, turn_num)
    board.remove_dead_flowers(turn_num)
    board.move_volants()
    lost = set(board.send_volants())
    received = set(board.receive_volants())
    board.visit_flowers(Random())
    landed = set(board.land_bees())
    crashed = {k: set(v) for k, v in board.detect_crashes().items()}

    return board.hives, board.flowers, board.inflight, crashed, landed, lost, received
Пример #2
0
def apply_command_and_advance(board_width, board_height, hives, flowers, inflight, turn_num, cmd):
    """
    You can use this function to try out a potential move and test what happens.

    Parameters
    ----------
    board_width: int
        The number of tiles in each row of the board
    board_height: int
        The number of tiles in each column of the board
    hives: tuple[`Hive`+]
        Hives present on player's board
    flowers: tuple[`Flower`+]
        Flowers present on player's board
    inflight: dict [str, `Volant`]
        A dictionary of volant identifiers to volant
    turn_num: int
        The number of the current turn
        
        
    Returns
    -------
    crashed: dict [str, set[str]]
        A dictionary of causes to Volant identifiers which have been removed
    landed: set[`str`]
        A set of Bee identifiers which have landed back on a hive and are no longer active on the board
    lost: set[`str`]
        A set of Volant identifiers which have moved over the boundary into a neighbouring board
    """
    board = Board(game_params=DEFAULT_GAME_PARAMETERS,
                  board_width=board_width,
                  board_height=board_height,
                  hives=[Hive(*i) for i in hives],
                  flowers=[Flower.from_json(i) for i in flowers],
                  neighbours={'N':1, 'S':1, 'E':1, 'W':1, 'NW':1, 'SE':1, },
                  inflight={volant_id: volant_from_json(volant) for volant_id, volant in inflight.items()},
                  dead_bees=0)
    
    board._connect_to_neighbours([board, _OtherBoard()])
    board.apply_command(cmd, turn_num)
    board.remove_dead_flowers(turn_num)
    board.move_volants()
    lost = set(board.send_volants())
    board.visit_flowers(Random())
    landed = set(board.land_bees())
    crashed = {k: set(v) for k, v in board.detect_crashes().items()}
    
    return crashed, landed, lost
Пример #3
0
def test_can_convert_flower_to_from_json(flower_type):
    flower = flower_type(sentinel.x, sentinel.y, DEFAULT_GAME_PARAMETERS, sentinel.potency, sentinel.visits, sentinel.expires)
    bounce_flower = Flower.from_json(flower.to_json())
    assert flower == bounce_flower