Flow is a psychological state linked to optimizing cognitive performance in humans. In this paper we propose a simple computational model of flow. We first define the degree of flow as the quality of the match between the agent’s cognitive skills and the cognitive complexity of its task. In a hierarchy of increasingly more complex and rewarding tasks, taking on the task of a matching complexity allows the agent to maximize its performance. It also consequently maximizes the degree of flow the agent will experience. We take advantage of this connection and make our agents explicitly aware of the degree of flow they are experiencing. Maximizing the readings from such a "flow meter" improves the agent’s ability to explore the environment and find problems of matching complexity. Thus, maximizing the degree of flow becomes a guide to maximizing the agent’s performance in the environment. We implement these ideas by extending the standard value iteration learning method with planning and real-time operation and empirically demonstrate that flow-maximizing agents tend to collect more reward from the environment.