def test_with_action_applied():
    patient = GameState.root(5)
    assert patient.player_to_act() == color_to_player(COLOR_WHITE)
    for _ in patient.with_action_applied(0):
        assert patient.player_to_act() == color_to_player(COLOR_WHITE)
        assert str(patient) == (
'''
  A  B  C  D  E
1  O  .  .  .  .  O
 2  .  .  .  .  .  O
  3  .  .  .  .  .  O
   4  .  .  .  .  .  O
    5  .  .  .  .  .  O
        @  @  @  @  @'''
        )
    assert patient.player_to_act() == color_to_player(COLOR_WHITE)
    assert str(patient) == (
'''
  A  B  C  D  E
1  .  .  .  .  .  O
 2  .  .  .  .  .  O
  3  .  .  .  .  .  O
   4  .  .  .  .  .  O
    5  .  .  .  .  .  O
        @  @  @  @  @'''
        )
Esempio n. 2
0
def test_black_moves_are_not_hidden_from_white():
    patient = GameState.root(5)
    cell = (0, 0)
    patient.place(patient.board.cell_index(*cell), COLORS['black'])
    patient.set_player_to_act(color_to_player(COLORS['black']))
    assert patient.player_to_act() == color_to_player(COLORS['black'])
    assert patient[cell] == COLORS['black']

    patient.set_player_to_act(color_to_player(COLORS['white']))
    assert patient.player_to_act() == color_to_player(COLORS['white'])
    assert patient[cell] == COLORS['black']

    assert str(patient) == ('''
  A  B  C  D  E
1  @  .  .  .  .  O
 2  .  .  .  .  .  O
  3  .  .  .  .  .  O
   4  .  .  .  .  .  O
    5  .  .  .  .  .  O
        @  @  @  @  @''')
def test_black_moves_are_not_hidden_from_white():
    patient = GameState.root(5)
    cell = (0, 0)
    patient.place(patient.board.cell_index(*cell), COLOR_BLACK)
    patient.set_player_to_act(color_to_player(COLOR_BLACK))
    assert patient.player_to_act() == color_to_player(COLOR_BLACK)
    assert patient[cell] == COLOR_BLACK

    patient.set_player_to_act(color_to_player(COLOR_WHITE))
    assert patient.player_to_act() == color_to_player(COLOR_WHITE)
    assert patient[cell] == COLOR_BLACK

    assert str(patient) == (
'''
  A  B  C  D  E
1  @  .  .  .  .  O
 2  .  .  .  .  .  O
  3  .  .  .  .  .  O
   4  .  .  .  .  .  O
    5  .  .  .  .  .  O
        @  @  @  @  @'''
    )
def test_white_moves_are_not_hidden_from_black():
    patient = GameState.root(5)
    cell = (0, 0)
    patient.place(patient.board.cell_index(*cell), COLOR_WHITE)
    patient.set_player_to_act(color_to_player(COLOR_WHITE))
    assert patient.player_to_act() == color_to_player(COLOR_WHITE)
    assert patient[cell] == COLOR_WHITE

    patient.set_player_to_act(color_to_player(COLOR_BLACK))
    assert patient.player_to_act() == color_to_player(COLOR_BLACK)
    assert patient[cell] == COLOR_WHITE

    assert str(patient) == (
'''
  A  B  C  D  E
1  O  .  .  .  .  O
 2  .  .  .  .  .  O
  3  .  .  .  .  .  O
   4  .  .  .  .  .  O
    5  .  .  .  .  .  O
        @  @  @  @  @'''
    )
Esempio n. 5
0
def test_terminal_black():
    patient = GameState.root(5)
    assert patient.winner() == COLORS['none']
    patient.place(patient.board.cell_index(0, 0), COLORS['black'])
    assert patient.winner() == COLORS['none']
    patient.place(patient.board.cell_index(1, 0), COLORS['black'])
    assert patient.winner() == COLORS['none']
    patient.place(patient.board.cell_index(2, 0), COLORS['black'])
    assert patient.winner() == COLORS['none']
    patient.place(patient.board.cell_index(3, 0), COLORS['black'])
    assert patient.winner() == COLORS['none']
    patient.place(patient.board.cell_index(4, 0), COLORS['black'])
    assert patient.winner() == COLORS['black']

    patient.set_player_to_act(color_to_player(COLORS['white']))
    patient.undo()
    assert patient.winner() == COLORS['none']
def test_terminal_black():
    patient = GameState.root(5)
    assert patient.winner() == COLOR_NONE
    patient.place(patient.board.cell_index(0, 0), COLOR_BLACK)
    assert patient.winner() == COLOR_NONE
    patient.place(patient.board.cell_index(1, 0), COLOR_BLACK)
    assert patient.winner() == COLOR_NONE
    patient.place(patient.board.cell_index(2, 0), COLOR_BLACK)
    assert patient.winner() == COLOR_NONE
    patient.place(patient.board.cell_index(3, 0), COLOR_BLACK)
    assert patient.winner() == COLOR_NONE
    patient.place(patient.board.cell_index(4, 0), COLOR_BLACK)
    assert patient.winner() == COLOR_BLACK

    patient.set_player_to_act(color_to_player(COLOR_WHITE))
    patient.undo()
    assert patient.winner() == COLOR_NONE