def test_blocked_split_slide(board): b = qb.CirqBoard(u.squares_to_bitboard(['d1', 'g1'])) assert b.perform_moves( 'g1^e2h3:SPLIT_JUMP:BASIC', 'd1^b3g4:SPLIT_SLIDE:BASIC', ) test_utils.assert_sample_distribution( b, { u.squares_to_bitboard(['e2', 'b3']): 1 / 2, u.squares_to_bitboard(['h3', 'b3']): 1 / 4, u.squares_to_bitboard(['h3', 'g4']): 1 / 4, })
def test_split_and_use_same_square(board): b = board.with_state(u.squares_to_bitboard(['a1'])) assert b.perform_moves( 'a1a2b1:SPLIT_JUMP:BASIC', 'b1b2:JUMP:BASIC', 'b2a2:JUMP:BASIC', ) probs = b.get_probability_distribution(5000) assert_sample_distribution(b, { u.squares_to_bitboard(['a2']): 1 / 2, u.squares_to_bitboard(['b2']): 1 / 2 })
def test_overlapping_splits(board): b = board(u.squares_to_bitboard(['e1', 'g1'])) assert b.perform_moves( 'e1^d3f3:SPLIT_JUMP:BASIC', 'g1^h3f3:SPLIT_JUMP:BASIC', ) assert_sample_distribution( b, { u.squares_to_bitboard(['d3', 'f3']): 1 / 4, u.squares_to_bitboard(['d3', 'h3']): 1 / 4, u.squares_to_bitboard(['f3', 'g1']): 1 / 4, u.squares_to_bitboard(['h3', 'g1']): 1 / 4, })
def test_blocked_split_slide_merge2(): b = quantum_board_test.simulator(u.squares_to_bitboard(['d1', 'g1'])) assert b.perform_moves( 'g1^e2h3:SPLIT_JUMP:BASIC', 'd1^b3g4:SPLIT_SLIDE:BASIC', 'g4b3^e6:MERGE_SLIDE:BASIC', ) test_utils.assert_sample_distribution( b, { u.squares_to_bitboard(['e2', 'e6']): 1 / 4, u.squares_to_bitboard(['e2', 'b3']): 1 / 4, u.squares_to_bitboard(['h3', 'e6']): 1 / 2, })
def test_blocked_split_slide(board): b = board(u.squares_to_bitboard(["d1", "g1"])) assert b.perform_moves( "g1^e2h3:SPLIT_JUMP:BASIC", "d1^b3g4:SPLIT_SLIDE:BASIC", ) test_utils.assert_sample_distribution( b, { u.squares_to_bitboard(["e2", "b3"]): 1 / 2, u.squares_to_bitboard(["h3", "b3"]): 1 / 4, u.squares_to_bitboard(["h3", "g4"]): 1 / 4, }, )
def test_overlapping_splits(board): b = board(u.squares_to_bitboard(["e1", "g1"])) assert b.perform_moves( "e1^d3f3:SPLIT_JUMP:BASIC", "g1^h3f3:SPLIT_JUMP:BASIC", ) assert_sample_distribution( b, { u.squares_to_bitboard(["d3", "f3"]): 1 / 4, u.squares_to_bitboard(["d3", "h3"]): 1 / 4, u.squares_to_bitboard(["f3", "g1"]): 1 / 4, u.squares_to_bitboard(["h3", "g1"]): 1 / 4, }, )
def test_split_and_use_same_square(board): b = board(u.squares_to_bitboard(["a1"])) assert b.perform_moves( "a1^a2b1:SPLIT_JUMP:BASIC", "b1b2:JUMP:BASIC", "b2a2:JUMP:BASIC", ) assert_sample_distribution(b, { u.squares_to_bitboard(["a2"]): 1 / 2, u.squares_to_bitboard(["b2"]): 1 / 2 }) board_probs = b.get_board_probability_distribution(5000) assert len(board_probs) == 2 assert_fifty_fifty(board_probs, u.squares_to_bitboard(["a2"])) assert_fifty_fifty(board_probs, u.squares_to_bitboard(["b2"]))
def test_blocked_split_slide_merge2(): b = quantum_board_test.simulator(u.squares_to_bitboard(["d1", "g1"])) assert b.perform_moves( "g1^e2h3:SPLIT_JUMP:BASIC", "d1^b3g4:SPLIT_SLIDE:BASIC", "g4b3^e6:MERGE_SLIDE:BASIC", ) test_utils.assert_sample_distribution( b, { u.squares_to_bitboard(["e2", "e6"]): 1 / 4, u.squares_to_bitboard(["e2", "b3"]): 1 / 4, u.squares_to_bitboard(["h3", "e6"]): 1 / 2, }, )
def test_slide_with_two_path_qubits_coherence(): """Tests that a path ancilla does not mess up split/merge coherence. Position: Qd1, Bf1, Ng1. See https://github.com/quantumlib/ReCirq/issues/193. """ b = simulator(u.squares_to_bitboard(['d1', 'f1', 'g1'])) assert b.perform_moves( 'g1^h3f3:SPLIT_JUMP:BASIC', 'f1^e2b5:SPLIT_SLIDE:BASIC', 'd1h5:SLIDE:BASIC', 'd1h5:SLIDE:BASIC', 'd1h5:SLIDE:BASIC', 'd1h5:SLIDE:BASIC', 'h3f3^g1:MERGE_JUMP:BASIC', ) assert_sample_distribution( b, { u.squares_to_bitboard(['d1', 'b5', 'g1']): 1 / 2, u.squares_to_bitboard(['d1', 'e2', 'g1']): 1 / 2, })