예제 #1
0
def render_results(inputs):
    """
    Performs placements and returns their results.
    """
    placements = [PlacementFactory.create(x) for x in inputs]

    players = []
    for i, placement in enumerate(placements):
        p = Player(name=str(i))
        p.color = placement.color
        players.append(p)

    ref = Referee(players)

    ref.add_placements(placements)

    return observer.render_board(ref.board, ref.players)
예제 #2
0
def render_intermediate(inputs, requested):
    placements = [PlacementFactory.create(x) for x in inputs + [requested[0]]]

    players = []
    for i, placement in enumerate(placements):
        p = Player(name=str(i))
        p.color = placement.color
        players.append(p)

    ref = Referee(players)
    ref.add_placements(placements[:-1])
    next_move = placements[-1]
    ref.players_by_color[next_move.color].tile_hand = [
        Tile.Builder.build(i).readonly() for i in requested[1:]
    ]
    ref.players_by_color[next_move.color].strategy = Predetermined(next_move)
    ref.turn_index = ref.turn_order.index(
        ref.players_by_color[next_move.color])

    return observer.render_board(ref.board, ref.players, ref.turn)