You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have written a function that would take a stockfish move and translate it into a human readable string. Maybe you want to implement that in the library so I thought I'd share. Feel free to close if you do not.
classPlayer:
WHITE="White"BLACK="Black"defgetNTM(stockfish: Stockfish) ->str:
returnPlayer.WHITEif (stockfish.get_fen_position().find(" w ") >0) elsePlayer.BLACKdefdescribeMove(stockfish: Stockfish, move: str) ->str:
if (stockfish.is_move_correct(move)):
# move stuffsrc=move[0:2]
dst=move[2:4]
turnsInto=move[4:5].lower()
cap=NonepieceMoving=str(stockfish.get_what_is_on_square(src)).replace("Piece.", "")
ret=f"{pieceMoving} from {src} to {dst}"# if capturecap=stockfish.will_move_be_a_capture(move)
ifcap==Stockfish.Capture.DIRECT_CAPTURE:
tgt=stockfish.get_what_is_on_square(dst)
tgt=str(tgt).replace("Piece.", "")
ret=ret+f" capturing {tgt}"elifcap==Stockfish.Capture.EN_PASSANT:
tgt=Stockfish.Piece.WHITE_PAWNifgetNTM(stockfish) ==Player.BLACKelseStockfish.Piece.BLACK_PAWNtgt=str(tgt).replace("Piece.", "")
ret=ret+f" capturing {tgt} en passant"# turning pawn into something else.ifturnsInto!='':
ifturnsInto=='q':
turnsInto=Stockfish.Piece.WHITE_QUEENifgetNTM(stockfish) ==Player.WHITEelseStockfish.Piece.BLACK_QUEENelifturnsInto=='n':
turnsInto=Stockfish.Piece.WHITE_KNIGHTifgetNTM(stockfish)==Player.WHITEelseStockfish.Piece.BLACK_KNIGHTelifturnsInto=='b':
turnsInto=Stockfish.Piece.WHITE_BISHOPifgetNTM(stockfish)==Player.WHITEelseStockfish.Piece.BLACK_BISHOPelifturnsInto=='r':
turnsInto=Stockfish.Piece.WHITE_ROOKifgetNTM(stockfish)==Player.WHITEelseStockfish.Piece.BLACK_ROOK# remove 'Piece.'turnsInto=str(turnsInto).replace('Piece.', '')
# colorifcap!=None:
ret=ret+" and"ret=ret+f" turning into {turnsInto}"returnretelse:
return"Invalid Move"
The text was updated successfully, but these errors were encountered:
Hello, this project is no longer maintained in this repo but on this fork. (For more information about this please look here).
Since this issue has no comments, it should be quite easy to copy the content and title into a new issue over there. (For more specific information on that, look here).
This makes it easier for us to keep track of things, and it's more convenient because we then have the issues right where they are being worked on. So please create a new issue in the new repo and then close this one. Thank you!
I have written a function that would take a stockfish move and translate it into a human readable string. Maybe you want to implement that in the library so I thought I'd share. Feel free to close if you do not.
The text was updated successfully, but these errors were encountered: