Consciousness is widely considered to be a mysterious and uniquely human trait, which cannot be achieved artificially. On the contrary, a system and method are disclosed for a computational machine that can recognize itself and other agents in a dynamic environment, in a way that seems quite similar to biological consciousness in humans and animals. The machine comprises an artificial neural network configured to identify correlated temporal patterns and attribute causality and agency. The machine is further configured to construct a virtual reality environment of agents and objects based on sensor inputs, to create a coherent narrative, and to select future actions to pursue goals. Such a machine may have application to enhanced decision-making in autonomous vehicles, robotic agents, and intelligent digital assistants.