Deep learning, a subset of machine learning, involves using neural networks with many layers to model and understand complex patterns in data. It has achieved remarkable success across various fields such as computer vision, natural language processing, and more recently, in solving partial differential equations (PDEs). Physics-informed neural networks (PINNs) are a novel approach that leverages deep learning to solve PDEs by incorporating physical laws directly into the neural network’s training process. In this work, we extend the application of PINNs to solve obstacle-related PDEs, which are particularly challenging as they require numerical methods that can accurately approximate solutions constrained by obstacles. These obstacles can represent physical barriers or constraints in the solution space. We specifically focus on employing PINNs with hard boundary conditions. Hard boundary conditions ensure that the solution strictly adheres to the constraints imposed by the physical boundaries, rather than merely approximating them. This is achieved by explicitly encoding the boundary conditions into the neural network architecture, which guarantees that the solutions satisfy these conditions throughout the training process. By using PINNs with hard boundary conditions, we can effectively address the complexities posed by both regular and irregular obstacle configurations, ensuring that the solutions remain physically realistic and mathematically precise. We demonstrate the efficacy of the proposed PINNs in various scenarios involving both linear and nonlinear PDEs, with both regular and irregular obstacle constraints.