Dynamical systems as a level of cognitive analysis of multi-agent learning

A dynamical systems perspective on multi-agent learning, based on the link between evolutionary game theory and reinforcement learning, provides an improved, qualitative understanding of the emerging collective learning dynamics. However, confusion exists with respect to how this dynamical systems account of multi-agent learning should be interpreted. In this article, I propose to embed the dynamical systems description of multi-agent learning into different abstraction levels of cognitive analysis. The purpose of this work is to make the connections between these levels explicit in order to gain improved insight into multi-agent learning. I demonstrate the usefulness of this framework with the general and widespread class of temporal-difference reinforcement learning. I find that its deterministic dynamical systems description follows a minimum free-energy principle and unifies a boundedly rational account of game theory with decision-making under uncertainty. I then propose an on-line sample-batch temporal-difference algorithm which is characterized by the combination of applying a memory-batch and separated state-action value estimation. I find that this algorithm serves as a micro-foundation of the deterministic learning equations by showing that its learning trajectories approach the ones of the deterministic learning equations under large batch sizes. Ultimately, this framework of embedding a dynamical systems description into different abstraction levels gives guidance on how to unleash the full potential of the dynamical systems approach to multi-agent learning.


Introduction
Multi-agent learning. In a multi-agent system, a collective of autonomous agents interacts in a shared environment. Multi-agent systems are important for a variety of application domains, such as traffic [3,90,113], manufacturing [111], electricity [82] and finance [61]. Furthermore, a sound understanding of multi-agent systems is relevant for other fields, such as biology [68], economics [28], sustainability [10] and social sciences in general [19]. For artificial agents, preprogrammed agent behavior cannot lead to satisfactory solutions when the behavior of other agents and the shared environment is unknown or too complex. The agents need to learn an appropriate course of actions by themselves. Likewise, natural agents do use many forms of learning, which is required when the future is unpredictable and complex and therefore precise planning is doomed to failure.
While many learning mechanisms have been studied and applied in a multi-agent setting [31,92], a significant amount of work concerns multi-agent reinforcement learning [17,105]. Reinforcement learning is a trial-anderror method of mapping situations to actions in order to maximize a numerical reward signal [98]. Particular challenging is the case when rewards come as a delayed consequence of current actions. For this case, the class of reinforcement learning procedures that utilizes the difference between estimates made from past and current experiences, called temporal-difference learning [96], has been particularly influential. Also, remarkable similarities exist between computational reinforcement learning and results of neuroscientific experiments [24]. Dopamine appears to convey temporal-difference errors to brain structures where learning and decision-making take place [87]. It has further been argued that this dopamine reward-prediction error signal constitutes a potential neuronal substrate for the crucial economic decision variable of utility [88].
Reinforcement learning algorithms can be divided into two categories: model-free and model-based. Model-free methods learn directly from experience, whereas modelbased methods learn a model of the environment to plan their course of actions [44]. In multi-agent settings, agents can be further categorized into two categories [15,105]: independent learners, which learn the value of situationaction mappings only for their own actions and joint-action learners, where the learning takes place over the jointaction space [20].
Challenges. However, the application of multi-agent learning systems is hindered by numerous challenges: Complexity. The joint state-action space suffers from the curse of dimensionality, hindering the scalability of algorithms to realistic problem sizes [17]. While deep-learning techniques can enable the scalability of multi-agent learning, several new challenges need to be addressed regarding implementation, computational demands and scientific reproducibility [43].
Non-stationarities. Each agent's environment becomes non-stationary due to the other learning agents. Thus, each agent is faced with a moving-target problem [105] which invalidates the convergence properties of most single-agent learning algorithms [17,42]. Also, the exploration-exploitation trade-off is further complicated due to the presence of multiple agents. Agents need to explore to obtain information not only about the environment, but also about the other agents [17]. As a result, the analysis of the transient learning behavior gains in importance.
Coordination needs. Agents need to coordinate between equally good policies, since the effect of any agent's action depends also on the actions taken by the other agents [17,72]. Even more challenging is the case when the agents did not train together and have to coordinate in an ad hoc [95] or zero-shot [51] manner.
Social dilemmas. Social dilemmas can arise, typically defined as a situation in which any agent prefers the socially defecting choice, regardless of what the other agents do, yet all agents are better off if all choose the socially cooperative option [23].
Learning goal. Last, defining an appropriate learning goal still remains challenging since the objectives of the agents are not necessarily aligned [17,93,117].
Taken together, these challenges culminate in the challenge of the interpretability of multi-agent learning systems. Despite the lack of consensus on how to specify interpretable machine learning, it has been widely recognized as an important aspect for the advancement of autonomous learning systems [65]. The majority of interpretability research focuses on methods for classifying high-dimensional data. Techniques for interpretable reinforcement learning have not been extensively studied [45]. As Doshi-Velez and Kim [27] argue, the need for interpretability stems from an incompleteness in the problem formalization. As the list of challenges above highlights, multi-agent learning with various types of learners in various types of environments can find themselves in various types of strategic interactions and dynamic regimes under various types of learning goals. This openness of the multiagent learning problem formulation highlights the need for interpretable multi-agent learning methods.
Replicator Reinforcement Learning Dynamics. A dynamical systems approach, based on the link between evolutionary game theory and reinforcement learning, contributes to solving these challenges by providing improved, qualitative insights into the emerging collective learning dynamics [15]. This link turned out to be beneficial for applications regarding hyper-parameter tuning [56,58], the design of new reinforcement learning algorithms [36,40], the creation of novel evaluation metrics [78] and the analysis of strategic interactions [116]. Therefore, it is a prime candidate for interpretable multiagent learning research.
In their seminal work, Börgers and Sarin showed how one of the most basic reinforcement learning update schemes, cross-learning [22], can converge to the deterministic replicator dynamics of evolutionary games theory [18]. This connection opened up all the tools of dynamical systems theory to the study of collective learning. The relationship between the two fields is as follows: one population with a frequency over phenotypes in the evolutionary setting corresponds to one agent with a frequency over actions in the learning setting [103]. The convergence to the replicator dynamics has also been shown for stateless Q-learning [86,104], following some mathematical limiting procedure.
Yet, there is ambiguity as to how this deterministicsometimes also called evolutionary -limit is taken. Consequently, it remains also unclear how to interpret these dynamics of multi-agent reinforcement learning [6].
One technique sends the learning rate to zero, resulting in replicator-type dynamics in continuous time [86,104]. However, previous work found that discrepancies arise between the learning trajectories of the limiting learning equations and the actual Q-learning algorithm at small learning rates. This policy-bias problem has been addressed by modifications of the basic Q-learning algorithm. The value of an action is updated proportional to the inverse of the frequency of choosing that action. This suggests that replicator dynamics learning actually matches a frequencyadjusted Q-learning algorithm [1,55].
Alternatively, a deterministic limit of reinforcement learning can be taken in discrete time, resulting in a set of difference equations for the action probabilities [14,[32][33][34]. This technique assumes that agents update their action values and policies only once every K rounds, using averages of the collected rewards. Similar methods in computer science are known as experience replay [64] or batch learning [60]. Deterministic dynamics emerge by sending the size of the batch K to infinity.
While the construction of such a batch-learning algorithm is straight forward for stateless repeated games, it is less clear how learning dynamics and batch algorithm relate in multi-state environments. Overall, there is much less work on learning dynamics in changing environments. Multiple variants of state-coupled replicator dynamics [40,41,109] have been introduced, yet, all of these dynamics consider an average reward setting, whereas in temporal-difference learning a discounted reward is commonly used. Recently, we introduced an analytical method to derive the deterministic, discrete-time limit of temporaldifference reinforcement learning with discounted rewards [7]. This method extends on the idea of batch learning with an infinite batch size, yet, it is still an open question how a temporal-difference batch learning algorithm must be constructed such that the learning trajectories of the algorithm can approximate those of the deterministic dynamics under large batch sizes.
Cognitive levels of analysis. In order to resolve ambiguity around the interpretation of multi-agent learning using dynamical systems theory, I propose to embed the dynamical systems approach within multiple levels of cognitive analysis. Marr's level of analysis-computational, algorithmic and implementation-has had farreaching influence in both neuroscience and cognitive science [70,71]. They correspond to an abstract characterization of the computational problem being solved, the algorithm executing that solution, and the hardware implementing that algorithm. This framework highlights that it is valid, fruitful, and even necessary to analyze cognition by forming abstraction barriers which result in different levels of analysis [35]. Griffiths and colleagues [35] proposed to define levels of analysis that lie between the computational and the algorithmic, leading to the study of the optimal use of cognitive resources [37,50,52,63,83].
Contributions. I take on this idea of different levels of analysis and the value of building bridges between them and explicitly apply it to multi-agent learning.
First, I associate the dynamical systems level-manifested by replicator-alike equations-to an algorithmic level of high abstraction. Note that dynamical systems approaches to agent-environment interactions in particular and cognitive science in general have a long tradition [12,13]. In this article, I explore the connections between this dynamical systems level, the computational level and an algorithmic level of lower abstraction. Like Griffiths and colleagues [35], I do not deal with the implementation level.
Second, I establish connections between the replicatoralike reinforcement learning equations [7] and the computational level. For multi-agent learning, the computational level is characterized by the framework of stochastic games [66] which I introduce in Sect. 2. I conjecture the relationship between the learning dynamics and Markov Perfect equilibria, a solution concept of stochastic games, and show that the dynamics follow a minimum free-energy principle (Sect. 3).
Third, I connect the dynamical systems level to an algorithmic level of lower abstraction. To do so, I propose a novel temporal-difference batch-learning algorithm (Sect. 4) and show that the learning trajectories of the algorithm converge to the ones of the deterministic equations under increasing batch sizes (Sect. 5).
I finish with a discussion about specifics, limitations and related work about the dynamic equations and the proposed sample-batch algorithm and highlight how the learning dynamics form a model of bounded rationality. I also give directions for future work and potential applications (Sect. 6). Fig. 1 shows a graphical overview of the paper's main contributions.

Stochastic games
Stochastic games are a formal model for multi-agent environment systems. They generalize both repeated normal form games and Markov decision processes (MDPs). MDPs are generalized by introducing multiple agents. Repeated games are generalized by introducing an environment with multiple states and transition probabilities between those states. All agents choose their actions simultaneously. The transition probabilities depend on the joint action and the current environmental state. So do the rewards. Formally, the game G ¼ hN; S; A; T; R; Xi is a stochastic game with N 2 N agents. The environment consists of Z 2 N states S ¼ ðS 1 ; . . .; S Z Þ. In each state s, is the joint-action set and agents choose their actions simultaneously.
The transition function T : S Â A Â S ! ½0; 1 determines the probabilistic state change. Tðs; a; s 0 Þ is the transition probability from current state s to next state s 0 under joint action a ¼ ða 1 ; . . .; a N Þ 2 A.
The reward function R : S Â A Â S ! R N maps the triple of current state s, joint action a and next state s 0 to an immediate reward value for each agent. R i ðs; a; s 0 Þ is the reward agent i receives.
Agents choose their actions probabilistically according to their policy X i : S Â A i ! ½0; 1. X i ðs; aÞ is the probability that agent i chooses action a given the environment is in state s. Xðs; aÞ ¼ Q i X i ðs; a i Þ is the joint policy. I chose an identical number of actions for all states and all agents out of notational convenience. With a Ài ¼ ða 1 ; . . .; a iÀ1 ; a iþ1 ; . . .; a N Þ I denote the joint action except agent i's. Throughout this paper I only consider ergodic environments without absorbing states.

Temporal-difference reinforcement learning
Temporal-difference Q-learning is one of the most widely used reinforcement learning algorithms [98,112]. Agents successively improve their evaluations of the quality of the available actions at each state. At time step t, agent i evaluates action a in state s to be of quality Q i t ðs; aÞ. Those state-action values Q i t ðs; aÞ are then updated after selecting action a t in state s t according to with the temporal-difference error This update can be derived from the assumption that agent i aims to maximizes its expected discounted future reward G i t ¼ ð1 À cÞ P 1 k c k r i tþk , where the discount factor parameter c 2 ½0; 1Þ regulates how much the agent cares for future rewards. The pre-factor ð1 À cÞ normalizes the stateaction values to be on the same numerical scale as the rewards. The learning rate parameter a 2 ð0; 1Þ regulates how much new information is used for a state-action-value update. For the sake of simplicity, I assume identical parameters across agents throughout this paper and therefore do not equip parameters with agent indices. The variable r i t refers to agent i's immediate reward at time step t.
Agents select actions based on the current state-action values Q i t ðs; aÞ, balancing exploitation (i.e., selecting the action of maximum quality) and exploration (i.e., selecting lower quality actions in order to learn more about the environment). I here focus on the widely used Boltzmann policy. The probability of choosing action a in state s is where the intensity of choice parameter b controls the exploration-exploitation trade-off. Throughout this paper, I am interested in the learning process with fixed parameters a, b and c throughout learning and evaluating a policy.

Deterministic learning dynamics
In this section, I first present a dense recap of the derivation of the deterministic discrete-time dynamic equations of temporal-difference reinforcement learning. A more elaborate version can be found in Ref. [7]. Then, I show how these equations relate to the higher-level properties of game-equilibira and free energy minimization. Note that temporal-difference learning generalizes simpler forms of stateless reinforcement learning used in many previous studies. In a stateless environment with discount factor c ¼ 0, temporal-difference learning reduces to this simpler form of reinforcement learning. Thus, the presented results conceptually hold for these learning dynamics as well.

Derivation
In where P s 0 P a Ài X Ài ðs; a Ài Þ Tðs; a; s 0 Þ is a short notation for X ÞTðs; a; s 0 Þ: Regarding notation, the bar over the symbol indicates that a policy average has been taken. When fewer state and action variables appear in the brackets, the remaining variables indicate which other variables have been used to average over.
Second, the quality of the next state, max b Q i t ðs tþ1 ; bÞ, yields max Q i ðs; aÞ :¼ X

Properties
Let us divide the average temporal-difference error into two parts, the non-regularized part plus the regularizer, d i ðs; aÞ ¼ q i ðs; aÞ À ln X i ðs; aÞ=b with q i ðs; aÞ ¼ ð1 À cÞ R i ðs; aÞ þ c max Q i ðs; aÞ: The deterministic map comprised of Eq. 3 and the nonregularized temporal-difference error, is equivalent to the alternative replicator dynamics in discrete time [48,49] with ab q i ðs; aÞ being the fitness of agent i's action a in state s. This equivalence allows us to conjecture the folk theorem of evolutionary game theory [21,49] for policy-average temporal-difference learning in stochastic games (a detailed proof is not the focus of this work and left for future work): Roughly speaking, Markov Perfect equilibria can be seen as the Nash equilibria of the stochastic game when agents employ stationary Markov policies [26], i.e., as in this case, choose an action with a probability based only on the current state. This means no agent can gain more value by unilaterally changing its policy at a Markov Perfect equilibrium. Nontrivially, they have been shown to exist in discounted stochastic games with a finite number of agents [29]. Considering the dynamics with full average temporaldifference error including the regularization term, the steady state policy, if it exists, can be obtained by setting d i ðs; aÞ ¼ 0 which yields after normalizing, Despite their similarity, this set of equations is qualitatively different from Eq. 2; Eq. 6 gives a condition for the policies X i Ã ðs; aÞ and values q i Ã ðs; aÞ at equilibrium. One can show that the joint policy described in Eq. 6 follows from the principle of maximum entropy [53] under the constraint that agents play a policy the yields a constant expected value [114,115]. The negative logarithm, À ln X i ðs; aÞ, is called the information, surprise or uncertainty [91] of agent i taking action a in state s. The entropy À P b X i ðs; bÞ ln X i ðs; bÞ is the average surprise of agent i's policy in state s. The principle of maximizing the average surprise or uncertainty in a policy is reasonable whenever agents are not capable of computing the optimal policy straight away. This may because either agents are uncertain about their environment or they lack the cognitive resources. Within the context of active learning [89], this is also known as uncertainty sampling.
From the maximum entropy principle follows the principle of minimum free energy which can be expressed as the action-mean policy-average Minimizing the first term is equivalent to maximizing the expected average quality, minimizing the second term means maximizing the entropy of agent i's choice of actions in state s. The Lagrange parameter b balances these two contributions.
It is important to note that the minimum free energy principle does only hold for temporal-difference reinforcement learning when we differentiate the free energy with respect to the current action in the current state. In other words, we ask only for the effect of what the agent can do at this moment. We are not concerned with the effects of this action when the environment returns to the current state. This notion, that we are only interested in the effect of the current action a in state s resembles precisely the common definition of the state-action values Q i ðs; aÞ [98].
While the dynamics (Eq. 5) converge to a policy with minimum free energy (Eq. 6) one can also show that the steps the dynamics take minimize free energy differences,

Algorithmic foundations
In order to connect the presented deterministic learning dynamics to an algorithmic level of analysis of lower abstraction, I present a temporal-difference reinforcement learning algorithm whose learning trajectories approach the ones of the deterministic dynamics. I will build up on the idea of batch learning that has been used in previous work on stateless reinforcement learning dynamics and extend it to multi-state temporal-difference learning. Originally, the batch reinforcement learning problem is defined to learn the best policy from a fixed set of a priori-known transition samples [60]. Research activity on batch reinforcement learning has grown substantially in recent years, primarily due to the central merits of the batch approach: (i) its efficient use of collected data and (ii) the stability of the learning process when used with function approximation. My focus though is not to present an efficient algorithm that solves the batch learning problem. Instead, I aim for an improved understanding regarding the algorithmic foundations underlying the policy-average temporal-difference learning equations.
I denote the proposed algorithm sample-batch temporaldifference Q-learning. The learning process is divided into two phases, an interaction phase and an adaptation phase. During the interaction phase, the agent keeps its policy fixed while interacting with its environment for K time steps, collecting state, action and reward information. During the adaptation phase, the agent uses the collected information for an update of its policy. Key is the use of two state-action value tables, one for acting ( act Q), the other for improved value estimation ( val Q). While act Q is kept constant during the interaction phase, val Q is iteratively updated.
During the interaction phase the information is collected as follows. The agent counts the number of visited stateaction-next state triples, t i ðs t ; a t ; s tþ1 Þ þ¼ 1 and sums up immediate rewards for each state-action pair, r i ðs t ; a t Þ þ¼ r i t ; with r i t being the reward agent i received at time step t. Both, tðs; a; s 0 Þ and r(s, a) were initialized to zero for all s; a; s 0 . Further, each agent updates its value estimate of the current state-action pair as Note, I here do not use the off-policy max term in the value update. The aim of updating the val Q i values is to estimate the true state-action values of policy X i . The use of P b X i t ðs tþ1 ; bÞ val Q i tþ1 ðs tþ1 ; bÞ is known as expected SARSA, which was shown to have significant advantages over other update schemes [54,106]. At the beginning of each batch val Q i tþ1 ðs; aÞ are set to act Q i tþ1 ðs; aÞ, which are initialized to lnðX i 0 ðs; aÞÞ=b À hlnðX i 0 ðs; bÞÞ=bi b . These interaction steps repeat until the current time step t is a multiple of the batch size K. Then the learner enters the adaptation phase.
During the adaptation phase, the agent uses the sample averages of the immediate rewards and next-state-value estimates to summarize the collected information in order to update the act Q values. For all states, s, and actions, a, the sample-average reward is computed as R i ðs; aÞ ¼ r i ðs; aÞ=dðs; aÞ; with the divisor dðs; aÞ ¼ minð1; P s 0 t i ðs; a; s 0 ÞÞ. The divisor is used to avoid a division by zero, taking into account the possibility that a state-action pair might not have been visited. The sample-average transition model amounts tõ the values val Q i tþ1 ðs; aÞ ¼ act Q i tþ1 ðs; aÞ, and r i ðs; aÞ ¼ 0, and t i ðs; a; s 0 Þ ¼ 0, for all s; a; s 0 . Note that this sample-batch algorithm reduces to standard Q-learning for a batch size K ¼ 1.

Results
In this section, I compare the deterministic learning equations (Sect. 3) with the sample-batch algorithm (Sect. 4) to show that their learning trajectories match under large batch sizes and thus, the sample-batch algorithm can be seen as an algorithmic foundation of the deterministic learning dynamics. I use two classes of environments as testbeds, a risk-reward dilemma and a zero-sum competition. For each comparison, I let both learning processes, deterministic equations and stochastic algorithm, update their policies 100 times. As a consequence, an increased batch size K results into an increased number of time steps as the sample-batch algorithm interacts with the environment.

Risk-reward dilemma
The first environment I use as a testbed is a one-agent stochastic game, i.e., a Markov decision process. It is a simple, two-state, two-action environment and models the inter-temporal dilemma between a risky choice with possibly high immediate reward and a safe choice with a guaranteed, but low immediate reward [8]. The action set reads A ¼ fsafe; riskyg, the environment can either be in a prosperous or a degraded state, S ¼ fprosp:; deg:g. The transition function reads By applying the safe action in the prosperous state, the agent is guaranteed to remain in the prosperous state and obtains a reward of 0.5. If it applies the risky action and remains in the prosperous state, it obtains a reward of 1. If, however, the environment collapses under the risky action, the agent obtains 0 reward until the environment is recovered again. Recovery is possible only under the safe action after waiting for some iterations in the degraded state. In the prosperous state, it depends on the agent's discount factor whether the risky or the safe action is more valuable to the agent. Figure 2 compares the deterministic dynamics with the sample-batch algorithm. For an agent with a discount factor of c ¼ 0:9 it is optimal to select the safe action in both states. The challenge presented in Fig. 2 is learning to play safe in both states, starting from an initial policy where the safe action is chosen only with 20% in both states. The arrows in the policy space indicate the average direction toward which the learner is driven by temporal-difference errors of the deterministic limit (Eq. 4). The deterministic dynamics (dark red dashed line) follow these temporaldifference arrows and learn to play almost completely safe. The small distance to the upper right corner in the policy space results from the finite exploitation parameter b.
Under increasing the sample-batch size K, the match between deterministic dynamics and sample-batch algorithm becomes increasingly closer. The sample-batch learning algorithm with batch size K ¼ 50 does not learn to play safe in the prosperous state (Fig. 2a). For a batch size of K ¼ 500, the agent learns to do so, yet, the trajectory through the policy space differs from the one of the deterministic limit (Fig. 2b). The agent learns to play safe in the degraded state faster than in the prosperous state. For a batch size of K ¼ 5000, algorithm and equations match almost perfectly (Fig. 2c).
Extending the single-agent risk-reward dilemma to a multi-agent environment, I let the agents face a classic social dilemma in the prosperous state [9]. Playing safe induces a costly contribution c to the public good from which all agents will receive a benefit b, regardless whether they contributed or not. However, each risky action will increase the probability by 0.2/N that the environment will collapse from the prosperous to the degraded state. In the degraded state, all agents receive a negative collapse impact m\0. Only the safe action will increase the recovery probability by 0.1/N from the degraded to the prosperous state. In previous work, we showed that the discount factor alone can transform this game from a tragedy of the commons, where the risky action dominates, into one of coordination, and even into a comedy of the commons in which the safe action dominates [9]. Figure 3 compares the deterministic dynamics with the sample-batch algorithm for an environment with 2 agents. Parameters are as such that the game is a comedy, where the game-equilibrium corresponds to all agents playing safe in both states. And indeed, the deterministic dynamics (dark red dashed line) reach this policy from the asymmetric initial policy, where agent 1 plays safe with 10% in the degraded and 80% in the prosperous state and agent 2 play safe with 40% in the degraded and 10% in the prosperous state.
Here too, as well, the match between deterministic dynamics and sample-batch algorithm becomes increasingly closer under increasing sample-batch size K. For K ¼ 50, the learning behavior of the algorithm in the prosperous state appears to be random around the center of the policy space (Fig. 3 a). For a batch size of K ¼ 500, algorithm and deterministic dynamics match already well (Fig. 3 b). The match is perfected for K ¼ 5000 (Fig. 3 c).

Zero-sum competition
The other environment I use as a testbed is the two-agent (N ¼ 2), two-state (S ¼ f1; 2g), two-action (A ¼ fleft; rightg) matching pennies game [40]. It roughly models the situation of penalty kicks between a kicker and a keeper. Both agents can choose between the left and the right side of the goal. The keeper agent scores one point if it catches the ball, otherwise the kicker agent receives one point. Agents change roles under state transitions, which depend only on agent 1's actions. Precisely when agent 1 selects either left as keeper or right as kicker both agent will change roles. With symmetrical rewards but asymmetrical state transitions, the two-state Matching Pennies game presents the challenge of coordinating both agents on playing a mixed strategy with equiprobable actions. Figure 4 shows that the match between deterministic dynamics and sample-batch algorithm becomes increasingly closer under increasing sample-batch size K. The deterministic dynamics (dark red-dashed line) manage to find this mixed Markov equilibrium in the center of the policy space from a spiraling learning trajectory starting with both agents selecting left with 20% in both states. The sample-batch algorithm with batch size K ¼ 50 does not capture the learning trajectory of the deterministic dynamics (Fig. 4a). For a batch size of K ¼ 500, algorithm and deterministic dynamics match already well (Fig. 4b).
The match is perfected for K ¼ 5000 (Fig. 4c). The match between the samplebatch learning algorithm and the deterministic dynamics becomes increasingly closer as the batch size K increases Figure 5 shows that the sample-batch algorithm approaches the deterministic dynamics under increasing sample-batch size K even for parameter domains at which the deterministic agents no longer converge to a fixed point policy but instead learn on a periodic orbit of changing policies.

Rate of convergence
where I use h:i s;a;s 0 to take the sample average along all states s, actions a and next state s 0 , if they exist in the temporal-difference error term Y. Fig. 6 shows how the relative errors of the temporal-difference error terms  in all environments. Yet, here differences between environment classes exist. The convergence of the value terms occurs faster in the zero-sum environments than in the risk-reward dilemmas. One explanation for this phenomenon is the environmental dynamics. In the zero-sum games, state changes occur more often than in the risk-reward dilemmas, allowing for a faster and smoother convergence.
Overall, Fig. 6 explains the results shown in Figs. 2, 3, 4 5. For batch sizes of K ¼ 50 and K ¼ 500, the differences between algorithmic and average temporal-difference errors are simply too large for a close match between algorithmic and determinsitic learning trajectories through policy space. For the environments used in this article, a batch size of K ¼ 5000 is able to let the learning trajectories match well. Interestingly, the quality of this match must depend also on the type of the attractor. For agent parameters that lead to a periodic orbit in the zero-sum environment, a batch size of K ¼ 5000 is required to let the learning trajectories match well. For agent parameters that let the learning convergence to the center of the policy space, a good match of the learning trajectories could already be achieved with K ¼ 2500. The reason is that the center of the policy space does not require the same amount

Discussion
In this article, I proposed to regard the replicator reinforcement learning dynamics perspective on multi-agent learning as a level of cognitive analysis. This dynamical systems level still has a high level of abstraction, connecting the computational level of the problem statement with lower algorithmic levels that aim to find a solution for the computational problem. I argue that it are the connections between those levels that can bring improved insights about the whole system of multiple learning agents (Fig. 1). I demonstrated this approach with the classic model-free independent temporal-difference Q-learning algorithm. It generalizes simpler forms of reinforcement learning used in previous studies and has importance also in neuroscience through the reward-prediction hypothesis [87]. I first discuss specifics, limitations and related work about the dynamic equations and the proposed sample-batch algorithm separately, before I highlight how the learning dynamics form a model of bounded rationality which can be used as a cognitive interpretation of individual learning in models of social dynamics. I finish with an outline for future work.

Dynamics
With respect to the connection between the computational level and the dynamical systems level of learning, I have shown that the equilibria of these dynamics, if they exist, minimize a free energy functional resulting from a maximum entropy approach. Further, I showed that the discrete The concept of free energy minimization occurs in various other related domains. Minimizing free energy differences has been proposed as a thermodynamic theory of decision-making with information processing costs, which encompasses optimal, risk-sensitive and robust decision-making as special cases [79,80]. Also, free energy minimization has served as a theory of boundedly rational decision-making [114,115]. Eq. 6 resembles Quantal Response [74,75] or logit equilibria [4] from behavioral game theory, which are able to provide a unified perspective on many of the systematic deviations from Nash equilibria in behavioral experiments. For example, the famous Ellsberg's and Allais' paradoxes can be explained [80]. Under a particular choice of rewards, which minimize the agents' observational surprise, minimizing the free energy approximates Bayesian inference [67,80]. Such a variational Bayes approach has also been proposed as a unified theory to understand brain function [30]. With respect to the domain of optimal control, closely related ideas are entropy regularization [77], reinforcement learning as probabilistic inference [62], maximum-entropy reinforcement learning [119], energy-based reinforcement learning [39,84] and Kullback-Leibler divergence minimization [36,57,101].
It is interesting to observe the different roles the parameter b receives from these different contexts. From decision-making under uncertainty, the intensity of choice b regulates the exploration-exploitation trade-off. In the min free energy principle b is a Lagrange multiplier. In boundedly rational decision-making b regulates the degree of an agent's rationality or likewise b À1 the cognitive cost of the agent. Indeed, b À1 must come in units of reward per units of information, i.e., how expensive it is for an agent to acquire information about the optimal policy. For decisionmaking under uncertainty, b À1 expresses the value of being unsure about what to do. If the agent knows nothing about the environment being unsure about what to do is more valuable compared to the situation when the agent already learned something about the environment. This suggests the use of an adaptive b [102]. Fig. 6 Relative error of temporal-difference error terms (reward DR i ðs; aÞ in red, transitions DT i ðs; a; s 0 Þ in dark blue, values DQ i ðs; aÞ in orange, max values D max Q i ðs; aÞ in light blue, temporal-difference error Dd i ðs; aÞ in green) versus the batch size K for the four environments presented (singleagent risk-reward environment in Fig. 2, two-agent risk-reward environment in Fig. 3, zero-sum competition with fixed point in Fig. 4, zero-sum competition with periodic orbits in Fig. 5). Shown are the averages of 100 sample runs in the center of on standard deviation. Each plot uses the initial policy from its corresponding Figs. 2-5. Vertical lines indicate the batch size shown in those figures

Algorithm
In order to connect the dynamical systems level to an algorithmic level of lower abstraction, I proposed a simple batch learning algorithm for temporal-difference Q-learning. I showed that under increasing batch size the learning trajectories of this sample-batch algorithm match the ones of the deterministic equations. Two characteristics of the algorithm are essential for this property. First, the policy is updated using a batch of experiences, i.e., state-action transitions. Second, the state-action values are separated into two data structures, one for the value estimation inside the batch, the other for acting outside the batch.
This algorithms has various similarities with wellknown algorithms from the literature. For one, its structure is similar to the influential DQN-paradigm [76], which also combines the replay of a batch of experiences with separated state-action value estimation. This suggests that some of DQN's success might be due to the fact that it approximates a free-energy minimizing learning dynamic whose stable rest points correspond to Nash equilibria under b ! 1. Nevertheless, significant differences remain. Most importantly, DQN is used with non-linear function approximation, whereas my algorithm is a tabular method. Being in the tabular setting is certainly a limitation of my work. Both, algorithm and dynamic equations do not scale to more complex environments.
With respect to use of separate state-action value estimation, a related approach is double-Q learning [38]. It uses two Q-tables to avoid an overestimation of the next state value caused by the max operator used in Q-learning. One Q-table is used for an update of the other and vice versa. In contrast, my algorithm's Q-tables keep their roles as actor and value-estimator fixed. Overestimation is avoided by a large batch sizes which lead to unbiased policy-average estimators.
With respect to use of a batch for memory replay, my sample-batch algorithm has similarities with a stochastic Dyna agent [97] that uses experienced reward and state samples to simultaneously update a value function and learn a model. Indeed, the distinction between model-free and model-based algorithms is not always clear and memory replay blurs the line between model-based and model-free methods [107]. The data structures of the proposed algorithm, which store rewards and transitions, are the model the agent learns while interacting with the environment. The state-action values for improved value estimation inside the batch ( val Q) are simultaneously updated. The use of the current policy of my algorithm resembles what is known as trajectory sampling [11]. In contrast to Dyna, the model is learned for each policy from scratch and also no reward-state transitions are sampled from the model. This makes the proposed algorithm highly data-inefficient. Yet, my goal was not to create an efficient algorithm, but to improve on the understanding of the deterministic temporal-difference learning dynamics.
All related algorithm discussed so far fall under the category of value-based or critic-only methods, that aim to obtain a good estimate of the state-action value function first and then derive a policy from it. However, the use of the soft-max policy in combination with the two Q-tables has also similarities with the family of actor-critic algorithms [59] and policy gradient methods [99]. One Qtable is used for acting ( act Q), the other for improved values estimation and criticizing the actor ( val Q). Actor-critic algorithms have also been referred to as two-time-scale algorithms [59] in which the actor is updated on a slower time scale than the critic. This description matches my sample-batch algorithm perfectly. One advantage of actorcritic methods is their capability of learning a stochastic policy explicitly, which turns out to be useful in competitive and non-Markov cases [94]. And indeed, we have seen the convergence of both the sample-batch algorithm and the learning equations in the zero-sum competition (Fig. 4).
Taken together, the classification of the replicator reinforcement learning dynamics need revision. Although originally derived from model-free temporal-difference reinforcement learning algorithms [7], they should be classified as model-based learners. In the limit of an infinite memory-batch, they obtained a perfect model of their current environment. However, the environmental transitions each agent learns are influenced by the policies of the other agents. And since this influence of the other agents' policies is taken into account perfectly by the deterministic equations, i.e., they condition their perfect model of the environment on the current policies of the other agents without error, they should also be classified as joint-action space learners. This is interesting because originally, the deterministic learning dynamics were derived from a set of independent temporal-difference learning algorithms.

Bounded rationality
We can use those deterministic dynamics for a boundedly rational account of game theory in two ways. First, added cognitive costs and second, agents no longer assume that other agents behave rationally.
First, the idea to model a cognitive cost of computation through a Boltzman softmax function is nothing new [4,115]. Yet, I have shown that the Boltzman softmax function can originate from the need to regulate the exploration-exploitation trade-off in a decision-making situation under uncertainty. To unify both perspectives, bounded rationality and decision-making under uncertainty, the corresponding parameter b might be called the ecological rationality parameter. Generally, the study of ecological rationality uncovers the conditions of how computationally bounded minds use simple heuristics and produce accurate decisions by exploiting the structures of information in uncertain environments [100]. Thus, on a high level of abstraction, the exploration-exploitation trade-off justifies bounded rational decision-making and explains why it can be beneficial in decision-making contexts under uncertainty. The best choice of the ecological rationality b depends on the environment. In this sense, multi-agent learning dynamics can serve also as a highlevel theory of ecological rationality.
Second, the classic solution to a game in the form of a Nash equilibrium requires the assumptions that all agents behave fully rational and have complete information about rewards and environmental transitions. Thus, all agents assume all other agents to behave rationally as well. In contrast, the deterministic learning equations use only the other agents' current policy to update their own policy. As a result, learning behavior emerges in policy space, instead of game-equilibrium points. Such learning dynamics help overcome the game-equilibrium selection problem, if more than one such equilibrium exists.
In combination, learning dynamics with full cognitive rationality, i.e. the extreme case of b ! 1 (under ab ¼ 1), the deterministic dynamics approach the alternative replicator dynamics in discrete time. For the replicator dynamics, the folk theorem of evolutionary game theory connects dynamic equilibria to game-theoretic equilibria. Stable rest points of the dynamics correspond to Nash equilibria of the game. However, this only works because the deterministic dynamics learn as if they have a perfect model of the environment and the other agent's current policy and thus, they are not required to explore the environment with some finite b. Additionally, with temporal-difference learning we are not restricted to normalform games. Instead, the more general form of stochastic games allows us to investigate the interactions of multiple agents within a changing environment [9,47].
This account of boundedly rational game theory can also be embedded within the framework of cognitive levels of analysis ( Table 1). The stochastic game corresponds to the upper level of the computational problem that is posed to the agents. Typically, it is assumed that agents have perfect information about their environment, assume that all other agents behave rationally as well, require no cognitive cost of computation and thus find some static equilibrium. The learning dynamics correspond to an algorithmic level with a high level of abstraction. Here, agents are assumed to have a perfect model of the environment and of the other agents current policy. Cognitive costs are included in the model and tunable by the parameter b. The outcome is a deterministic dynamic learning trajectory which is not necessarily converging to a rest point. The proposed learning algorithm corresponds to an algorithmic level of lower abstraction. Agents require no knowledge about the environment in advance. They learn a model of the environment and the other agents current policy through repeated interactions with the environment and each other under the same policy. The cognitive costs of computing this model are immense and dealing with the explorationexploitation is required. As a result, the agents' learning is stochastic.

Future work and potential applications
The proposed algorithm is not resource-efficient at all. In fact, the computational costs are infinite to match the deterministic learning dynamics exactly. Future work is needed to advance the link between the deterministic learning dynamics and more data-efficient algorithms toward resource-rational analysis. A natural start to do so is to not erase all collected experience after a policy update and instead start from the current reward and transition model. The equations need to be extended to account for imperfect models by adding suitable noise terms to the temporal-difference error, building upon previous work on stateless learning dynamics [32]. Thereby, it is important to investigate the conditions influencing the rate of convergence of the temporal-difference error. The convergence quality surely must depend on the environmental dynamics. State that are visited rarely will correspond to increased noise.
Potential applications. The improved insights about the connections between different analysis levels may have potential use with respect to the following application domains.
Hyper-parameter tuning. How does the quality and dynamics depend on hyper-parameters of the algorithm and features of the environment? For example, the size of the memory buffer in experience replay needs careful tuning [118]. A noisy version of the replicator reinforcement learning dynamics may shed light on the principles for determining decent batch sizes that can be translated to learners in complex environments.
Design of new algorithms. Can we reduce the number of hyper-parameters by replacing them through sensible functional relationships? For example, an inexperienced agent should explore more than an experienced one. The level of experience of an agent should also depend on the discount factor. An agent with a small outlook on the future should exploit faster than an agent who values the future more. Future work may investigate and formalize those verbal principles and convert its findings into novel algorithms. Based on this work, these algorithms can be deployed and tested both on the idealized process level of replicator reinforcement learning dynamics as well as on the concrete process model of reinforcement learning algorithms. Additionally, extensions to the basic reinforcement learning update scheme, such as leniency [81] and Win-or-Learn-Fast (WoLF) [16], could be rapidly prototyped on the idealized process level and then converted to the concrete process algorithms.
Analysis of strategic interactions. How do hyper-parameter combinations affect the resulting collective incentive structure in relation to features of the environment? For example, in previous work, we found that a sufficiently large discount factor can change a tragedy of the commons into a comedy of the commons where the mutually beneficial cooperative action dominates, given a potential environmental threat is sufficiently severe [9]. We must assume that this found principle also conveys to more complex environments. An interesting area for future work is to study the influence of the batch size in relation to the other hyper-parameters on the emerging incentive structure.
Modeling of social dynamics. Related to the analysis of strategic interactions, replicator reinforcement learning dynamics are of potential use in models of social dynamics that apply evolutionary game theory to human social phenomena [2,25,46,69,73,85,108,110]. Methodologically, the use of evolutionary game theory can be seen as a middle ground between the highly formal classic game theoretic equilibrium analyses and more open agent-basedmodeling approaches. It has been justified either as as a theoretical tool to identify robust behavioral policies or as model of social imitation learning. This work provides a third interpretation for studying social dynamics. Reinforcement learning agents learn on their own in a boundedly rational fashion. This interpretation might be valuable especially when a social learning interpretation might not be justifiably from the modeling context.

Conclusion
Evolutionary game theory is a fruitful framework to enhance the interpretability of multi-agent learning systems. In this work, I have enhanced the interpretability of the link between evolutionary game theory and reinforcement learning itself.
Conceptually, I have embedded replicator reinforcement learning dynamics into different levels of cognitive analysis. Doing so allowed me to investigate the connections between the dynamical systems level to the computational level and algorithmic levels of lower abstraction. I have found that temporal-difference replicator reinforcement learning dynamics follow a principle of minimum free energy and combines a boundedly rational account to game equilibria in stochastic games with decision-making under uncertainty. I have introduced a sample-batch algorithm and showed that it serves as a micro-foundation for the replicator reinforcement learning equation. The algorithm combines memory-batch learning with separated state-action value estimation. The learning trajectories of the algorithm matches the ones of the equation under a large memory-batch, which I have empirically shown across two classes of environments.
Taken together, the classification for replicator reinforcement learning dynamics must be revised. Although originally derived from independent, model-free temporaldifference reinforcement learning algorithms, replicator reinforcement learning dynamics should be classified as model-based, joint-action learners. They use a perfect model of the environment and the other agents' current policies balancing the rewards from the environment with the exploration-exploitation costs of cognition.
Funding This work was supported by UK Research and Innovation Future Leaders Fellowship MR/S032525/1.

Declarations
Conflict of interest The author declares that he has no conflict of interest.
Code availability Python code to generate all reported results is available at Zenodo (https://doi.org/10.5281/zenodo.4982727) and GitHub (https://github.com/wbarfuss/CognitiveLevels). Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons. org/licenses/by/4.0/.