Research Article

On-Policy Vs. Off-Policy Reinforcement Learning in ConnectX: Seat-Stratified Performance and the Role of Action Masking

Jiayi Lai*
Faculty of Engineering, McGill University, Montreal, Canada

* Corresponding author: [email protected]

Abstract

This study evaluates on-policy and off-policy reinforcement learning for ConnectX under a unified, seat-stratified evaluation protocol, with particular attention to invalid-action masking. Policies are trained against a fixed opponent schedule and evaluated offline with frozen parameters. The test set distinguishes Seen opponents from Unseen, deeper search (noisy-minimax-3 as the primary adversary; clean minimax-3 as a stress test). Uncertainty is summarized with 95% Wilson intervals, and all outcomes are reported by seat to avoid pooling bias. Across Seen opponents, masking consistently accelerates policy-gradient learning and reduces variability: MaskablePPO reaches target win-rate levels with fewer samples and tighter intervals than PPO, while value-based baselines reach an early asymptote. Against the Unseen noisy-minimax-3 in the first seat, PPO exceeds MaskablePPO (71.9% vs. 37.5%; intervals non-overlapping), whereas in the second seat masking yields large margins where legal actions are scarce (e.g., 87.6% vs. 17.3% against noisy-minimax-2; 48.3% vs. 8.3% against blocker; intervals non-overlapping). Against clean minimax-3, win rates approach zero within CI in the second seat for all methods, indicating a persistent gap to deeper search. These results imply two practical guidelines for legality-constrained, turn-based games: (i) legality-aware sampling is a substantive stability lever for policy-gradient methods rather than a peripheral implementation detail; and (ii) seat-stratified reporting is required to disentangle structural initiative from algorithmic effects. Overall, masking improves in-distribution efficiency and second-seat robustness but does not by itself close the generalization gap to stronger, unseen search.

Keywords: Reinforcement learning; connectx; invalid-action masking; seat-stratified evaluation; on-policy vs. off-policy
Published: November 11, 2025
DOI: 10.54254/2755-2721/2026.TJ29489
Volume: ACE Vol.203
pp. 160-170
Download PDF

References

  1. Huang, S., & Ontañón, S. (2022). A Closer Look at Invalid Action Masking in Policy Gradient Algorithms. In FLAIRS-35 Proceedings. arXiv: 2006.14171.
  2. Kaggle. (n.d.). kaggle-environments: Agent and environment library for reinforcement learning competitions. GitHub repository. Retrieved from  https: //github.com/Kaggle/kaggle-environments.
  3. Allis, L. V. (1988). A Knowledge-Based Approach of Connect-Four (Master’s thesis). Vrije Universiteit Amsterdam. (Often cited with subtitle “The Game is Solved: White Wins”.)
  4. Hou, Y., Liang, X., Zhang, J., Yang, Q., Yang, A., & Wang, N. (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(14), 8283.  https: //doi.org/10.3390/app13148283.
  5. Stable-Baselines3 Contrib Team. (n.d.). Maskable PPO (v2.5.0) — Documentation. Retrieved from  https: //sb3-contrib.readthedocs.io/en/v2.5.0/modules/ppo_mask.html.
  6. Dabney, W., Rowland, M., Bellemare, M. G., & Munos, R. (2017). Distributional Reinforcement Learning with Quantile Regression. arXiv: 1710.10044.
  7. Dabney, W., Ostrovski, G., Silver, D., & Munos, R. (2018). Implicit Quantile Networks for Distributional Reinforcement Learning. In ICML 2018. arXiv: 1806.06923.
  8. Bellemare, M. G., Dabney, W., & Munos, R. (2017). A Distributional Perspective on Reinforcement Learning. Website: distributional-rl.org.
  9. Cho, T., Han, S., Lee, H., Lee, K., & Lee, J. (2023). Pitfall of Optimism: Distributional Reinforcement Learning by Randomizing Risk Criterion. NeurIPS 2023. arXiv: 2310.16546.
  10. Schulman, J., Wolski, F., Dhariwal, P., Radford, A., & Klimov, O. (2017). Proximal Policy Optimization Algorithms. arXiv: 1707.06347.
  11. Kaggle. (n.d.). kaggle-api: Official Kaggle API. GitHub repository. Retrieved from  https: //github.com/Kaggle/kaggle-api.
  12. McGrath, O., & Burke, K. (2021). Binomial Confidence Intervals for Rare Events. arXiv: 2109.02516.
  13. Mnih, V., Badia, A. P., Mirza, M., Graves, A., Lillicrap, T. P., Harley, T., Silver, D., & Kavukcuoglu, K. (2016). Asynchronous Methods for Deep Reinforcement Learning. ICML 2016. arXiv: 1602.01783.
  14. Nguyen, T. T., Gupta, S., & Venkatesh, S. (2020). Distributional Reinforcement Learning via Moment Matching. AAAI 2021. arXiv: 2007.12354.
  15. Cho, T., Han, S., Lee, H., Lee, K., & Lee, J. (2023). Pitfall of Optimism: Distributional Reinforcement Learning by Randomizing Risk Criterion. NeurIPS 2023. arXiv: 2310.16546.
  16. Garg, D., Gupta, P., Malhotra, P., Vig, L., and Shroff, G., “Batch-Constrained Distributional Reinforcement Learning for Session-based Recommendation, ” arXiv: 2012.08984 [cs.LG], 2020. DOI: 10.48550/arXiv.2012.08984.
  17. Narvekar, S., Pereira, A., Leonetti, M., & Stone, P. (2020). Curriculum Learning for Reinforcement Learning Domains: A Framework and Survey. arXiv: 2003.04960.
  18. Bighashdel, A., Wang, Y., McAleer, S., Savani, R., & Oliehoek, F. A. (2024). Policy Space Response Oracles: A Survey. IJCAI-24. arXiv: 2403.02227.
  19. McAleer, S., Lanier, J. B., Fox, R., & Baldi, P. (2021). Pipeline PSRO: A Scalable Approach for Finding Approximate Nash Equilibria in Large Games. arXiv: 2006.08555.
  20. Farama Foundation.  Gymnasium API — Env: attributes (action_space, observation_space).  Official documentation. Available at:   https: //gymnasium.farama.org/api/env/.