Impartial Games on Graphs: Solving Kayles via Dynamic Programming and Periodicity Properties
DOI:
https://doi.org/10.5753/jbcs.2026.7462Keywords:
Caterpillars, graphs, combinatorial games, Kayles, nimbersAbstract
In this work, we consider combinatorial games in which two players alternately choose vertices from a finite graph until a winning condition is achieved. Specifically, we focus our investigation on the well-known game Kayles, in which the selected vertices must form an independent set, and the player who makes the last valid move wins (i.e., the player who chooses a vertex that completes a maximal independent set). Zermelo's Theorem guarantees that, in this scenario, one of the players has a winning strategy---that is, a sequence of moves that ensures a win regardless of the opponent's choices. Given a graph, the typical decision problem associated with this type of game consists of determining which player has a winning strategy. Answering this question means solving the game. We first consider Kayles played on caterpillars. Since caterpillars are interval graphs, an O(n3)-time algorithm for solving Kayles on this graph class is already known [Bodlaender and Kratsch, 2002]. However, we investigate scenarios in which this time complexity can be reduced to O(1) by extending the periodicity property presented in [Guignard and Sopena, 2009] to caterpillars. We prove that the nimber of any caterpillar is equal to the nimber of an equivalent reduced caterpillar, obtained by appropriately removing certain leaves from the original graph. By partitioning these reduced caterpillars into classes, we show that a period of 34 emerges in each investigated class, allowing the computation of nimbers to scale to graphs with a large number of vertices. We present a sufficient condition for a class of caterpillars to exhibit periodicity 34, using it to identify many periodic classes and to calculate the nimber of their caterpillars in O(1) time. Furthermore, we present an O(n2)-time dynamic programming algorithm for solving Kayles on powers of paths, improving upon the O(n4)-time complexity given in [Bodlaender and Kratsch, 2002]for graphs with an asteroidal number of at most 2. Finally, we show how this same O(n2)-time algorithm can be adapted to solve Kayles on powers of cycles, thereby reducing the O(n3)-time complexity previously established in [Bodlaender and Kratsch, 2002] for circular-arc graphs.
Downloads
References
Berlekamp, E. R., Conway, J. H., and Guy, R. K. (2001). Winning Ways for Your Mathematical Plays, volume 1. A. K. Peters, 2nd edition. DOI: 10.2307/2323620.
Bodlaender, H. L. and Kratsch, D. (2002). Kayles and nimbers. Journal of Algorithms, 43:106-119. DOI: 10.1006/jagm.2002.1215.
Bodlaender, H. L., Kratsch, D., and Timmer, S. T. (2015). Exact algorithms for Kayles. Theoretical Computer Science, 562:165-176. DOI: 10.1016/j.tcs.2014.09.042.
Bouton, C. L. (1901). Nim, a game with a complete mathematical theory. Annals of Mathematics, 3(1/4):35-39. DOI: 10.2307/1967631.
DeVos, M. and Kent, D. A. (2016). Game Theory: A Playful Introduction. AMS - American Mathematical Society. DOI: 10.1090/stml/080.
Ferguson, T. S. (2000). Game Theory. Class notes for Math 167, Fall 2000, Carnegie Mellon University. DOI: 10.1017/cbo9780511609909.006.
Fleischer, R. and Trippen, G. (2006). Kayles on the Way to the Stars. In van den Herik, H. J., Björnsson, Y., and Netanyahu, N. S., editors, Computers and Games, pages 232-245. Springer Berlin Heidelberg. DOI: 10.1007/11674399_16.
Grundy, P. M. (1939). Mathematics and games. Eureka, 2:6-8. Book.
Guignard, A. and Sopena, E. (2009). Compound node–Kayles on paths. Theoretical Computer Science, 410(21):2033-2044. DOI: 10.1016/j.tcs.2008.12.053.
Kobayashi, Y. (2021). On structural parameterizations of node Kayles. In Akiyama, J., Marcelo, R. M., Ruiz, M.-J. P., and Uno, Y., editors, Discrete and Computational Geometry, Graphs, and Games, pages 96-105, Cham. Springer International Publishing. DOI: 10.1007/978-3-030-90048-9_8.
Saldanha, N. C. (2008). Tópicos em Jogos Combinatórios. Instituto de Matemática Pura e Aplicada, Rio de Janeiro. Book.
Schaefer, T. J. (1978). On the complexity of some two-person perfect-information games. Journal of Computer and System Sciences, 16(2):185-225. DOI: 10.1016/0022-0000(78)90045-4.
Sibert, W. L. and Conway, J. H. (1992). Mathematical Kayles. International Journal of Game Theory, 20(3):237-246. Available at:[link].
Sprague, R. (1935). Über Mathematische Kampfspiele. Tohoku Mathematical Journal (First Series), 41:438-444. Available at [link].
Zermelo, V. E. (1912). Uber eine Anwendung der Mengenlehre auf die Theorie des Schachspiels. Proc. Fifth Congress Mathematicians, 5:501-504. Available at:[link].
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2026 Marcos Felipe Medeiros-de-Souza, Felipe Eizo Hanada, Fábio Protti

This work is licensed under a Creative Commons Attribution 4.0 International License.

