Esempio n. 1
0
	def test_queen_moves(self):
		'''Test the rook's moves unblocked'''
		board = Board(10, 10)
		queen = Queen(board.white)

		i, j = 4, 4
		board[i, j].piece = queen
		moves = queen.get_moves((i, j), board)

		self.assertTrue(Move((i,j),(i,0)) in moves)
		self.assertTrue(Move((i,j),(i,7)) in moves)
		self.assertTrue(Move((i,j),(0,j)) in moves)
		self.assertTrue(Move((i,j),(7,j)) in moves)
		self.assertTrue(Move((i,j),(i+1,j+1)) in moves)
		self.assertTrue(Move((i,j),(i+1,j-1)) in moves)
		self.assertTrue(Move((i,j),(i-1,j+1)) in moves)
		self.assertTrue(Move((i,j),(i-1,j-1)) in moves)
Esempio n. 2
0
	def test_queen_horizontal_move_blocked(self):
		'''Test the Queen's horizontal move when blocked by a piece from the
		same owner.'''
		board = Board(10, 10)
		queen = Queen(board.white)
		pawn = Pawn(board.white)

		i, j = 0, 4
		board[i, j].piece = queen
		board[i+2, j].piece = pawn

		moves = queen.get_moves((i, j), board)

		self.assertTrue(Move((i,j), (i-1,j)) not in moves)
		self.assertTrue(Move((i,j), (i+1,j)) in moves)
		self.assertTrue(Move((i,j), (i+2,j)) not in moves)
		self.assertTrue(Move((i,j), (i+3,j)) not in moves)