コード例 #1
0
def generate_games_from_subsets(subsets: list):
    yield "0"
    for left, right in product(subsets, repeat=2):
        g = Game()
        # Add all options from the sets to the game
        if left:
            g.left_options.extend(Game(opt) for opt in left)
        if right:
            g.right_options.extend(Game(opt) for opt in right)

        # Yield the canonical form as str
        yield str(g.canonical_form())
コード例 #2
0
def canonical_from_pair(pair: tuple):
    # Split pair in left and right options
    left, right = pair
    g = Game()
    # Add all options from the sets to the game
    if left:
        g.left_options.extend(Game(opt) for opt in left)
    if right:
        g.right_options.extend(Game(opt) for opt in right)

    # Return the canonical form as str
    return str(g.canonical_form())
コード例 #3
0
def compute_combinations(sets):
    yield Game("0")
    # Create the cartesian product to create all combinations
    # of Left and Right option sets.
    for left_set, right_set in product(sets, repeat=2):
        g = Game()
        # Add all options from the sets to the game
        if left_set:
            g.left_options.extend(left_set)
        if right_set:
            g.right_options.extend(right_set)

        # Yield the canonical form
        yield g.canonical_form()