Sample Page

Move generation is the computational process by which a program identifies the legal moves available from a given game state in computer chess and generally other strategy games. In general game playing, the engine must produce only valid moves before evaluation can begin. Pseudo-legal moves follow basic movement rules, and fully legal moves satisfy all higher-level constraints such as check (chess). Because the number of possible positions grow exponentially with search depth, move generation gives a major effect on speed and search.

The field developed alongside early chess programming in the 1950s and later progressed through new board representations, data structures and hardware support. Early systems depended on simple array-based boards and strict square-by-square testing and later programs used methods such as the mailbox board, rotated bitboards and magic bitboards. Some engines also used move generation using custom chips, like Belle and Deep Blue.

Definition

In the context of computer chess and in general strategic games, move generation refers to the specific computational process where an algorithm identifies every legal transition from a given state.[1] This fundamental component of a general game playing engine must follow the defined rules of the game to ensure the search algorithm only evaluates valid positions. Developers often distinguish between pseudo-legal moves, which follow basic piece movement patterns, and strictly legal moves that also include complex restrictions like check (chess).

The total number of potential outcomes grow exponentially as the search depth increases.[2] Bitboards represent the game state through 64-bit integers. Bitboards use bitwise operations to calculate piece movements efficiently.[3] Pseudo-legal generation speeds up the calculation process further by temporarily ignoring whether a move accidentally leaves the king in check. Advanced systems integrate precomputed attack tables for “sliding pieces” like rooks and queens to eliminate redundant real-time processing.[4]

History

IBM Deep Blue, a chess computer that used chess chips to accelerate move generation and search.

Move generation developed during the 1950s alongside the foundational concepts of Alan Turing and Claude Shannon.[5][6] Early programs ran on massive mainframe computers and relied on piece-centric array systems to determine valid board moves, because physical computer memory was limited, engineers had to write highly restrictive instructions that checked every square on the board sequentially.[7]

During the 1970s, researchers at Northwestern University created the Chess series of programs, which introduced advanced board representations to reduce redundant processing loops.[8] The introduction of the mailbox board design provided quick out-of-bounds error handling; at the same time, university labs started experimenting with custom microchips engineered to execute move generation tasks directly in hardware.[9]

The Belle chess engine demonstrated that offloading the move generation loop to custom circuitry could increase the number of nodes evaluated per second, and this hardware approach led to Deep Blue.[10]

Calculating sliding attacks for rooks and bishops remained a problem because other pieces blocked them, requiring programs to track board occupancy, so software engineers resolved this issue by using rotated bitboards. However, rotated bitboards still needed additional processing time to keep the various board views synchronized after every single move.[11] To overcome the computational overhead of rotated bitboards, developers invented magic bitboards to handle sliding piece generation using hashing. The engine only verifies the legality of a move if the search algorithm decides to explore that specific branch, which saves valuable computing cycles on paths that are pruned.[12]

Core concepts

Move generation depends on memory architecture, state tracking, and algorithmic verification to populate the game tree. The data structure chosen for move representation must pack original squares, target squares, and special flags into compact bit fields to conserve system memory.[13] The generator then processes these structures through either pseudo-legal or strict legal move filters. Pseudo-legal generation speeds up the initial phase by delaying king safety checks while legal generation immediately validates all spatial and tactical constraints before passing data to the search loop.[14]

In abstract strategy game programming, a pseudo-legal move represents any action that follows basic piece mechanics but ignores broader constraints like immediate loss conditions.[15] The engine checks whether the move follows to movement rules of the game. but this calculation does not check if the move violates the rules of its corresponding game. Generating these moves requires very little computation because the system skips complex safety verification steps.[16]

A legal move must satisfy every rule of the game and also preserve all mandatory safety requirements in the game states. Engines filter out illegal moves by simulating the action and analyzing the next board position.[17] If the simulated state reveals that the player or the engine has violated a core rule or allowed an instant defeat in the game, the engine rejects the move.[15]

Move representation

In game theory and computer game playing, a move representation defines the internal data structure used to encode a player’s legal action within a specific board state. This architectural choice directly determines the computational efficiency of the broader move generation subsystem across various strategic games like chess, shogi, and Go. Developers often pack critical execution data into a single 16-bit or 32-bit integer by using bitmask operators to save cache memory and minimize overhead.[18] This compressed format typically holds the starting coordinate, the arrival coordinate, the moving piece type, and the distinct flag bits for special moves in chess like castling, en passant, or piece promotion.[19]

Board representation

Board representation is the internal model a game engine uses to store the current position, and for board games it can be built in several ways. The bitboard method represents a board game by encoding various information about the position.[20] Move generation reads that encoded position to determine the legal continuations, so the representation has to make occupied squares, piece types, and other such rule data available to query.[5]

The choice of move generator applies to how it works during search. Specifically, the move generation is used many times, meaning an efficient generator is needed to maintain performance. This efficiency can be achieved by storing all possible moves in precomputed data so the program can access them quickly.[21] For non-sliding pieces, this lets the program filter destination squares directly from cached move sets, while sliding pieces need extra data tied to rank, file, or diagonal occupancy because their legal moves depend on the current line on the board.[22]

Generation methods

Move generation methods define the specific instructions and computer code used to calculate all valid actions a general game playing engine can execute from a specific state. Within these generation methods, move generation works as the core component that fills the search tree, directly determining the speed and accuracy of the next evaluation phase. Programs apply rule-based generation to enforce complex game constraints sequentially, ensuring total legality at the cost of processing speed.[23]

Piece-based generation scans only the active pieces on the board to find potential actions.[24] General game playing engines simplify this process by using table-driven and lookup-based methods, which pull precalculated moves from memory to bypass real-time computation.[25]

Bitboards, and other similar variants like PEXT Bitboard, rotated bitboards, use parallel bitwise operations on binary arrays to find valid moves instantly.[26] Incremental and cached generation methods reuse calculations from previous turns, updating only the specific parts of the board that changed.[27]

Rule-based move generation

Rule-based move generation uses explicit code to apply the rules of a game to a specific state.[28] A specialized function basically implements all of the rules to strictly verify which actions are valid. This process generates a list of all the legal moves as output, ensuring the software knows all rules before it begins any strategic search. Incremental generation will usually work faster than listing every option immediately, allowing the engine to process strictly necessary branches first.

Piece-based move generation

Piece-based move generation is an algorithmic approach in computer chess that scans the board to locate individual pieces and calculates their legal destinations one by one.[29] In move generation, this strategy isolates each active piece on the chessboard to determine it’s valid moves.[30]

The engine uses specialized data structures like mailbox arrays or bitboards to identify piece coordinates sequentially. For each piece found, the system applies sliding piece or stepper piece rules to find empty squares or enemy captures.

See also

References

  1. ^ Dehghani, Hootan; Babamir, Seyed Morteza (April 21, 2017). “A GA based method for search-space reduction of chess game-tree”. Applied Intelligence. 47 (3): 750–768. doi:10.1007/s10489-017-0918-z. ISSN 0924-669X. OCLC 10957950152 – via Springer Nature.
  2. ^ Marsland, Tony (March 1986). “A Review of Game-Tree Pruning”. ICCA Journal. 9 (1): 3–19. doi:10.3233/ICG-1986-9102. ISSN 1389-6911 – via Sage Publishing.
  3. ^ Browne, Cameron (June 1, 2014). “Bitboard Methods for Games”. ICGA Journal. 37 (2): 67–84. doi:10.3233/ICG-2014-37202 – via Sage Publishing.
  4. ^ Vrzina, Sander (July 2023). Piece by Piece: Building a Strong Chess Engine (PDF) (BSc thesis). Vrije Universiteit Amsterdam. pp. 11–13.
  5. ^ a b Shannon, Claude E. (March 1950). “Programming a Computer for Playing Chess” (PDF). Philosophical Magazine. Series 7. 41 (314). Taylor & Francis: 256–275. doi:10.1080/14786445008521796.
  6. ^ Turing, Mathison Alan (1953). “Digital Computers Applied to Games”. In Bowden, Bertram (ed.). Faster Than Thought: A Symposium on Digital Computing Machines. London: Pitman Publishing. pp. 286–295.
  7. ^ Bernstein, Alex; Roberts, Michael de V.; Arbuckle, Timothy; Belsky, Martin. A Chess Playing Program for the IBM 704. Joint Computer Conference. Association for Computing Machinery. pp. 157–159. doi:10.1145/1457769.1457813. ACM DL ID:1457813.
  8. ^ Slate, David; Atkin, Lawrence (1977). “CHESS 4.5: The Northwestern University Chess Program”. In Frey, Peter (ed.). Chess Skill in Man and Machine. New York: Springer Science+Business Media. pp. 82–118. ISBN 978-3-662-06241-8.
  9. ^ Hsu, Feng-hsiung (April 30, 1999). “IBM’s Deep Blue Chess Grandmaster Chips”. IEEE Micro. 19 (2): 70–81. Bibcode:1999IMicr..19b..70F. doi:10.1109/40.755469. eISSN 1937-4143. ISSN 0272-1732. OCLC 5872001685.
  10. ^ Condon, Joseph Henry; Thompson, Ken (1982). “Belle Chess Hardware”. In Clarke, M.R.B. (ed.). Advances in Computer Chess (3rd ed.). Oxford, United Kingdom: Pergamon Press. pp. 45–54. doi:10.1016/B978-0-08-026898-9.50007-3. ISBN 978-0-08-026898-9 – via ScienceDirect.
  11. ^ Hyatt, Robert (December 1, 1999). “Rotated Bitmaps, a New Twist on an Old Idea”. ICCA Journal. 22 (4): 213–222. doi:10.3233/ICG-1999-22403. eISSN 2468-2438. ISSN 1389-6911. OCLC 10597447514 – via Sage Publishing.
  12. ^ Rasmussen, Ravn David (August 2004). “Data Structures”. Parallel Chess Searching and Bitboards (PDF) (Thesis). Technical University of Denmark. p. 56. And it is cheaper to let the search itself check for legality of moves when needed, because the search is already making and unmaking the moves. And if a cutoff occurs, we have not wasted time checking the remaining moves for legality.
  13. ^ Levy, David; Newborn, Monty (1991). How Computers Play Chess (1st ed.). New York: Computer Science Press. pp. 21–41. ISBN 0-7167-8239-1. LCCN 90039244. OCLC 826075762.
  14. ^ Cracraft, M. Stuart (September 1984). “Bitmap Move Generation in Chess”. ICCA Journal. 7 (3): 146–153. doi:10.3233/ICG-1984-7304. eISSN 2468-2438. ISSN 1389-6911. OCLC 8152667560 – via Sage Publishing.
  15. ^ a b Ondrej, Franko (February 6, 2026). “Move Generation”. Chess Engine Techniques Analysis (PDF) (Bc thesis). Faculty of Informatics Masaryk University. pp. 11–16. The engine utilises a pseudo-legal move… the king in check.
  16. ^ Takizawa, Hiroki (September 12, 2023). “Strongly solved Ostle: calculating a strong solution helps compose high-quality puzzles for recent games”. PeerJ Computer Science. 9 e1560. doi:10.7717/peerj-cs.1560. PMC 10557503. PMID 37810330. …Algorithm 1 does not consider the restriction of rule 8 and generates a restricted move for computational efficiency. In other words, Algorithm 1 is a “pseudo-legal” move generator…
  17. ^ Fürnkranz, Johannes (March 28, 2011). “Machine Learning and Game Playing”. In Sammut, Claude; Webb, Geoffrey (eds.). Encyclopedia of Machine Learning (1st ed.). Springer Science+Business Media. pp. 633–637. doi:10.1007/978-0-387-30164-8. ISBN 978-0-387-30768-8.
  18. ^ Ondrej 2026, p. 13.
  19. ^ Bošković, Borko; Brest, Janez (2011). “Chess Program Umko” (PDF). Elektrotehniški vestnik. 78 (3): 153–158. eISSN 2232-3236. ISSN 0351-5680. OCLC 781408058.
  20. ^ Buchner, Johannes (May 5, 2025). “Reinforcement Learning and Life Cycle Assessment for a Circular Economy – Towards Progressive Computer Science”. arXiv:2503.10822 [cs.AI].. “The bitboard method for representing a board game appears to have been invented in the mid-1950s, by Arthur Samuel and was used in his checkers program.”
  21. ^ Buchner 2025, p. 1. “The move-generation is used many times during the search-algorithms used in chess programs. Therefore, an efficient move-generation is needed.”
  22. ^ Tannous, Sam (June 1, 2007). “Avoiding Rotated Bitboards with Direct Lookup”. ICGA Journal. 30 (2). IOS Press: 85–91. doi:10.3233/ICG-2007-30204. eISSN 2468-2438. ISSN 1389-6911. OCLC 691054431 – via Sage Publishing.
  23. ^ Genesereth, Michael; Thielscher, Michael (March 1, 2014). “General Game Playing With Propnets”. General Game Playing. Synthesis Lectures on Artificial Intelligence and Machine Learning (1st ed.). Morgan & Claypool Publisher. pp. 89–95. doi:10.1007/978-3-031-01569-4. eISSN 1939-4616. ISBN 978-3-031-00441-4. ISSN 1939-4608.
  24. ^ Vrzina 2023, p. 6.
  25. ^ Schiffel, Stephan; Thielscher, Michael (July 22, 2007). Fluxplayer: A Successful General Game Player. Proceedings of the Twenty-Second AAAI Conference on Artificial Intelligence. Vol. 2. Vancouver, British Columbia, Canada: AAAI Press. pp. 1191–1196 – via ACM Digital Library.
  26. ^ Fenner, Trevor; Levene, Mark (March 15, 2008). “Move generation with perfect hash functions”. ICGA Journal. 31 (1): 3–12. doi:10.3233/ICG-2008-31102. eISSN 2468-2438. ISSN 1389-6911 – via Sage Publishing.
  27. ^ Campbell, Murray; Hoane Jr., A. Joseph; Hsu, Feng-hsiung (January 24, 2002). “Deep Blue”. Artificial Intelligence. 134 (1–2): 64–66. doi:10.1016/S0004-3702(01)00129-1. ISSN 0004-3702 – via ScienceDirect.
  28. ^ Chen, Yuhao; Liu, Shuochen; et al. (Yuanjie Lyu, Chao Zhang, Jiayao Shi, Tong Xu) (July 16, 2025). “Xiangqi-R1: Enhancing Spatial Strategic Reasoning in LLMs for Chinese Chess via Reinforcement Learning”. arXiv:2507.12215 [cs.AI].
  29. ^ Schalk, Andrea. “Large Games” (PDF). University of Manchester. p. 15. Course Code: CS3191. Retrieved May 27, 2026. To generate moves: Pick piece, generate possible target fields, then… Need… Complicated, not fast.
  30. ^ Sander 2023, p. 6.