engine.py
def possible_moves(self, game_state, from_position):
        """Return all moves except for castlings that this piece can make if it's
        located at from_position."""
        capture_move_list = []
        non_capture_move_list = []

        # Moves up.
        for to_position in range(from_position + 8, 64, 8):
            piece = game_state.board[to_position]
            if piece:
                # If capture.
                if piece.white != self.white:
                    move = Move()
                    move.add_change(from_position, self, None)
                    move.add_change(to_position, piece, self)
                    capture_move_list.append(move)
                break
            else:
                move = Move()
                move.add_change(from_position, self, None)
                move.add_change(to_position, None, self)
                non_capture_move_list.append(move)

        # Moves down.
        for to_position in range(from_position - 8, -1, -8):
            piece = game_state.board[to_position]
            if piece:
                # If capture.
                if piece.white != self.white:
                    move = Move()
                    move.add_change(from_position, self, None)
                    move.add_change(to_position, piece, self)
                    capture_move_list.append(move)
                break
            else:
                move = Move()
                move.add_change(from_position, self, None)
                move.add_change(to_position, None, self)
                non_capture_move_list.append(move)

        # Moves right.
        for to_position in range(from_position + 1, from_position - from_position % 8 + 8, 1):
            piece = game_state.board[to_position]
            if piece:
                # If capture.
                if piece.white != self.white:
                    move = Move()
                    move.add_change(from_position, self, None)
                    move.add_change(to_position, piece, self)
                    capture_move_list.append(move)
                break
            else:
                move = Move()
                move.add_change(from_position, self, None)
                move.add_change(to_position, None, self)
                non_capture_move_list.append(move)

        # Moves left.
        for to_position in range(from_position - 1, from_position - from_position % 8 - 1, -1):
            piece = game_state.board[to_position]
            if piece:
                # If capture.
                if piece.white != self.white:
                    move = Move()
                    move.add_change(from_position, self, None)
                    move.add_change(to_position, piece, self)
                    capture_move_list.append(move)
                break
            else:
                move = Move()
                move.add_change(from_position, self, None)
                move.add_change(to_position, None, self)
                non_capture_move_list.append(move)

        return (capture_move_list, non_capture_move_list)
Return all moves except for castlings that this piece can make if it's
        located at from_position.
Return all moves except for castlings that this piece can make if it's
located at from_position.
Return all moves except for castlings that this piece can make if it ' s located at from_position .
def possible_moves(self, game_state, from_position):
        capture_move_list = []
        non_capture_move_list = []
        for to_position in range(from_position + 8, 64, 8):
            piece = game_state.board[to_position]
            if piece:
                if piece.white != self.white:
                    move = Move()
                    move.add_change(from_position, self, None)
                    move.add_change(to_position, piece, self)
                    capture_move_list.append(move)
                break
            else:
                move = Move()
                move.add_change(from_position, self, None)
                move.add_change(to_position, None, self)
                non_capture_move_list.append(move)
        for to_position in range(from_position - 8, -1, -8):
            piece = game_state.board[to_position]
            if piece:
                if piece.white != self.white:
                    move = Move()
                    move.add_change(from_position, self, None)
                    move.add_change(to_position, piece, self)
                    capture_move_list.append(move)
                break
            else:
                move = Move()
                move.add_change(from_position, self, None)
                move.add_change(to_position, None, self)
                non_capture_move_list.append(move)
        for to_position in range(from_position + 1, from_position - from_position % 8 + 8, 1):
            piece = game_state.board[to_position]
            if piece:
                if piece.white != self.white:
                    move = Move()
                    move.add_change(from_position, self, None)
                    move.add_change(to_position, piece, self)
                    capture_move_list.append(move)
                break
            else:
                move = Move()
                move.add_change(from_position, self, None)
                move.add_change(to_position, None, self)
                non_capture_move_list.append(move)
        for to_position in range(from_position - 1, from_position - from_position % 8 - 1, -1):
            piece = game_state.board[to_position]
            if piece:
                if piece.white != self.white:
                    move = Move()
                    move.add_change(from_position, self, None)
                    move.add_change(to_position, piece, self)
                    capture_move_list.append(move)
                break
            else:
                move = Move()
                move.add_change(from_position, self, None)
                move.add_change(to_position, None, self)
                non_capture_move_list.append(move)
        return (capture_move_list, non_capture_move_list)
def possible_moves ( self , game_state , from_position ) : capture_move_list = [ ] non_capture_move_list = [ ] for to_position in range ( from_position + 8 , 64 , 8 ) : piece = game_state . board [ to_position ] if piece : if piece . white != self . white : move = Move ( ) move . add_change ( from_position , self , None ) move . add_change ( to_position , piece , self ) capture_move_list . append ( move ) break else : move = Move ( ) move . add_change ( from_position , self , None ) move . add_change ( to_position , None , self ) non_capture_move_list . append ( move ) for to_position in range ( from_position - 8 , - 1 , - 8 ) : piece = game_state . board [ to_position ] if piece : if piece . white != self . white : move = Move ( ) move . add_change ( from_position , self , None ) move . add_change ( to_position , piece , self ) capture_move_list . append ( move ) break else : move = Move ( ) move . add_change ( from_position , self , None ) move . add_change ( to_position , None , self ) non_capture_move_list . append ( move ) for to_position in range ( from_position + 1 , from_position - from_position % 8 + 8 , 1 ) : piece = game_state . board [ to_position ] if piece : if piece . white != self . white : move = Move ( ) move . add_change ( from_position , self , None ) move . add_change ( to_position , piece , self ) capture_move_list . append ( move ) break else : move = Move ( ) move . add_change ( from_position , self , None ) move . add_change ( to_position , None , self ) non_capture_move_list . append ( move ) for to_position in range ( from_position - 1 , from_position - from_position % 8 - 1 , - 1 ) : piece = game_state . board [ to_position ] if piece : if piece . white != self . white : move = Move ( ) move . add_change ( from_position , self , None ) move . add_change ( to_position , piece , self ) capture_move_list . append ( move ) break else : move = Move ( ) move . add_change ( from_position , self , None ) move . add_change ( to_position , None , self ) non_capture_move_list . append ( move ) return ( capture_move_list , non_capture_move_list )
Return all moves except for castlings that this piece can make if it's
located at from_position.
Return all moves except for castlings that this piece can make if it ' s located at from_position .
"""Return all moves except for castlings that this piece can make if it's
        located at from_position.""" # Moves up. # If capture. # Moves down. # If capture. # Moves right. # If capture. # Moves left. # If capture.
self
game_state
from_position