Created
December 8, 2021 03:11
-
-
Save luccabb/9cf4d91754dbe4e9ec11dbddff55cd4b to your computer and use it in GitHub Desktop.
Simple move ordering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def organize_moves(board: chess.Board): | |
""" | |
This function receives a board and it returns a list of all the | |
possible moves for the current player, sorted by importance. | |
Right now we are only sending the moves that are capturing pieces | |
at the starting positions in our array (so we can prune more and earlier). | |
Arguments: | |
- board: chess board state | |
Returns: | |
- legal_moves: list of all the possible moves for the current player. | |
""" | |
org_moves = deque() | |
for move in board.legal_moves: | |
if board.is_capture(move): | |
org_moves.appendleft(move) | |
else: | |
org_moves.append(move) | |
return list(org_moves) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment