We propose a computational justice model for resource distribution in ad hoc networks using socially inspired computing and agent-based modeling. Ad hoc networks are self-organizing systems in which there is no central controller or other orchestration forms. Therefore, it is not possible to use distribution methods designed for centralized systems that require complete information and where the resource distribution aims to optimize the performance of the whole system without considering the individual goals of the participants. In this work, we used socially inspired computing to formulate a distribution method using stochastic games, institutions, distributive justice, and adaptative computing. We analyzed our proposal through simulation and compared its performance with previous works. The result showed how a distribution method based on computational justice is a potential solution for facing the distribution problem in ad hoc networks. Additionally, we implemented a multi-agent system to evaluate this proposal in a real system and to provide an easy and low-cost platform for developing ad hoc network applications.