def Demo2(n_fish_per_tile=1) -> FishGameController: """ Randomly Generated Holes with 1 Fish on all tiles... :return: A controller to be execute in main. """ hexgrid = HexGridView() board = FishBoard(num_rows=HEXES_ROWS, num_cols=HEXES_COLUMNS) for row in range(board.num_rows): for col in range(board.num_cols): if board.retrieve_num_fish( row=row, col=col) == 0 and board.is_tile(row=row, col=col): for i in range(n_fish_per_tile): board = board.add_fish(row=row, col=col) player_1 = Player("red", 0, 0, []) state = FishGameState(board=board, num_players=1, players=[player_1], current_player=player_1) behavior = FishGameBehavior(state=state, view=hexgrid) controller = FishGameController(behavior=behavior, view=hexgrid, state=state) return controller
def Demo3(holes: List[Coordinate]) -> FishGameController: """ Given the list of holes, render a board with holes at those cooridates and 1 fish at every non-hole tile. :param holes: List of hole Coordinates :return: A controller to be execute in main. """ hexgrid = HexGridView() board = FishBoard(num_rows=HEXES_ROWS, num_cols=HEXES_COLUMNS) for hole in holes: board = board.create_hole(row=hole.row, col=hole.col) for row in range(board.num_rows): for col in range(board.num_cols): if board.retrieve_num_fish( row=row, col=col) == 0 and board.is_tile(row=row, col=col): board = board.add_fish(row=row, col=col) player_1 = Player("red", 0, 0, []) state = FishGameState(board=board, num_players=1, players=[player_1], current_player=player_1) behavior = FishGameBehavior(state=state, view=hexgrid) controller = FishGameController(behavior=behavior, view=hexgrid, state=state) return controller
def RandomlyGenerateHole(board: FishBoard, total_num_hole=2): for _ in range(total_num_hole): not_added = True while not_added: random_row = randint(0, HEXES_ROWS - 1) random_col = randint(0, HEXES_COLUMNS - 1) if board.retrieve_num_fish(random_row, random_col) == 0 and board.is_tile( random_row, random_col): board = board.create_hole(random_row, random_col) not_added = False return board
def RandomlyGenerateFish(board: FishBoard, total_num_fish=10): for _ in range(total_num_fish): not_added = True while not_added: random_row = randint(0, HEXES_ROWS - 1) random_col = randint(0, HEXES_COLUMNS - 1) if board.retrieve_num_fish( random_row, random_col) < MAX_NUM_FISH and board.is_tile( random_row, random_col): board = board.add_fish(row=random_row, col=random_col) not_added = False return board