<commit_before>from chess.pieces.color import Color
from chess.pieces.piece import Piece
from chess.point import Point
from chess.log import log

class Pawn(Piece):
    def __init__(self, position = Point(0, 0), color = Color.neither):
        super().__init__(position, color)

        # If positive, move down the board, else move up
        self.move_dir = -1
        # White moves up, black moves down
        if self.color == Color.black:
            self.move_dir = 1

        # True if the piece hasn't moved yet
        self.moved = False

    def render(self):
        if self.color == Color.white:
            return 'P'
        else:
            return 'p'

    def valid_move(self, position):
        # Pawn must stay in same column during movement
        if position.x == self.position.x:
            if position.y == self.position.y + self.move_dir:
                return True
            # Check if it is the pawn's first turn, if it is it can move two spaces as well
            if not self.moved and position.y == self.position.y + self.move_dir * 2:
                return True

        return False

    def is_path_clear(self, board, to_pos):
        if board.piece_at(to_pos):
            return False
        # Is piece is trying to move 2 spaces, if so check the middle space
        if abs(self.position.subtract(to_pos).y) == 2:
            if board.piece_at(to_pos.subtract(Point(0, self.move_dir))):
                return False

        return True<commit_msg>Added movement for pawn. Get rid of is_path_clear<commit_after>from chess.pieces.color import Color
from chess.pieces.piece import Piece
from chess.point import Point
from chess.log import log

class Pawn(Piece):
    def __init__(self, position = Point(0, 0), color = Color.neither):
        super().__init__(position, color)

        # If positive, move down the board, else move up
        self.move_dir = -1
        # White moves up, black moves down
        if self.color == Color.black:
            self.move_dir = 1

        # True if the piece hasn't moved yet
        self.moved = False

    def render(self):
        if self.color == Color.white:
            return 'P'
        else:
            return 'p'

    def valid_move(self, board, position):
        # Is piece is trying to move 2 spaces forward, check the middle space
        if abs(self.position.subtract(position).y) == 2:
            if board.piece_at(position.subtract(Point(0, self.move_dir))):
                return False

        # Pawn must stay in same column during movement
        if position.x == self.position.x:
            # First check if a piece is in front of the pawn
            if board.piece_at(position):
                return False

            if position.y == self.position.y + self.move_dir:
                return True
            # Check if it is the pawn's first turn, if it is it can move two spaces as well
            if not self.moved and position.y == self.position.y + self.move_dir * 2:
                return True

        log(str(position.subtract(self.position) == Point(1, self.move_dir)))
        # If there is a piece in a forward diagonal, we can take it
        if (position.subtract(self.position) == Point(1, self.move_dir) and
                board.piece_at(self.position.add(Point(1, self.move_dir)))):

            return True

        if (position.subtract(self.position) == Point(-1, self.move_dir) and
                board.piece_at(self.position.add(Point(-1, self.move_dir)))):

            return True

        return False

{'fraction_non_alphanumeric': 0.08862545865086086, 'fraction_numerical': 0.0059271803556308214, 'mean_word_length': 2.021312872975277, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3176887', 'n_tokens_mistral': 1040, 'n_tokens_neox': 982, 'n_words': 345}