예제 #1
0
def test_check_small():
  board = Board()
  king = King(BLACK, 0, 0)
  rook = Rook(WHITE, 2, 2)
  board._pieces = {king, rook}
  assert not board.checked(BLACK)
  board.move(rook, 2, 0)
  assert board.checked(BLACK)
예제 #2
0
def test_copy():
  board = Board()
  king = King(BLACK, 0, 0)
  rook = Rook(WHITE, 2, 2)
  board._pieces = {king, rook}
  clone = board.copy()
  assert len(clone._pieces) == len(board._pieces)
  for piece in clone._pieces:
    assert piece not in board._pieces
예제 #3
0
def test_check_medium():
  board = Board()
  king = King(BLACK, 0, 0)
  rook = Rook(WHITE, 2, 2)
  pawn = Pawn(WHITE, 7, 3)
  bishop = Bishop(WHITE, 1, 3)
  enemy_king = King(WHITE, 6, 6)
  board._pieces = {king, rook, pawn, bishop, enemy_king}
  assert not board.checked(BLACK)
  board.move(rook, 2, 0)
  assert board.checked(BLACK)
  assert not board.checked(WHITE)
예제 #4
0
def test_moves_tiny():
  board = Board()
  king = King(BLACK, 0, 0)
  r = Rook(WHITE, 4, 0)
  board._pieces = {king, r}
  assert_equals(board.moves_open(BLACK), True)