The paper presents a model of adaptive behavior of an autonomous adaptive agent (an artificial organism) based on the semantic probabilistic inference and the functional system theory by P.K. Anokhin. The main distinction of this model is the possibility for automatic generation of new subgoals, which allows us to solve more complex multi-level tasks. An autonomous adaptive agent has been created on the basis of this model, and a number of experiments have been carried out in order to train it and to compare it with the existing approaches based on neural networks and reinforcement learning. The results of comparison have shown that the proposed model learns and acts more efficiently.