def move(self, original_position, new_position, promotion): dest = tuple_to_0x88(new_position) moves = self.generate_moves( LEGAL, tuple_to_0x88(original_position), COLOR_EMPTY, ) for move in moves: if move.destination() == dest: move.set_promotion(promotion) move.do_update(self) return move return False
def piece_attack_moves(self, position): square = tuple_to_0x88(position) color = self.colors[square] moves = self.attack_moves( square, color, ) return moves
def at(self, position): square = tuple_to_0x88(position) color = self.colors[square] piece = self.pieces[square] if piece == PIECE_EMPTY: return None result = "white " if color == WHITE else "black " result += NAMES[piece] return result
def piece_moves(self, position): square = tuple_to_0x88(position) color = self.colors[square] moves = self.generate_moves( LEGAL, square, color, ) return moves