コード例 #1
0
def test_no_valid_moves():
    state = SploofState("""\
  A C E G
7 W . W . 7

5 . W B W 5

3 W B W . 3

1 . W . W 1
  A C E G
>W(0,18)
""")

    assert state.get_winner() == state.BLACK
コード例 #2
0
def test_empty_stock(start: int, end: int, expected_valid: bool, reason: str):
    board = SploofState("""\
  A C E G
7 R R . . 7

5 R . . R 5

3 R W W R 3

1 R R R R 1
  A C E G
>W(0,6)
""")
    valid_moves = board.get_valid_moves()
    for move in range(start, end):
        assert valid_moves[move] == expected_valid, move
コード例 #3
0
    def __init__(self):
        display = SploofDisplay()
        display.update_board(
            SploofState('''\
  A C E G
7 B B W W 7

5 R W W W 5

3 W B W R 3

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

 4 B W W 4

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

  3 W . 3
    C E
>W(1,2)
'''))
        display.resize(300, 224)
        super().__init__(display)
コード例 #4
0
def test_add_move():
    state1 = SploofState("""\
  A C E G
7 R R R R 7

5 . . . . 5

3 R W B R 3

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

 4 . . . 4

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

5 W . . . 5

3 R W B R 3

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

 4 . . . 4

 2 W B . 2
   B D F
>B(2,1)
"""
    state2 = state1.make_move(8)

    display = state2.display()
    active_player = state2.get_active_player()

    assert display == expected_display
    assert active_player == state2.BLACK
コード例 #5
0
def test_start():
    expected_display = """\
  A C E G
7 R R R R 7

5 R . . R 5

3 R . . R 3

1 R R R R 1
  A C E G
>W(2,2)
"""
    # Shows size of player's stock, followed by opponent's stock.
    state = SploofState()

    display = state.display()
    active_player = state.get_active_player()

    assert display == expected_display
    assert active_player == state.WHITE
コード例 #6
0
def test_diagonal_win():
    state = SploofState("""\
  A C E G
7 R R R . 7

5 R B B R 5

3 R B W R 3

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

 4 . W . 4

 2 . . W 2
   B D F
>B(1,0)
""")

    assert state.get_winner() == state.WHITE
コード例 #7
0
def test_cutoff_column():
    state = SploofState("""\
  A C E G
7 R R W R 7

5 R . W R 5

3 R B W R 3

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

 4 . . . 4

 2 . B B 2
   B D F
>B(1,0)
""")

    assert state.get_winner() == state.NO_PLAYER
コード例 #8
0
def test_cutoff_row():
    state = SploofState("""\
  A C E G
7 R R R R 7

5 R . B R 5

3 W W W W 3

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

 4 . . B 4

 2 . . B 2
   B D F
>B(1,0)
""")

    assert state.get_winner() == state.NO_PLAYER
コード例 #9
0
def test_base_column():
    state = SploofState("""\
  A C E G
7 R R W R 7

5 R B W R 5

3 R B W R 3

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

 4 B . . 4

 2 . . . 2
   B D F
>B(1,0)
""")

    assert state.get_winner() == state.WHITE
コード例 #10
0
def test_base_row():
    state = SploofState("""\
  A C E G
7 R R R R 7

5 R B B R 5

3 W W W W 3

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

 4 . . . 4

 2 . . . 2
   B D F
>B(1,0)
""")

    assert state.get_winner() == state.WHITE
コード例 #11
0
def test_valid_moves(start: int, end: int, expected_valid: bool, reason: str):
    board = SploofState("""\
  A C E G
7 R R R R 7

5 . . . . 5

3 R W B R 3

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

 4 . . . 4

 2 W B . 2
   B D F
>W(2,2)
""")
    valid_moves = board.get_valid_moves()
    for move in range(start, end):
        assert valid_moves[move] == expected_valid, move
コード例 #12
0
def test_piece_count():
    state = SploofState("""\
  A C E G
7 R R R R 7

5 . . . . 5

3 R W B R 3

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

 4 . . . 4

 2 W B . 2
   B D F
>W(4,3)
""")

    assert state.get_piece_count(state.WHITE) == 4
    assert state.get_piece_count(state.BLACK) == 3
コード例 #13
0
def test_let_opponent_win():
    state1 = SploofState("""\
  A C E G
7 . . W W 7

5 . . W W 5

3 . . W W 3

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

 4 . . . 4

 2 . . W 2
   B D F
>B(16,0)
""")

    state2 = state1.make_move(32)

    assert state2.get_winner() == state2.WHITE
コード例 #14
0
def test_get_index():
    state = SploofState("""\
  A C E G
7 R R R R 7

5 . . . . 5

3 R W B R 3

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

 4 . . . 4

 2 W B . 2
   B D F
>W(2,2)
""")

    move = state.get_index(height=0, row=0, column=0, move_type=state.RED)

    assert move == 30
コード例 #15
0
    def __init__(self):
        display = SploofDisplay()
        display.update_board(
            SploofState('''\
  A C E G
7 . R R R 7

5 . B B R 5

3 W W W W 3

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

 4 . . W 4

 2 . . B 2
   B D F
>W(1,2)
'''))
        display.resize(300, 224)
        super().__init__(display)
コード例 #16
0
ファイル: display.py プロジェクト: donkirkby/shibumi-games
 def __init__(self):
     super().__init__(SploofState())
     self.visible_counts = (self.start_state.WHITE, self.start_state.BLACK)
コード例 #17
0
def test_display_move():
    state = SploofState()

    move_display = state.display_move(30)

    assert move_display == 'R1A'
コード例 #18
0
 def __init__(self):
     display = SploofDisplay()
     display.update_board(SploofState())
     display.resize(300, 224)
     super().__init__(display)