niklasf/python-chess

Moves generators behaviour.

GabrieleBattaglia opened this issue · 1 comments

When I set a black piece on a square, I'm getting no legal and no pseudo moves.
Is there a reason for this?
See here below

def GetPieceMoves(piece_symbol, square_str, legal_moves=True, occupied_only_square=True):
	tmp_board = board.copy()
	square = chess.parse_square(square_str)
	tmp_board.set_piece_at(square, chess.Piece.from_symbol(piece_symbol))
 # if piece_symbol is uppercase no problem, otherwise no result
	if legal_moves:
		moves = tmp_board.legal_moves
	else:
		tmp_board.clear()
		tmp_board.set_piece_at(square, chess.Piece.from_symbol(piece_symbol))
		moves = tmp_board.generate_pseudo_legal_moves()

After I'll filter these lists olding only those moves come from my target square but this is out of interest here.

When it's Whites/Blacks turn, only white/black pieces can move respectively.

You can change the turn via:

board.turn = chess.BLACK