Next Article in Journal
Multicriteria Decision Making and Water Infrastructure: An Application of the Analytic Hierarchy Process for a Sustainable Ranking of Investments
Previous Article in Journal
A Novel DFA on AES: Based on Two–Byte Fault Model with Discontiguous Rows
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Exploring the Use of Invalid Action Masking in Reinforcement Learning: A Comparative Study of On-Policy and Off-Policy Algorithms in Real-Time Strategy Games

1
Air Traffic Control and Navigation School, Air Force Engineering University, Xi’an 710051, China
2
Shaanxi Key Laboratory of Meta-Synthesis for Electronic and Information System, Air Force Engineering University, Xi’an 710051, China
3
Xi’an Research Institute of High-Technology, Xi’an 710051, China
*
Author to whom correspondence should be addressed.
Appl. Sci. 2023, 13(14), 8283; https://doi.org/10.3390/app13148283
Submission received: 2 June 2023 / Revised: 13 July 2023 / Accepted: 17 July 2023 / Published: 18 July 2023
(This article belongs to the Section Robotics and Automation)

Abstract

:
Invalid action masking is a practical technique in deep reinforcement learning to prevent agents from taking invalid actions. Existing approaches rely on action masking during policy training and utilization. This study focuses on developing reinforcement learning algorithms that incorporate action masking during training but can be used without action masking during policy execution. The study begins by conducting a theoretical analysis to elucidate the distinction between naive policy gradient and invalid action policy gradient. Based on this analysis, we demonstrate that the naive policy gradient is a valid gradient and is equivalent to the proposed composite objective algorithm, which optimizes both the masked policy and the original policy in parallel. Moreover, we propose an off-policy algorithm for invalid action masking that employs the masked policy for sampling while optimizing the original policy. To compare the effectiveness of these algorithms, experiments are conducted using a simplified real-time strategy (RTS) game simulator called Gym- μ RTS. Based on empirical findings, we recommend utilizing the off-policy algorithm for addressing most tasks while employing the composite objective algorithm for handling more complex tasks.

1. Introduction

Reinforcement Learning (RL) has attracted tremendous attention due to its human-level performance in challenging decision-making tasks [1,2,3,4]. However, in some more complex tasks, such as real-time strategy (RTS) games [5,6,7] and multiplayer online battle arena (MOBA) games [8,9,10], the action spaces are high-dimensional, and partial actions are usually invalid in some specific states. For instance, executing a skill on cool-down or buying an item exceeding existing gold will not be allowed. The action availability usually depends on the current state (e.g., skill cool-down finished or having enough gold). It is impractical to design variable action spaces for different states [11]. Therefore, finding an effective way to prevent the agent from choosing invalid actions is significant [12,13,14].
A common approach, called invalid action penalty, assigns a negative reward if the agent takes an invalid action so that the agent learns to avoid invalid actions by minimizing the expected penalty [15,16]. However, this technique cannot prevent the agent from taking invalid actions and can hardly scale on complex tasks [17,18]. An alternative method, action space shaping, works by reducing the full discrete action space to a simpler action space [19], which typically involves non-useful action removals and discretization of continuous action space. However, the tuning of action space shaping has been found to be challenging, and it can occasionally hinder the agent’s ability to successfully accomplish desired tasks [20]. Another popular technique is invalid action masking, which filters invalid actions by setting the probability of all invalid actions to near zero [7,8,9]. This technique ensures the agent can avoid selecting impossible or unavailable actions during training. In addition, it reduces the dimension of exploration space and improves exploration efficiency. Invalid action masking has been widely applied to many domains besides RTS or MOBA games, such as traffic signal control [21], unmanned vehicle [22], adaptive voltage control [12], etc.
Huang et al. [23] provides a closer look at invalid action masking for the first time, categorizing it into two types, invalid action policy gradient (utilizing the masked policy for gradient calculation) and naive invalid action policy gradient (utilizing the original policy for gradient calculation). Through a numerical example, it demonstrates that invalid action masking alters the policy gradient and that the invalid action policy gradient corresponds to a valid policy gradient. In addition, it is noted that employing the naive invalid action policy gradient may lead to instability. However, empirical results in [23] show that naive invalid action masking can outperform the invalid action policy gradient when the masking is removed. This finding challenges the existing theoretical analysis in [23], which has inspired our interest in understanding the mechanism behind naive invalid action masking.
Inspired by aforementioned analysis, this study provides a theoretical analysis and reveals why naive invalid action masking is an effective way to train the agent to avoid invalid actions explicitly. Specifically, the regular invalid action masking is to replace the logits of invalid actions with a large negative number [23], which we call logit-level masking. To derive the policy gradient, we present a novel masking called action-level masking. We prove that two types of masking are equivalent so that the conclusions derived by one also apply to another. We utilize the action-level masking to verify that invalid action masking indeed changes the policy gradient. More interestingly, we find that the difference between naive invalid action policy gradient and invalid action policy gradient is a state-dependent factor that directly impacts the probabilities associated with invalid actions. Based on this, we prove that the naive invalid action policy gradient (taking the masked policy as behavior policy and using the original policy to calculate the gradient) is actually a valid gradient that concurrently optimizes the masked policy and the original policy. From this conclusion, we design a Composite Objective Invalid Action Masking (CO-IAM) algorithm that concurrently optimizes the masked policy and reduces the probabilities of invalid actions. Furthermore, we present on-policy and off-policy algorithms for Invalid Action Masking, called On-PIAM and Off-PIAM, respectively. The On-PIAM algorithm aims to optimize the performance of the masked policy, which is the same as that of the invalid action policy gradient in [23]. The Off-PIAM adopts the Importance Sampling (IS) technique and optimizes the original policy. The main contributions of this paper are summarized as follows:
  • We introduce the concept of action-level masking, which is proven to be equivalent to logit-level masking. The theoretical analysis based on action-level masking demonstrates that the difference between the invalid action policy gradient and the naive invalid action policy gradient is a state-dependent gradient that impacts the probability distribution of invalid actions. This contributes to a better understanding of the impact of invalid action masking on gradients.
  • We prove that the naive policy gradient is indeed a valid gradient that optimizes both the masked policy and original policy concurrently. Although this is a counter-intuitive conclusion, it ensures that we can directly use the naive policy gradient for training without causing instability. In addition, we also propose an off-policy algorithm for invalid action masking that focuses on optimizing the original policy.
  • We conduct experiments based on the Gym- μ RTS platform [24] to compare the performance of the proposed algorithms and invalid action penalty. The results show that Off-PIAM outperforms other algorithms even if the masking is removed, and CO-IAM scales well on complex tasks. Based on these findings, we conclude that the Off-PIAM algorithm is suitable for addressing most tasks, while the CO-IAM algorithm is well-suited for handling more complex tasks.

2. Background

2.1. Reinforcement Learning

Consider a standard reinforcement learning problem in which an agent interacts with a stochastic environment and attempts to maximize cumulative reward [25]. The stochastic environment is formalized by a Markov Decision Process (MDP), which is denoted as the tuple M = S , A , P , ρ , R , γ , a state space S , an action space A , a transition probability distribution P : S × A × S [ 0 , 1 ] , an initial state distribution ρ : S [ 0 , 1 ] , a reward function R : S × A R , and a discount factor γ [ 0 , 1 ) . Without prior knowledge about the transition probability distribution, the agent utilizes its policy π θ to collect a trajectory τ = { s 0 , a 0 , r 0 , s 1 , a 1 , r 1 , } for training. The agent improves its policy π θ to maximize the expected discounted return for each episode
J π θ = E s 0 ρ , a t π θ , s t + 1 P ( · | s t , a t ) t = 0 H γ t r t ,
where r t = R s t , a t , and H is the maximal length of one episode. The fundamental result underlying this problem is the Policy Gradient Theorem [25], which derives the policy gradient θ J π θ with respect to the policy parameter θ . Executing gradient ascent θ θ + θ J π θ results in policy improvement and maximizes the expected discounted return. The policy gradient estimate is
g = E τ π θ t = 0 H θ log π θ a t | s t G t ,
where G t = t = t H γ t t r t is the discounted return for a trajectory following step t. The General Advantage Estimation (GAE) technique [26] is proposed to reduce the variance of the policy gradient estimate at the cost of some bias
g ^ = E τ π θ t = 0 H θ log π θ a t | s t A ^ t ,
where A ^ t is a GAE estimator of the advantage function [26]. The policy gradient algorithm requires on-policy trajectory for training (i.e., the target policy and behavior policy should be consistent).

2.2. Logit-Level Masking

In typical deep reinforcement learning algorithms, a neural network is commonly used to represent the policy. In the case of a discrete action space, the action probability distribution is produced by implementing the Softmax operation on the output logits of the neural network, which is the framework we will assume in the rest of the paper.
Invalid action masking is a practical technique in deep reinforcement learning to prevent the agent from taking impossible or unavailable actions. The most popular way for invalid action masking is to replace the logits of invalid actions with negative infinity (or a large negative number in practice) [23], which we call logit-level masking. Logit-level masking works by applying a state-dependent masking function m ( · | s ) when calculating action probability distribution [23], as shown in Figure 1.
Specifically, let us define an MDP with the state space S and the discrete action space A = { a 1 , a 2 , , a n } , where n is the number of discrete actions. The policy π θ is parameterized by parameters θ of the neural network. Taking any state s S as input, the output logits of the neural network are represented by l θ ( · | s ) = [ l θ ( a 1 | s ) , l θ ( a 2 | s ) , , l θ ( a n | s ) ] . The logit-level masking function is defined as
m l θ ( a i | s ) = l θ ( a i | s ) if a i is valid in s , if a i is invalid in s .
Then, we can obtain the re-normalized action probability distribution π θ m ( · s ) by implementing the Softmax operation on the masked logits
π θ m ( · s ) = Softmax ( m l θ ( · | s ) ) = exp ( m l θ ( a 1 | s ) ) a i A exp ( m l θ ( a i | s ) ) , , exp ( m l θ ( a n | s ) ) a i A exp ( m l θ ( a i | s ) ) .
Since the values of logits associated with invalid actions are , the sample probabilities of invalid actions are zero as lim l exp ( l ) = 0 .

3. Invalid Action Masking

This section proposes a novel paradigm for invalid action masking, called action-level masking. Compared with logit-level masking, the key benefit of action-level masking is its suitability for conducting theoretical analyses of action masking. Furthermore, we verify the equivalence of logit-level masking and action-level masking. Thus, the conclusions derived by Huang et al. [23] are also applicable to action-level masking.

3.1. Action-Level Masking

Different from logit-level masking, action-level masking works by replacing the action probability of invalid actions to be masked by zero and re-normalizing the action probability distribution (see Figure 2).
Taking any state s S as input, the original policy π θ outputs the action probability distribution [ π θ ( a 1 | s ) , π θ ( a 2 | s ) , , π θ ( a n | s ) ] , where
π θ ( a i | s ) = exp ( l θ ( a i | s ) ) a j A exp ( l θ ( a j | s ) ) .
The action-level masking function ϖ ( · | s ) is a state-dependent binary function
ϖ ( · | s ) = [ ϖ ( a 1 | s ) , ϖ ( a 2 | s ) , , ϖ ( a n | s ) ] , where ϖ ( a i | s ) = 1 , if a i is valid in s , 0 , if a i is invalid in s .
Then, we can re-normalize the Hadamard product of the original policy and action-level masking function and obtain the masked policy
π θ ϖ ( · | s ) = Normalize π θ ( · | s ) ϖ ( · | s ) = π θ ( a 1 | s ) ϖ ( a 1 | s ) a i A π θ ( a i | s ) ϖ ( a i | s ) , , π θ ( a n | s ) ϖ ( a n | s ) a i A π θ ( a i | s ) ϖ ( a i | s ) .
We assume that for any state s S , at least one action in the action space should be valid (i.e., a i A ( ϖ ( a i | s ) ) 0 , s S ). However, it is important to note that this assumption may not hold true in certain scenarios, such as when a passive unit is surrounded from all sides. To address this, we propose incorporating a no-operation action into the action space so that at least one action is always legal in any given state. The sample probability of any invalid action a inv is zero since the corresponding value of the action-level masking function ϖ ( a inv | s ) is equal to zero. We design action-level masking because it is conducive to the theoretical analysis of the policy gradient algorithm.

3.2. Equivalence Verification

This section will be concerned with verifying the equivalence of logit-level masking and action-level masking, based on which the conclusions derived by Huang et al. [23] are also applicable to action-level masking. The equivalence holds if two types of invalid action masking satisfy that:
π θ m ( a | s ) = π θ ϖ ( a | s ) , s S , a A .
For any state s S , the action space can be divided into two parts, valid action space A v ( s ) and invalid action space A inv ( s ) . We have:
A = A v ( s ) A inv ( s ) , A v ( s ) A inv ( s ) = .
According to (5), for any valid action a v A v ( s ) , the action probability of the logit-level masked policy is:
π θ m ( a v | s ) = exp ( m l θ ( a v | s ) ) a i A exp ( m l θ ( a i | s ) ) = exp ( m l θ ( a v | s ) ) a i A v exp ( m l θ ( a i | s ) ) + a j A inv exp ( m l θ ( a j | s ) ) = exp ( l θ ( a v | s ) ) a i A v exp ( l θ ( a i | s ) )
According to (8), for any valid action a v A v ( s ) , the action probability of the action-level masking policy is:
π θ ϖ ( a v | s ) = π θ ( a v | s ) ϖ ( a v | s ) a i A π θ ( a i | s ) ϖ ( a i | s ) = π θ ( a v | s ) a i A v ( s ) π θ ( a i | s ) = exp ( l θ ( a v | s ) ) a j A exp ( l θ ( a j | s ) ) exp ( l θ ( a v | s ) ) a j A exp ( l θ ( a j | s ) ) a i A v exp ( l θ ( a i | s ) ) a j A exp ( l θ ( a j | s ) ) a i A v ( s ) exp ( l θ ( a i | s ) ) a j A exp ( l θ ( a j | s ) ) = exp ( l θ ( a v | s ) ) a i A v ( s ) exp ( l θ ( a i | s ) )
In light of (11) and (12), one has:
π θ m ( a v | s ) = π θ ϖ ( a v | s ) , s S , a v A v ( s ) .
Obviously, the probabilities of invalid actions of both policies are equal to zero:
π θ m ( a inv | s ) = π θ ϖ ( a inv | s ) = 0 , s S , a inv A inv ( s ) .
Combining (13) with (14), we obtain that:
π θ m ( a | s ) = π θ ϖ ( a | s ) , s S , a A .
Thus, logit-level masking and action-level masking are equivalent. This is a significant result because it shows that the conclusions of logit-level masking [23] also apply to action-level masking. It is important to note that the substitution of negative infinity with a significantly negative value may introduce minor rounding errors. However, these errors do not impact the overall equivalence. While both action-level masking and logit-level masking are practically equivalent, action-level masking enables the explicit derivation of policy gradients, whereas logit-level masking does not. In the following, action-level masking is used to derive the policy gradient algorithm for invalid action masking.

3.3. Masking Changes Policy Gradient

This section focuses on the impact of invalid action masking on policy updates. Huang et al. [23] designed a numerical example to illustrate that the gradient generated by invalid action masking differs from the naive policy gradient. As a supplement, we further investigate this finding and reveal the difference between the naive policy gradient and the invalid action masking policy gradient.
In regular policy-based algorithms, the original policy π θ is employed to collect samples and calculate the policy gradient using the policy gradient theorem [25]. To avoid invalid actions, we apply the invalid action masking to the policy π θ , resulting in a masked policy denoted as π θ ϖ . The straightforward approach to policy updating is the direct utilization of the original policy gradient, called naive policy gradient:
g naive = E τ π θ ϖ t = 0 H θ log π θ a t | s t A ^ t .
The naive policy gradient is intuitively improper because the policy gradient algorithm is an on-policy algorithm, but the target policy ( π θ ) and behavior policy ( π θ ϖ ) are different. Huang et al. [23] proposed the invalid action policy gradient, which is the policy gradient for the masked policy π θ ϖ
g mask = E τ π θ ϖ t = 0 H θ log π θ ϖ a t | s t A ^ t .
The distinction between the two policy gradients lies in different target policies for log probability calculation. Next, we provide a theoretical analysis to reveal the difference between the naive policy gradient (16) and invalid action policy gradient (17).
Theorem 1. 
Consider a masked policy π θ ϖ produced by applying invalid action masking to the original policy π θ . The difference between the naive policy gradient (16) and invalid action policy gradient (17) is a state-dependent gradient
g mask g naive = E τ π θ ϖ t = 0 H A ^ t I ( s t ; θ ) a i A inv ( s t ) θ π θ ( a i | s t )
where I ( s t ; θ ) = a j A v ( s t ) π θ ( a j | s t ) .
Proof of Theorem 1. 
According to (8), the gradient item in g mask can be written as:
θ log π θ ϖ ( a t | s t ) = θ log π θ ( a t | s t ) ϖ ( a t | s t ) a i A π θ ( a i | s t ) ϖ ( a i | s t ) .
Since a t is sampled from the masked policy π θ ϖ , a t must be a valid action, and ϖ ( a t | s t ) = 1 . Then, the gradient item (19) can be written as:
θ log π θ ϖ ( a t | s t ) = θ log π θ ( a t | s t ) a i A π θ ( a i | s t ) ϖ ( a i | s t ) = θ log π θ ( a t | s t ) θ log a i A π θ ( a i | s t ) ϖ ( a i | s t ) = θ log π θ ( a t | s t ) θ a i A π θ ( a i | s t ) ϖ ( a i | s t ) a j A π θ ( a j | s t ) ϖ ( a j | s t )
Since θ a i A π θ ( a i | s t ) = θ 1 = 0 , (20) is written as:
θ log π θ ϖ ( a t | s t ) = θ log π θ ( a t | s t ) + a i A θ π θ ( a i | s t ) ( 1 ϖ ( a i | s t ) ) a j A π θ ( a j | s t ) ϖ ( a j | s t ) .
According to the definition of masking function (7), we have 1 ϖ ( a i | s t ) = 0 , a i A v ( s t ) and ϖ ( a i | s t ) = 0 , a i A inv ( s t ) . Substituting the above equation into (21), we obtain that
θ log π θ ϖ ( a t | s t ) = θ log π θ ( a t | s t ) + a i A inv ( s t ) θ π θ ( a i | s t ) a j A v ( s t ) π θ ( a j | s t ) = θ log π θ ( a t | s t ) + 1 I ( s t ; θ ) a i A inv ( s t ) θ π θ ( a i | s t ) ,
where I ( s t ; θ ) = a j A v ( s t ) π θ ( a j | s t ) . Substituting (22) into (17), we obtain that
g m a s k = E τ π θ ϖ t = 0 H θ log π θ ( a t | s t ) + 1 I ( s t ; θ ) a i A inv ( s t ) θ π θ ( a i | s t ) A ^ t = g n a i v e + E τ π θ ϖ t = 0 H A ^ t I ( s t ; θ ) a i A inv ( s t ) θ π θ ( a i | s t )
This completes the Proof of Theorem 1.    □
Theorem 1 illustrates that the gradient produced by invalid action masking differs from the naive policy gradient. Specifically, the residual item is the sum of gradients corresponding to invalid actions.
The experimental results derived by Huang et al. [23] show that once the masking is removed, the performance of the original policy π θ will be unstable. We infer that the residual item in the invalid action policy gradient results in the poor performance of the original policy. In the rest of this paper, we propose a novel algorithm for invalid action masking based on Theorem 1.

4. Practical Algorithms for Action Masking

Invalid action masking transforms the original policy ( π θ ) into the masked policy ( π θ ϖ ), which is used to collect samples. The policy gradient algorithm is an on-policy algorithm where the target policy and behavior policy should be consistent. Intuitively, the naive policy gradient is improper because the behavior policy ( π θ ϖ ) is different from the target policy ( π θ ). The design of algorithms depends on which policy we expect to optimize.
This section lists three policy gradient algorithms for invalid action masking, the On-Policy Invalid Action Masking (On-PIAM) algorithm [23], the Off-Policy Invalid Action Masking (Off-PIAM) algorithm, and the Composite Objective Invalid Action Masking (CO-IAM) algorithm.
Each algorithm utilizes the masked policy to sample but optimize different policies. The On-PIAM algorithm optimizes the performance of the masked policy ( π θ ϖ ), while the Off-PIAM algorithm optimizes the original policy ( π θ ). The CO-IAM algorithm optimizes the masked policy ( π θ ϖ ) and the original policy ( π θ ) in parallel. Before introducing these algorithms, we first provide a brief summary of the above algorithms in Table 1.

4.1. On-Policy Algorithm

In the On-Policy Invalid Action Masking (On-PIAM) algorithm [23], the target and behavior policies are both masked policies ( π θ ϖ ). Since π θ ϖ is differentiable to its parameters θ , the policy gradient algorithm can be directly applied to train π θ ϖ :
θ J ( π θ ϖ ) = E τ π θ ϖ t = 0 H θ log π θ ϖ a t | s t A ^ t .
To train the agent more robustly, we can take Proximal Policy Optimization (PPO) algorithm [27] as the training algorithm:
L On - P C L I P ( θ ) = E τ π θ ϖ min r t ϖ ( θ ) A ^ t , clip r t ϖ ( θ ) , ϵ A ^ t ,
where r t ϖ ( θ ) = π θ ϖ a t | s t π θ old ϖ a t | s t , and clip ( r , ϵ ) = 1 + ϵ , r > 1 + ϵ r , 1 ϵ r 1 + ϵ 1 ϵ , r < 1 ϵ .
During training, the agent also maximizes the policy’s entropy to encourage exploration. We combine these optimization terms and obtain the following optimization objective
L On - P P P O ( θ ) = L On - P C L I P ( θ ) + c e H ( π θ ϖ ) .
where H ( · ) is an entropy bonus and c e is a coefficient for the entropy item.
After the training, we obtain a trained policy π θ ϖ rather than π θ . Note that we cannot remove the masking when using the policy because the target policy is the masked policy π θ ϖ .

4.2. Off-Policy Algorithm

In the Off-Policy Invalid Action Masking (Off-PIAM) algorithm, we treat π θ ϖ as the behavior policy, and we still optimize the original policy ( π θ ). We can adapt the Importance Sampling (IS) technique to derive an unbiased estimator of a policy gradient that relies on off-policy trajectories. This is known as an off-policy policy gradient [28]. The gradient of J ( π θ ) corresponding to its parameter θ is [29]:
θ J ( π θ ) = E τ π θ old ϖ t = 0 H π θ a t | s t π θ old ϖ a t | s t t = 0 H θ log π θ a t | s t A ^ t .
Even though the above policy gradient is unbiased, the product of the important sampling ratio results in high variance [30]. We can clip the gradient the same way as PPO [27,31]:
L Off - P C L I P ( θ ) = E τ π θ old ϖ min r t IS ( θ ) A ^ t , clip r t IS ( θ ) , ϵ A ^ t ,
where r t IS ( θ ) = π θ a t | s t π θ old ϖ a t | s t .
By adding the entropy item, the optimization objective is:
L Off - P P P O ( θ ) = L Off - P C L I P ( θ ) + c e H ( π θ ϖ ) .
Different from the On-PIAM algorithm, the Off-PIAM algorithm focuses on training the original policy π θ . After the training, the agent can work well even if we remove the masking. That is, the agent trained by the Off-PIAM algorithm explicitly learns to avoid invalid actions.

4.3. Composite Objective Algorithm

The On-PIAM algorithm aims to improve performance of the masked policy, and the Off-PIAM algorithm focuses on optimizing the original policy. A question naturally arises, can we optimize two policies concurrently? The solution is to design a composite objective, making a compromise between the performance of the masked policy and the original policy. In the following, we present the Composite Objective Invalid Action Masking (CO-IAM) algorithm, which is actually an on-policy algorithm with an auxiliary optimization objective. Inspired by Theorem 1, we design the composite optimization objective
L CO ( θ ) = J ( π θ ϖ ) c ϕ Φ ( π θ ) ,
where
J ( π θ ϖ ) = E s 0 ρ , a t π θ ϖ , s t + 1 P ( · | s t , a t ) t = 0 H γ t r t ,
Φ ( π θ ) = E τ π θ ϖ t = 0 H a i A inv ( s t ) π θ ( a i | s t ) .
The first objective item J ( π θ ϖ ) is the cumulative reward following the masked policy π θ ϖ . The second objective item Φ ( π θ ) is the cumulative probability sum of all invalid actions. c ϕ is the coefficient that balances two items.
The second objective item aims to reduce the probability of invalid actions when c ϕ > 0 . In short, the composite objective aims to optimize the cumulative reward and adjust the probability of invalid actions concurrently. Next, we derive the gradient of the composite objective:
θ L CO ( θ ) = θ J ( π θ ϖ ) c ϕ θ Φ ( π θ ) .
The gradient of the first objective item can be directly obtained according to the Policy Gradient Theorem [25]:
θ J ( π θ ϖ ) = E τ π θ ϖ t = 0 H θ log π θ ϖ a t | s t A ^ t .
The gradient of the second objective item is:
c ϕ θ Φ ( π θ ) = E τ π θ ϖ t = 0 H c ϕ a i A inv ( s t ) θ π θ ( a i | s t ) .
Inspired by Theorem 1, we set c ϕ = A ^ t / I ( s t ; θ ) and obtain that:
c ϕ θ Φ ( π θ ) = E τ π θ ϖ t = 0 H A ^ t I ( s t ; θ ) a i A inv ( s t ) θ π θ ( a i | s t ) .
Substituting (35) and (37) into (34), one has:
θ L CO ( θ ) = E τ π θ ϖ t = 0 H θ log π θ ϖ a t | s t A ^ t E τ π θ ϖ t = 0 H A ^ t I ( s t ; θ ) a i A inv ( s t ) θ π θ ( a i | s t ) = g mask E τ π θ ϖ t = 0 H A ^ t I ( s t ; θ ) a i A inv ( s t ) θ π θ ( a i | s t ) .
According to Theorem 1, we have:
g mask g naive = E τ π θ ϖ t = 0 H A ^ t I ( s t ; θ ) a i A inv ( s t ) θ π θ ( a i | s t )
In light of (16), (38) and (39), we obtain an interesting finding that the gradient of the composite objective is equal to the naive policy gradient:
θ L CO ( θ ) = g naive = E τ π θ ϖ t = 0 H θ log π θ a t | s t A ^ t .
In Section 3.3, we present that the naive policy gradient is intuitively improper because it is an on-policy algorithm, but the behavior policy is not consistent with the target policy. However, based on the above derivation, we obtain that the naive policy gradient is indeed a valid gradient because it is equivalent to the composite objective invalid action masking (CO-IAM) algorithm, which optimizes the masked policy and the original policy concurrently. Although this is a counter-intuitive conclusion, it ensures that we can directly use the naive policy gradient (16) for training without causing instability.
Based on the above discussion, we suggest directly replacing the CO-IAM algorithm with the naive policy gradient in practice. That is, we only need to use the masked policy for sampling without changing the structure of the policy gradient algorithm. Similarly, we can employ PPO as the training algorithm:
L CO C L I P ( θ ) = E τ π θ ϖ min r t CO ( θ ) A ^ t , clip r t CO ( θ ) , ϵ A ^ t ,
where r t CO ( θ ) = π θ a t | s t π θ old a t | s t .
By adding the entropy item, the optimization objective is:
L CO P P O ( θ ) = L CO C L I P ( θ ) + c e H ( π θ ϖ ) .
The value functions of all algorithms are updated by the squared error loss [27], which is not listed in the optimization objectives.

5. Empirical Analysis

We evaluate how well the proposed algorithms deal with invalid actions using the Gym- μ RTS environment [24]. It is a perfect testbed for our experiments because the space of invalid actions increases exponentially with the map size. We take four maps with different sizes for experiments (see Figure 3), and the environment setup is the same as Huang et al. [23].
In the Gym- μ RTS environments, an agent attempts to control the unit at the top left of the map to harvest resources as fast as possible. The agent receives a reward + 1 when the unit harvests a resource or returns a resource to the base. The action space is designed as the MultiDiscrete action space [19]. A composite action comprises eight discrete actions, Source Unit, Action Type, Move Parameter, Harvest Parameter, Return Parameter, Produce Direction Parameter, Produce Type Parameter, and Attack Target Unit. The first component is the location of the selected unit to perform an action. Since only the worker and base can be selected as Source Unit, selecting other grids on the map are usually invalid. This action space enables us to verify the scalability of invalid action masking.
We will compare On-PIAM, Off-PIAM, and CO-IAM algorithms on different maps. We further evaluate the performance of original policies with Masking Removed (i.e., On-PIAM-MR, Off-PIAM-MR, and CO-IAM-MR). To illustrate the superiority of invalid action masking, we also compare it with the invalid action penalty, which assigns a negative reward r inv = { 0.01 , 0.1 } for choosing an invalid action (called Penalty-0.01 and Penalty-0.1). All the agents are trained for 1,000,000 time steps, and the maximal length of each episode is 200 iteration steps. All experiments were run with four random seeds.

5.1. Evaluation Metrics

Drawing from Huang et al. [23], we employ six metrics to measure our algorithms’ performance. Specifically, r episode is the episode return. a null is the number of actions that select an invalid Source Unit. a busy is the number of actions that select a Source Unit that is executing other actions. a owner is the number of actions that select a Source Unit that does not belong to the agent. t first is the percentage of the total time steps that it takes for the agent to obtain the first positive reward. t solve is the percentage of the total time steps that it takes for the episode return to exceed 40.

5.2. Results

The experimental results are presented in Figure 4 and Figure 5 and Table 2. Here, we provide some important observations.
Invalid action penalty is not a robust way to prevent the agent from taking invalid actions. In Figure 4, we observe that Penalty-0.01 achieves more than 30 rewards in 4 × 4 and 10 × 10 maps. It even surpasses On-PIAM in the 4 × 4 map but can hardly extend to other maps. Further, the performance of Penalty-0.1 is obviously worse than Penalty-0.01. However, Table 2 shows that a null , a busy , and a owner of Penalty-0.1 is better than Penalty-0.01. It demonstrates that the larger penalty causes lower probabilities of invalid actions, but it fails to obtain more positive rewards. Thus, we have to make more efforts to tune the value of the negative reward when we adopt the invalid action penalty.
On-PIAM solves all tasks within fewer time steps than Off-PIAM and CO-IAM, but it fails to achieve expected asymptotic performance. As shown in Table 2, On-PIAM’s t solve is roughly 3% to 7% and very similar across different map sizes. However, we can observe that the episode return of On-PIAM achieves 34 on average, but Off-PIAM and CO-IAM achieve almost 40. The green curves in Figure 4 verify that the episode return curves of On-PIAM are not stable, and its asymptotic performance is worse than Off-PIAM and CO-IAM. Furthermore, Figure 5 shows that once the masking is removed, On-PIAM-MR only sightly works in 4 × 4 map and cannot obtain rewards on other maps. In Table 2, we also notice that On-PIAM-MR has larger probabilities of choosing a null and a owner . This is expected since On-PIAM aims to optimize the masked policy rather than the original policy.
CO-IAM outperforms On-PIAM and scales well on complex tasks. As shown in Figure 5 and Table 2, CO-IAM is better than On-PIAM with or without masking. When the masking is removed, the episode return of CO-IAM-MR still maintains roughly 30. It verifies our idea that although g naive seems to be an improper policy gradient, it indeed optimizes the masked policy and the original policy concurrently. CO-IAM’s t solve is better than Off-PIAM. In general, the performance of CO-IAM shows that CO-IAM seems to be a combination of On-PIAM and Off-PIAM. In the 24 × 24 map, CO-IAM obtains 37.2 rewards on average and outperforms Off-PIAM and On-PIAM. It demonstrates that CO-IAM has a better exploration ability to deal with complex tasks.
Off-PIAM achieves the best performance when the masking is removed. In Figure 5, and Table 2, we observe that Off-PIAM-MR obtains the better asymptotic performance than On-PIAM-MR and CO-IAM-MR. In addition, Off-PIAM also realizes the great performance during the training. Figure 4 shows that Off-PIAM surpasses other algorithms in 10 × 10 and 16 × 16 maps, and it achieves similar asymptotic performance to CO-IAM in other maps. It demonstrates that the masked policy of Off-PIAM can work well even if it focuses on optimizing the original policy. Moreover, the second row of Figure 4 shows the Kullback–Leibler (KL) divergence between the target policy and the current policy. The target policy of Off-PIAM is π θ , and the behavior policy is π θ ϖ . We can observe that the KL divergence of Off-PIAM is large at the beginning and gradually decreases during the training. That is, π θ and π θ ϖ become closer during the training, which illustrates that Off-PIAM guides the agent to explicitly learn to avoid invalid actions.

6. Conclusions

In this study, we compared the performance of three invalid action masking algorithms, On-PIAM, Off-PIAM, and CO-IAM. These algorithms optimize the masked policy, the original policy, and both policies, respectively. Our main contribution lies in the successful performance of the proposed Off-PIAM and CO-IAM algorithms when removing masking after training, while CO-IAM fails to work. Through our work, we have discovered several key findings. Firstly, while On-PIAM solves all tasks within fewer time steps, it fails to achieve the expected return when masking is removed. Secondly, we found that the naive policy gradient is equivalent to the CO-IAM algorithm, which optimizes the masked policy and the original policy in parallel. Thirdly, CO-IAM demonstrates superior performance compared to On-PIAM and scales well on complex tasks. Lastly, Off-PIAM outperforms other algorithms, regardless of whether masking is present or not. Based on our empirical findings, we recommend utilizing the Off-PIAM algorithm for addressing most tasks, as it consistently delivers strong performance. Additionally, the CO-IAM algorithm should be employed for handling more complex tasks. One limitation of this study is its focus on the effects of invalid action masking on RL agents in RTS games. Therefore, the findings cannot be generalized to all solutions, such as rule-based approaches or optimization-based approaches. As part of our future work, we would like to extend our experiments to include more complex game environments, such as StarCraft II, to assess the effectiveness and adaptability of our method in those settings.

Author Contributions

Conceptualization, X.L. and J.Z.; methodology, Y.H., Q.Y. and A.Y.; software, Y.H.; validation, Y.H. and A.Y.; formal analysis, Y.H., X.L. and J.Z.; investigation, Y.H. and N.W.; resources, Y.H.; data curation, Y.H. and A.Y.; writing—original draft preparation, Y.H. and Q.Y.; writing—review and editing, Y.H., Q.Y., A.Y. and N.W.; visualization, Y.H.; supervision, X.L.; project administration, X.L.; funding acquisition, J.Z. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the National Natural Science Foundation of China grant number 61703427.

Data Availability Statement

The online supplementary material is available at https://github.com/afeuhyq/invalid-action-masking (accessed on 16 July 2023), as well as all the metrics, logs, and recorded videos at https://wandb.ai/drhou/invalid-action-masking (accessed on 16 July 2023).

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Xu, Y.; Wei, Y.; Jiang, K.; Wang, D.; Deng, H. Multiple UAVs Path Planning Based on Deep Reinforcement Learning in Communication Denial Environment. Mathematics 2023, 11, 405. [Google Scholar] [CrossRef]
  2. Li, K.; Zhang, T.; Wang, R.; Wang, Y.; Han, Y.; Wang, L. Deep Reinforcement Learning for Combinatorial Optimization: Covering Salesman Problems. IEEE Trans. Cybern. 2022, 52, 13142–13155. [Google Scholar] [CrossRef]
  3. Mnih, V.; Kavukcuoglu, K.; Silver, D.; Rusu, A.A.; Veness, J.; Bellemare, M.G.; Graves, A.; Riedmiller, M.; Fidjeland, A.K.; Ostrovski, G.; et al. Human-level control through deep reinforcement learning. Nature 2015, 518, 529–533. [Google Scholar] [CrossRef]
  4. Song, J.; Luo, Y.; Zhao, M.; Hu, Y.; Zhang, Y. Fault-Tolerant Integrated Guidance and Control Design for Hypersonic Vehicle Based on PPO. Mathematics 2022, 10, 3401. [Google Scholar] [CrossRef]
  5. Liu, X.; Tan, Y. Attentive Relational State Representation in Decentralized Multiagent Reinforcement Learning. IEEE Trans. Cybern. 2022, 52, 252–264. [Google Scholar] [CrossRef] [PubMed]
  6. Liang, W.; Wang, J.; Bao, W.; Zhu, X.; Wu, G.; Zhang, D.; Niu, L. Qauxi: Cooperative multi-agent reinforcement learning with knowledge transferred from auxiliary task. Neurocomputing 2022, 504, 163–173. [Google Scholar] [CrossRef]
  7. Vinyals, O.; Ewalds, T.; Bartunov, S.; Georgiev, P.; Vezhnevets, A.S.; Yeo, M.; Makhzani, A.; Küttler, H.; Agapiou, J.; Schrittwieser, J.; et al. Starcraft II: A new challenge for reinforcement learning. arXiv 2017, arXiv:1708.04782. [Google Scholar]
  8. Berner, C.; Brockman, G.; Chan, B.; Cheung, V.; Debiak, P.; Dennison, C.; Farhi, D.; Fischer, Q.; Hashme, S.; Hesse, C.; et al. Dota 2 with large scale deep reinforcement learning. arXiv 2019, arXiv:1912.06680. [Google Scholar]
  9. Ye, D.; Liu, Z.; Sun, M.; Shi, B.; Zhao, P.; Wu, H.; Yu, H.; Yang, S.; Wu, X.; Guo, Q.; et al. Mastering complex control in moba games with deep reinforcement learning. In Proceedings of the AAAI Conference on Artificial Intelligence, New York, NY, USA, 7–12 February 2020; Volume 34, pp. 6672–6679. [Google Scholar]
  10. Csereoka, P.; Roman, B.I.; Micea, M.V.; Popa, C.A. Novel Reinforcement Learning Research Platform for Role-Playing Games. Mathematics 2022, 10, 4363. [Google Scholar] [CrossRef]
  11. Kalweit, G.; Huegle, M.; Werling, M.; Boedecker, J. Q-learning with Long-term Action-space Shaping to Model Complex Behavior for Autonomous Lane Changes. In Proceedings of the 2021 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), Prague, Czech Republic, 27 September–1 October 2021; IEEE: Piscataway, NJ, USA, 2021; pp. 5641–5648. [Google Scholar]
  12. Li, P.; Wei, M.; Ji, H.; Xi, W.; Yu, H.; Wu, J.; Yao, H.; Chen, J. Deep Reinforcement Learning-Based Adaptive Voltage Control of Active Distribution Networks with Multi-terminal Soft Open Point. Int. J. Electr. Power Energy Syst. 2022, 141, 108138. [Google Scholar] [CrossRef]
  13. Mercado, R.; Rastemo, T.; Lindelöf, E.; Klambauer, G.; Engkvist, O.; Chen, H.; Bjerrum, E.J. Graph networks for molecular design. Mach. Learn. Sci. Technol. 2021, 2, 25023. [Google Scholar] [CrossRef]
  14. Zhao, Z.; Wang, Q.; Li, X. Deep reinforcement learning based lane detection and localization. Neurocomputing 2020, 413, 328–338. [Google Scholar] [CrossRef]
  15. Zahavy, T.; Haroush, M.; Merlis, N.; Mankowitz, D.J.; Mannor, S. Learn what not to learn: Action elimination with deep reinforcement learning. Adv. Neural Inf. Process. Syst. 2018, 31. Available online: https://proceedings.neurips.cc/paper_files/paper/2018/file/645098b086d2f9e1e0e939c27f9f2d6f-Paper.pdf (accessed on 16 July 2023).
  16. Dietterich, T.G. Hierarchical reinforcement learning with the MAXQ value function decomposition. J. Artif. Intell. Res. 2000, 13, 227–303. [Google Scholar] [CrossRef] [Green Version]
  17. Tang, C.Y.; Liu, C.H.; Chen, W.K.; You, S.D. Implementing action mask in proximal policy optimization (PPO) algorithm. ICT Express 2020, 6, 200–203. [Google Scholar] [CrossRef]
  18. Yang, Q.; Zhu, Y.; Zhang, J.; Qiao, S.; Liu, J. UAV air combat autonomous maneuver decision based on DDPG algorithm. In Proceedings of the 2019 IEEE 15th international conference on control and automation (ICCA), Edinburgh, UK, 16–19 July 2019; IEEE: Piscataway, NJ, USA, 2019; pp. 37–42. [Google Scholar]
  19. Kanervisto, A.; Scheller, C.; Hautamäki, V. Action Space Shaping in Deep Reinforcement Learning. In Proceedings of the 2020 IEEE Conference on Games (CoG), Osaka, Japan, 24–27 August 2020; pp. 479–486. [Google Scholar] [CrossRef]
  20. Dulac-Arnold, G.; Evans, R.; Sunehag, P.; Coppin, B. Reinforcement Learning in Large Discrete Action Spaces. arXiv 2015, arXiv:1512.07679. [Google Scholar]
  21. Long, M.; Zou, X.; Zhou, Y.; Chung, E. Deep reinforcement learning for transit signal priority in a connected environment. Transp. Res. Part Emerg. Technol. 2022, 142, 103814. [Google Scholar] [CrossRef]
  22. Xiaofei, Y.; Yilun, S.; Wei, L.; Hui, Y.; Weibo, Z.; Zhengrong, X. Global path planning algorithm based on double DQN for multi-tasks amphibious unmanned surface vehicle. Ocean. Eng. 2022, 266, 112809. [Google Scholar] [CrossRef]
  23. Huang, S.; Ontañón, S. A Closer Look at Invalid Action Masking in Policy Gradient Algorithms. In Proceedings of the Thirty-Fifth International Florida Artificial Intelligence Research Society Conference, FLAIRS 2022, Jensen Beach, FL, USA, 15–18 May 2022. [Google Scholar] [CrossRef]
  24. Huang, S.; Ontañón, S.; Bamford, C.; Grela, L. Gym-μRTS: Toward Affordable Full Game Real-time Strategy Games Research with Deep Reinforcement Learning. In Proceedings of the 2021 IEEE Conference on Games (CoG), Copenhagen, Denmark, 17–20 August 2021; IEEE: Piscataway, NJ, USA, 2021; pp. 1–8. [Google Scholar]
  25. Sutton, R.S.; McAllester, D.; Singh, S.; Mansour, Y. Policy gradient methods for reinforcement learning with function approximation. Adv. Neural Inf. Process. Syst. 1999, 12, 1057–1063. [Google Scholar]
  26. Schulman, J.; Moritz, P.; Levine, S.; Jordan, M.; Abbeel, P. High-dimensional continuous control using generalized advantage estimation. arXiv 2015, arXiv:1506.02438. [Google Scholar]
  27. Schulman, J.; Wolski, F.; Dhariwal, P.; Radford, A.; Klimov, O. Proximal policy optimization algorithms. arXiv 2017, arXiv:1707.06347. [Google Scholar]
  28. Degris, T.; White, M.; Sutton, R.S. Off-policy actor-critic. arXiv 2012, arXiv:1205.4839. [Google Scholar]
  29. Levine, S.; Kumar, A.; Tucker, G.; Fu, J. Offline reinforcement learning: Tutorial, review, and perspectives on open problems. arXiv 2020, arXiv:2005.01643. [Google Scholar]
  30. Wang, Z.; Bapst, V.; Heess, N.; Mnih, V.; Munos, R.; Kavukcuoglu, K.; de Freitas, N. Sample efficient actor-critic with experience replay. arXiv 2016, arXiv:1611.01224. [Google Scholar]
  31. Huang, S.; Ontañón, S. Action guidance: Getting the best of sparse rewards and shaped rewards for real-time strategy games. arXiv 2020, arXiv:2010.03956. [Google Scholar]
Figure 1. The overview of logit-level masking. Logit-level masking calculates the action probability distribution by applying a state-dependent masking function m ( · | s ) to the output logits of the policy network. m ( · | s ) is a mapping that replaces the logits of invalid actions with a large negative number.
Figure 1. The overview of logit-level masking. Logit-level masking calculates the action probability distribution by applying a state-dependent masking function m ( · | s ) to the output logits of the policy network. m ( · | s ) is a mapping that replaces the logits of invalid actions with a large negative number.
Applsci 13 08283 g001
Figure 2. The overview of action-level masking. The action-level masking function ϖ ( · | s ) is a binary function where the values corresponding to invalid actions are zero. Action-level masking calculates the action probability by replacing invalid actions’ probabilities with zero and re-normalizing the probability distribution.
Figure 2. The overview of action-level masking. The action-level masking function ϖ ( · | s ) is a binary function where the values corresponding to invalid actions are zero. Action-level masking calculates the action probability by replacing invalid actions’ probabilities with zero and re-normalizing the probability distribution.
Applsci 13 08283 g002
Figure 3. Four screenshots of Gym- μ RTS with different map sizes. The grey circular units are workers. Green square grids are resource mines from where workers can extract resources to produce more units. White square grids are bases that can produce workers. We train agents to control units at the top left to harvest resources, and the units in the bottom right will remain stationary.
Figure 3. Four screenshots of Gym- μ RTS with different map sizes. The grey circular units are workers. Green square grids are resource mines from where workers can extract resources to produce more units. White square grids are bases that can produce workers. We train agents to control units at the top left to harvest resources, and the units in the bottom right will remain stationary.
Applsci 13 08283 g003
Figure 4. Comparison of CO-IAM, Off-PIAM, On-PIAM, Penalty-0.01, and Penalty-0.1 during training in different maps. The top four figures show the episode return over the time steps, and the remaining four show the Kullback–Leibler (KL) divergence between the target and current policy of PPO over the time steps. The lines are the average of all runs, and the shaded area is the standard deviation.
Figure 4. Comparison of CO-IAM, Off-PIAM, On-PIAM, Penalty-0.01, and Penalty-0.1 during training in different maps. The top four figures show the episode return over the time steps, and the remaining four show the Kullback–Leibler (KL) divergence between the target and current policy of PPO over the time steps. The lines are the average of all runs, and the shaded area is the standard deviation.
Applsci 13 08283 g004
Figure 5. Comparison of CO-IAM-MR, Off-PIAM-MR, and On-PIAM-MR which are evaluated without providing the mask. The lines are the average of all runs, and the shaded area is the standard deviation.
Figure 5. Comparison of CO-IAM-MR, Off-PIAM-MR, and On-PIAM-MR which are evaluated without providing the mask. The lines are the average of all runs, and the shaded area is the standard deviation.
Applsci 13 08283 g005
Table 1. Summary of On-PIAM, Off-PIAM, and CO-IAM algorithms.
Table 1. Summary of On-PIAM, Off-PIAM, and CO-IAM algorithms.
Algorithms Behavior Policy Target PolicyObjectivePolicy Gradient PPO Ratio
On-PIAM [23] π θ ϖ π θ ϖ J ( π θ ϖ ) Equation (23) r t ϖ ( θ ) = π θ ϖ a t | s t / π θ old ϖ a t | s t
Off-PIAM π θ ϖ π θ J ( π θ ) Equation (27) r t IS ( θ ) = π θ a t | s t / π θ old ϖ a t | s t
CO-IAM π θ ϖ π θ ϖ , π θ J ( π θ ϖ ) c ϕ Φ ( π θ ) Equation (40) r t CO ( θ ) = π θ a t | s t / π θ old a t | s t
Table 2. Results averaged over four random seeds.
Table 2. Results averaged over four random seeds.
AlgorithmsMap r episode a null a busy a owner t solve t first
CO-IAM 4 × 4 38.504.17%0.03%
10 × 10 39.305.46%0.04%
16 × 16 39.306.21%0.06%
24 × 24 37.2010.10%0.05%
Off-PIAM 4 × 4 39.984.57%0.04%
10 × 10 39.679.66%0.02%
16 × 16 39.559.16%0.04%
24 × 24 35.2016.15%0.04%
On-PIAM [23] 4 × 4 36.553.49%0.04%
10 × 10 35.404.50%0.02%
16 × 16 33.585.40%0.04%
24 × 24 31.857.09%0.04%
Penalty-0.01 4 × 4 39.3359.621.7019.386.01%0.07%
10 × 10 32.00108.820.124.6213.98%1.34%
16 × 16 8.8930.680.000.601.10%
24 × 24 11.44163.050.301.450.93%
Penalty-0.1 4 × 4 29.9718.550.785.8034.48%0.07%
10 × 10 0.000.000.000.003.74%
16 × 16 7.9727.720.280.751.29%
24 × 24 0.6494.700.220.880.57%
CO-IAM-MR 4 × 4 21.370.270.00152.590.03%
10 × 10 33.00131.890.000.010.04%
16 × 16 32.25133.340.000.000.06%
24 × 24 25.10149.110.000.150.05%
Off-PIAM-MR 4 × 4 39.889.5317.811.317.22%0.04%
10 × 10 39.339.864.561.5934.92%0.02%
16 × 16 38.6510.191.951.0125.91%0.04%
24 × 24 35.2315.905.970.180.04%
On-PIAM-MR 4 × 4 7.1349.330.00133.200.04%
10 × 10 0.23188.200.0010.890.02%
16 × 16 0.15195.660.003.900.04%
24 × 24 0.48197.640.001.370.04%
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Hou, Y.; Liang, X.; Zhang, J.; Yang, Q.; Yang, A.; Wang, N. Exploring the Use of Invalid Action Masking in Reinforcement Learning: A Comparative Study of On-Policy and Off-Policy Algorithms in Real-Time Strategy Games. Appl. Sci. 2023, 13, 8283. https://doi.org/10.3390/app13148283

AMA Style

Hou Y, Liang X, Zhang J, Yang Q, Yang A, Wang N. Exploring the Use of Invalid Action Masking in Reinforcement Learning: A Comparative Study of On-Policy and Off-Policy Algorithms in Real-Time Strategy Games. Applied Sciences. 2023; 13(14):8283. https://doi.org/10.3390/app13148283

Chicago/Turabian Style

Hou, Yueqi, Xiaolong Liang, Jiaqiang Zhang, Qisong Yang, Aiwu Yang, and Ning Wang. 2023. "Exploring the Use of Invalid Action Masking in Reinforcement Learning: A Comparative Study of On-Policy and Off-Policy Algorithms in Real-Time Strategy Games" Applied Sciences 13, no. 14: 8283. https://doi.org/10.3390/app13148283

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop