Пример #1
0
def test_capture_in_top_right():
    board = SpargoState("""\
  A C E G
7 . . B W 7

5 . . . . 5

3 . . . . 3

1 . . . . 1
  A C E G
>B
""")
    expected_board = """\
  A C E G
7 . . B . 7

5 . . . B 5

3 . . . . 3

1 . . . . 1
  A C E G
>W
"""

    board2 = board.make_move(11)

    assert board2.display() == expected_board
Пример #2
0
def test_connected_to_freedom():
    board = SpargoState("""\
  A C E G
7 . . . . 7

5 . . . . 5

3 . . . . 3

1 B B . . 1
  A C E G
>W
""")
    expected_board = """\
  A C E G
7 . . . . 7

5 . . . . 5

3 W . . . 3

1 B B . . 1
  A C E G
>B
"""

    board2 = board.make_move(4)

    assert board2.display() == expected_board
Пример #3
0
def test_ko_rule():
    text1 = """\
  A C E G
7 . . . . 7

5 . . . . 5

3 . W B . 3

1 W B . B 1
  A C E G
>W
"""
    text2 = """\
  A C E G
7 . . . . 7

5 . . . . 5

3 . W B . 3

1 W . W B 1
  A C E G
>B
"""

    board1 = SpargoState(text1)
    board2 = board1.make_move(2)

    display = board2.display(show_coordinates=True)
    valid_moves = board2.get_valid_moves()

    assert display == text2
    assert not valid_moves[1]
Пример #4
0
def test_capture():
    board = SpargoState("""\
  A C E G
7 . . . . 7

5 . . . . 5

3 . . . . 3

1 W B . . 1
  A C E G
>B
""")
    expected_board = """\
  A C E G
7 . . . . 7

5 . . . . 5

3 B . . . 3

1 . B . . 1
  A C E G
>W
"""

    board2 = board.make_move(4)

    assert board2.display() == expected_board
Пример #5
0
def test_capture_group():
    board = SpargoState("""\
  A C E G
7 . . . . 7

5 . . . . 5

3 . W . . 3

1 B B W . 1
  A C E G
>W
""")
    expected_board = """\
  A C E G
7 . . . . 7

5 . . . . 5

3 W W . . 3

1 . . W . 1
  A C E G
>B
"""

    board2 = board.make_move(4)

    assert board2.display() == expected_board
Пример #6
0
def test_overpass_at_edge():
    """ The edge should not contribute to overpasses.

    Playing white at 3G should not capture black, because it has a freedom at
    1A. The white at 2D doesn't cut it off, because it's only one side of an
    overpass.
    """
    start_state = SpargoState("""\
  A C E G
7 . . . . 7

5 . . . . 5

3 . W W . 3

1 . B B B 1
  A C E G
   B D F
 6 . . . 6

 4 . . . 4

 2 . W . 2
   B D F
>W
""")
    expected_display = """\
  A C E G
7 . . . . 7

5 . . . . 5

3 . W W W 3

1 . B B B 1
  A C E G
   B D F
 6 . . . 6

 4 . . . 4

 2 . W . 2
   B D F
>B
"""

    new_state = start_state.make_move(7)

    display = new_state.display(show_coordinates=True)

    assert display == expected_display
Пример #7
0
def test_overpass():
    """ Overpass should cut underpass.

    Playing black at 5G should capture 3G and 1G, because the black overpass
    cuts off their connection to 3C. 3C and 3E survive as zombies, because they
    are supporting pieces on level 2.
    """
    start_state = SpargoState("""\
  A C E G
7 . . . . 7

5 . B B . 5

3 . W W W 3

1 . B B W 1
  A C E G
   B D F
 6 . . . 6

 4 . B . 4

 2 . B . 2
   B D F
>B
""")
    expected_display = """\
  A C E G
7 . . . . 7

5 . B B B 5

3 . W W . 3

1 . B B . 1
  A C E G
   B D F
 6 . . . 6

 4 . B . 4

 2 . B . 2
   B D F
>W
"""

    new_state = start_state.make_move(11)

    display = new_state.display(show_coordinates=True)

    assert display == expected_display
Пример #8
0
def test_covered_piece_not_connected():
    start_state = SpargoState("""\
  A C E G
7 . W . . 7

5 B W B . 5

3 B W B B 3

1 B W W W 1
  A C E G
   B D F
 6 . . . 6

 4 W B . 4

 2 B W . 2
   B D F
>B
""")
    expected_display = """\
  A C E G
7 . W . . 7

5 B W B . 5

3 B W B B 3

1 B W W . 1
  A C E G
   B D F
 6 . . . 6

 4 W B . 4

 2 B W . 2
   B D F
    C E
  5 . . 5

  3 B . 3
    C E
>W
"""

    new_state = start_state.make_move(25)

    display = new_state.display(show_coordinates=True)

    assert display == expected_display
Пример #9
0
def test_count_new_piece_in_overpass():
    start_state = SpargoState("""\
  A C E G
7 . B W . 7

5 . B W W 5

3 B B B W 3

1 . W B B 1
  A C E G
   B D F
 6 . . . 6

 4 . W . 4

 2 . . . 2
   B D F
>W
""")
    expected_display = """\
  A C E G
7 . B W . 7

5 . B W W 5

3 B B B W 3

1 . W B . 1
  A C E G
   B D F
 6 . . . 6

 4 . W . 4

 2 . W . 2
   B D F
>B
"""

    new_state = start_state.make_move(17)

    display = new_state.display(show_coordinates=True)

    assert display == expected_display
Пример #10
0
def test_zombie():
    board = SpargoState("""\
  A C E G
7 . . . . 7

5 . . . . 5

3 . W W . 3

1 B B W . 1
  A C E G
   B D F
 6 . . . 6

 4 . . . 4

 2 . W . 2
   B D F
>W
""")
    expected_board = """\
  A C E G
7 . . . . 7

5 . . . . 5

3 W W W . 3

1 . B W . 1
  A C E G
   B D F
 6 . . . 6

 4 . . . 4

 2 . W . 2
   B D F
>B
"""

    board2 = board.make_move(4)

    assert board2.display() == expected_board
Пример #11
0
def test_climb_to_freedom():
    board = SpargoState("""\
  A C E G
7 . . . . 7

5 . . . . 5

3 . W B . 3

1 B B W . 1
  A C E G
   B D F
 6 . . . 6

 4 . . . 4

 2 . B . 2
   B D F
>W
""")
    expected_board = """\
  A C E G
7 . . . . 7

5 . . . . 5

3 W W B . 3

1 B B W . 1
  A C E G
   B D F
 6 . . . 6

 4 . . . 4

 2 . B . 2
   B D F
>B
"""

    board2 = board.make_move(4)

    assert board2.display() == expected_board