How is the legal moves function supposed to be used on python-chess?
By running this code and entering e2e4. It turns out that the move is invalid.
import asyncio
import chess
import chess.engine
engine = chess.engine.SimpleEngine.popen_uci("stockfish.exe")
board = chess.Board()
while not board.is_game_over():
legal_count = board.legal_moves.count()
move_list = list(board.legal_moves) # Find legal moves
print (move_list)
print(board)
mover = input("Indica tu movimiento: ")
if mover not in move_list:
print ("vuelve a introducir una movida vĂ¡lida")
mover = input("otra movida: ")
board.push_xboard(mover)
result = engine.play(board, chess.engine.Limit(time=0.1))
board.push(result.move)
print(board)
engine.quit()
When I go through the list I find that ... have this kind of value:
[Move.from_uci('g1h3'), Move.from_uci('g1f3')
So, is not from legal_moves where i get the legal moves from the user??
or is supposed that i have to enter the values that way? I do not understand.
What I want is for the user to enter a value through the console "e2e4" and verify if the movement is possible. (by the way, i need that kind of coordenate "e2e4", not "e4" or "Nf3").
Thanks.