def move(self, my_board, ra, fi): result = self.move_rule(my_board, ra, fi) if not self.valid_move(ra, fi): return False # EN PASSANT if result == "ep": self.append_move_hist_ep(my_board, ra, fi) other_piece = my_board.get_piece(self.ra, fi) other_piece.kill() my_board.set_space(self.ra, fi, 0) my_board.set_space(self.ra, self.fi, 0) my_board.set_space(ra, fi, self) self.has_moved = True self.set_pos(my_board, ra, fi) my_board.last_move = self.take_to_str(ra, fi) +"e.p." return True # SETTING EN PASSANT elif result == "set_ep": Piece.append_move_hist(self, my_board, ra, fi) my_board.set_space(self.ra, self.fi, 0) my_board.set_space(ra, fi, self) self.en_passant_able = True self.has_moved = True self.set_pos(my_board, ra, fi) my_board.last_move = board.space_to_str(ra,fi) return True # STANDARD MOVE elif result == True: Piece.append_move_hist(self, my_board, ra, fi) take = self.take_piece(my_board, ra, fi) if take: my_board.last_move = self.take_to_str(ra, fi) else: my_board.last_move = board.space_to_str(ra, fi) my_board.set_space(self.ra, self.fi, 0) my_board.set_space(ra, fi, self) self.en_passant_able = False self.has_moved = True self.set_pos(my_board, ra, fi) return True else: return False
def move_str(self, ra, fi): return self.shorthand + board.space_to_str(ra, fi)
def take_to_str(self, ra, fi): return self.shorthand + "x" + board.space_to_str(ra, fi)
def take_to_str(self, ra, fi): return board.Board.file_[self.fi] + self.shorthand + "x" + board.space_to_str(ra, fi)
def move_str(self, ra, fi): return board.space_to_str(ra,fi)