def fixwp_example8(): #Figure 3.2.7 g = io.load_from_file("assets/strong parity/example_8.txt") (w0, w1) = fixwp.partial_solver( g, 10 ) #no solutions with any lambda because the winner is player 0 but player 1 can manage to loop to prevent window from closing return ops.are_lists_equal(w0, []) and ops.are_lists_equal(w1, [])
def worstcase1(): """ Solves a worst case graph G_n for n = 1. """ g = io.load_generalized_from_file("assets/strong parity/worstcase_1.txt") (a, c) = gp.generalized_parity_solver(g) return op.are_lists_equal(a, [1, 3, 4, 2, 0]) and op.are_lists_equal(c, [])
def example_2_antichain_algorithm(): """ Solves a simple example. """ g = io.load_from_file("assets/strong parity/example_2.txt") (a, c) = sp.strong_parity_antichain_based(g, 1) return ops.are_lists_equal(a, [1, 3, 4, 2]) and ops.are_lists_equal(c, [])
def example_2_reduction_to_safety(): """ Solves a simple example. """ g = io.load_from_file("assets/strong parity/example_2.txt") (a, c) = sp.reduction_to_safety_parity_solver(g) return ops.are_lists_equal(a, [1, 3, 4, 2]) and ops.are_lists_equal(c, [])
def example_2(): """ Solves a simple example. """ g = io.load_generalized_from_file("assets/strong parity/example_2.txt") (a, c) = gp.generalized_parity_solver(g) return op.are_lists_equal(a, [1, 3, 4, 2]) and op.are_lists_equal(c, [])
def dirfixwp_example3(): g = io.load_from_file("assets/strong parity/example_3.txt") (w0, w1) = dirfixwp.partial_solver(g, 1) #partial solve with lambda = 1 (w0_2, w1_2) = dirfixwp.partial_solver(g, 2) #full solve with lambda >= 2 return ops.are_lists_equal(w0, [1, 2, 4]) and ops.are_lists_equal( w1, [5, 6, 7]) and ops.are_lists_equal( w0_2, [1, 2, 3, 4]) and ops.are_lists_equal(w1_2, [5, 6, 7])
def simple_example2(): """ Solves a graph which is a simple example for the algorithm. """ g = io.load_generalized_from_file( "assets/generalized parity/simple_example2.txt") (a, c) = gp.generalized_parity_solver(g) return op.are_lists_equal(a, [1, 2]) and op.are_lists_equal(c, [3, 4, 5])
def figure56(): """ Solves the strong parity game from figure 5.6. """ g = io.load_generalized_from_file("assets/strong parity/figure56.txt") (a, c) = gp.generalized_parity_solver(g) return op.are_lists_equal(a, [2, 4, 1, 6]) and op.are_lists_equal( c, [5, 3])
def worstcase2_reduction_to_safety(): """ Solves a worst case graph G_n for n = 2. """ g = io.load_from_file("assets/strong parity/worstcase_2.txt") (a, c) = sp.reduction_to_safety_parity_solver(g) return ops.are_lists_equal(a, []) and ops.are_lists_equal( c, [6, 8, 9, 7, 5, 4, 0, 2, 1, 3])
def worstcase1_reduction_to_safety(): """ Solves a worst case graph G_n for n = 1. """ g = io.load_from_file("assets/strong parity/worstcase_1.txt") (a, c) = sp.reduction_to_safety_parity_solver(g) return ops.are_lists_equal(a, [1, 3, 4, 2, 0]) and ops.are_lists_equal( c, [])
def figure56_reduction_to_safety(): """ Solves the strong parity game from figure 5.6. """ fig56_graph = io.load_from_file("assets/strong parity/figure56.txt") (a, c) = sp.reduction_to_safety_parity_solver(fig56_graph) return ops.are_lists_equal(a, [2, 4, 1, 6]) and ops.are_lists_equal( c, [5, 3])
def worstcase2_antichain_algorithm(): """ Solves a worst case graph G_n for n = 2. """ g = io.load_from_file("assets/strong parity/worstcase_2.txt") (a, c) = sp.strong_parity_antichain_based(g, 0) return ops.are_lists_equal(a, []) and ops.are_lists_equal( c, [6, 8, 9, 7, 5, 4, 0, 2, 1, 3])
def worstcase1_antichain_algorithm(): """ Solves a worst case graph G_n for n = 1. """ g = io.load_from_file("assets/strong parity/worstcase_1.txt") (a, c) = sp.strong_parity_antichain_based(g, 0) return ops.are_lists_equal(a, [1, 3, 4, 2, 0]) and ops.are_lists_equal( c, [])
def example_2_doubled(): """ Solves a simple example. """ g = gen.multiple_priorities( io.load_generalized_from_file("assets/strong parity/example_2.txt"), 2) (a, c) = gp.generalized_parity_solver(g) return op.are_lists_equal(a, [1, 3, 4, 2]) and op.are_lists_equal(c, [])
def dirfixwp_example5(): g = io.load_from_file("assets/strong parity/example_5.txt") (w0, w1) = dirfixwp.partial_solver(g, 1) #partial solve with lambda = 1 (w0_2, w1_2) = dirfixwp.partial_solver( g, 100) #not able to solve more even with a greater lambda return ops.are_lists_equal(w0, [1, 2, 5]) and ops.are_lists_equal( w1, [3, 6]) and ops.are_lists_equal( w0_2, [1, 2, 5]) and ops.are_lists_equal(w1_2, [3, 6])
def worstcase2(): """ Solves a worst case graph G_n for n = 2. """ g = io.load_generalized_from_file("assets/strong parity/worstcase_2.txt") (a, c) = gp.generalized_parity_solver(g) return op.are_lists_equal(a, []) and op.are_lists_equal( c, [6, 8, 9, 7, 5, 4, 0, 2, 1, 3])
def example_1_opposite(): """ Solves a simple example. """ g = gen.opposite_priorities( io.load_generalized_from_file("assets/strong parity/example_1.txt")) (a, c) = gp.generalized_parity_solver(g) return op.are_lists_equal(a, []) and op.are_lists_equal(c, [1, 3, 2])
def figure56_antichain_algorithm(): """ Solves the strong parity game from figure 5.6. """ fig56_graph = io.load_from_file("assets/strong parity/figure56.txt") (a, c) = sp.strong_parity_antichain_based(fig56_graph, 1) return ops.are_lists_equal(a, [2, 4, 1, 6]) and ops.are_lists_equal( c, [5, 3])
def double_priority(): """ Solves a graph in which the priorities are twice the same. """ g = io.load_generalized_from_file( "assets/generalized parity/double_priority.txt") (a, c) = gp.generalized_parity_solver(g) return op.are_lists_equal(a, []) and op.are_lists_equal( c, [4, 5, 6, 7, 3, 1, 2])
def figure56_opposite(): """ Solves the strong parity game from figure 5.6. """ g = gen.opposite_priorities( io.load_generalized_from_file("assets/strong parity/figure56.txt")) (a, c) = gp.generalized_parity_solver(g) return op.are_lists_equal(a, []) and op.are_lists_equal( c, [2, 4, 1, 6, 5, 3])
def worstcase1_doubled(): """ Solves a worst case graph G_n for n = 1. """ g = gen.multiple_priorities( io.load_generalized_from_file("assets/strong parity/worstcase_1.txt"), 2) (a, c) = gp.generalized_parity_solver(g) return op.are_lists_equal(a, [1, 3, 4, 2, 0]) and op.are_lists_equal(c, [])
def figure56_doubled(): """ Solves the strong parity game from figure 5.6. """ g = gen.multiple_priorities( io.load_generalized_from_file("assets/strong parity/figure56.txt"), 2) (a, c) = gp.generalized_parity_solver(g) return op.are_lists_equal(a, [2, 4, 1, 6]) and op.are_lists_equal( c, [5, 3])
def counter_example(): """ Solves a graph which is one of the counter examples for the naive algorithms. Player 1 cannot avoid cycling between nodes in which 3 will appear infinitely often according to one of the priority function. """ g = io.load_generalized_from_file( "assets/generalized parity/counter_example.txt") (a, c) = gp.generalized_parity_solver(g) return op.are_lists_equal(a, []) and op.are_lists_equal(c, [1, 2, 3])
def simple_example(): """ Solves a graph which is a simple example for the algorithm. Player 1 can choose to cycle between two nodes, since center node has priorities (2,2), the path has maximal priority occurring infinitely often 2 for each priority function. """ g = io.load_generalized_from_file( "assets/generalized parity/simple_example.txt") (a, c) = gp.generalized_parity_solver(g) return op.are_lists_equal(a, [1, 2, 3]) and op.are_lists_equal(c, [])
def complementary_priorities(): """ Solves a graph in which the priorities are complementary (one is odd, one is even). This means that player 1 looses from every node (can't have a path even for every priority function) """ g = io.load_generalized_from_file( "assets/generalized parity/complementary_priorities.txt") (a, c) = gp.generalized_parity_solver(g) return op.are_lists_equal(a, []) and op.are_lists_equal( c, [6, 3, 4, 5, 7, 1, 2])
def fixwp_example6(): g = io.load_from_file("assets/strong parity/example_6.txt") (w0, w1) = fixwp.partial_solver(g, 1) #no solutions with lambda = 1 (w0_2, w1_2) = fixwp.partial_solver(g, 2) #no solutions with lambda = 2 (w0_3, w1_3) = fixwp.partial_solver(g, 3) #no solutions with lambda = 3 (w0_4, w1_4) = fixwp.partial_solver(g, 4) #full solve with lambda >= 4 return ops.are_lists_equal(w0, []) and ops.are_lists_equal( w1, []) and ops.are_lists_equal(w0_2, []) and ops.are_lists_equal( w1_2, []) and ops.are_lists_equal(w0_3, []) and ops.are_lists_equal( w1_3, []) and ops.are_lists_equal( w0_4, []) and ops.are_lists_equal(w1_4, [1, 2, 3, 4, 5])
def compute_Bn(g, j): """ Compute the under-approximation of the winning core. For this puropose we compute iteratively each b_i until we have b_n or until we have a convergence in the sequence. :param g: the game to solve. :param j: the player for who we want to compute B_n. :return: the states of B_n in a list. """ #b_0 = S b_i = g.get_nodes() #compute the b_i until having b_n or a convergence for i in range(len(g.get_nodes())): #compute b_i+1 b_i_next = compute_Bi(g, j, b_i) #checking if the sequence converged or not if ops.are_lists_equal(b_i, b_i_next): b_i = b_i_next break else: b_i = b_i_next return b_i
def dirfixwp_example2(): g = io.load_from_file("assets/strong parity/example_2.txt") (w0, w1) = dirfixwp.partial_solver(g, 1) #full solve with lambda >= 1 return ops.are_lists_equal(w0, [1, 2, 3, 4]) and ops.are_lists_equal( w1, [])
def wc_example9(): #Figure 2.2.2 g = io.load_from_file("assets/strong parity/example_9.txt") (w0, w1) = winningcore.partial_solver(g) return ops.are_lists_equal(w0, [1, 2, 3]) and ops.are_lists_equal(w1, [])
def wc_example7(): g = io.load_from_file("assets/strong parity/example_7.txt") (w0, w1) = winningcore.partial_solver(g) return ops.are_lists_equal(w0, []) and ops.are_lists_equal(w1, [1])