Uploaded November 2026 | Updated November 2026, 4 days ago
https://cppcon.org
---
Optimizing Bishop, Rook, and Queen Move Generation in a Chess Engine - Aryan Naraghi - CppCon 2026
---
A chess engine must search millions of positions per second. Move generation is often a bottleneck. Generating moves for knights, kings, and pawns are computationally cheap (~1 nanosecond). However, rooks, bishops, and queens (aka "sliding pieces") present a unique challenge: their movement depends on the placement of other pieces. This makes on-demand generation too slow (20+ nanoseconds) and naively-implemented lookup tables impractical (requiring zettabytes of RAM).
We will start by reviewing the core data structures in a chess engine and the logic behind move generation. Then, we will explore "magic bitboards", a perfect hashing technique that enables sliding piece move generation in ~1 nanosecond. We will look at how to implement this in modern C++, comparing hardware-specific instructions like PEXT (Parallel Bits Extract) against a portable software approach. Finally, we will discuss the practical challenges of generating the data structures required for magic bitboards, including the limitations of consteval and how to integrate build-time table generation into the build process using Bazel.
To ground these concepts, we will be referencing implementation details and code from my C++ chess engine, FollyChess.
---
Slides: github.com/CppCon/CppCon2026/blob/main/Presentations
Work at Hudson River Trading (HRT): tinyurl.com/safxfctf
---
Aryan Naraghi
Aryan Naraghi is a Member of Technical Staff at Anthropic. Before that, he spent most of his career at Google, where he contributed to BigQuery, App Engine, Google Analytics, and Compute Engine; in between his two stretches at Google, he led the data platform team at Restaurant Brands International.
As a C++ enthusiast, Aryan is the creator of FollyChess, a C++ chess engine focused on low-latency search and modern C++ design. He holds a B.S. in Computer Engineering from the University of Washington.
---
CppCon is the annual, week-long face-to-face gathering for the entire C++ community. The conference is organized by the C++ community for the community. You will enjoy inspirational talks and a friendly atmosphere designed to help attendees learn from each other, meet interesting people, and generally have a stimulating experience. Taking place this year in Aurora, Colorado, near the Denver airport, and including multiple diverse tracks, the conference will appeal to anyone from C++ novices to experts.
Annual CppCon Conference - cppcon.org
linkedin.com/company/cppcon
https://x.com/cppcon
facebook.com/CppConference
reddit.com/r/cppcon
https://mastodon.social/@CppCon
---
Videos Filmed & Edited by Bash Films: BashFilms.com
YouTube Channel Managed by Digital Medium Ltd: events.digital-medium.co.uk
---
#cpp #cplusplus #cppcon #cppprogramming #cplusplusprogramming #softwaredevelopment #softwareengineering #coding #code #computerscience #technology #technews #programming #programmer
https://cppcon.org
---
Optimizing Bishop, Rook, and Queen Move Generation in a Chess Engine - Aryan Naraghi - CppCon 2026
---
A chess engine must search millions of positions per second. Move generation is often a bottleneck. Generating moves for knights, kings, and pawns are computationally cheap (~1 nanosecond). However, rooks, bishops, and queens (aka "sliding pieces") present a unique challenge: their movement depends on the placement of other pieces. This makes on-demand generation too slow (20+ nanoseconds) and naively-implemented lookup tables impractical (requiring zettabytes of RAM).
We will start by reviewing the core data structures in a chess engine and the logic behind move generation. Then, we will explore "magic bitboards", a perfect hashing technique that enables sliding piece move generation in ~1 nanosecond. We will look at how to implement this in modern C++, comparing hardware-specific instructions like PEXT (Parallel Bits Extract) against a portable software approach. Finally, we will discuss the practical challenges of generating the data structures required for magic bitboards, including the limitations of consteval and how to integrate build-time table generation into the build process using Bazel.
To ground these concepts, we will be referencing implementation details and code from my C++ chess engine, FollyChess.
---
Slides: github.com/CppCon/CppCon2026/blob/main/Presentations
Work at Hudson River Trading (HRT): tinyurl.com/safxfctf
---
Aryan Naraghi
Aryan Naraghi is a Member of Technical Staff at Anthropic. Before that, he spent most of his career at Google, where he contributed to BigQuery, App Engine, Google Analytics, and Compute Engine; in between his two stretches at Google, he led the data platform team at Restaurant Brands International.
As a C++ enthusiast, Aryan is the creator of FollyChess, a C++ chess engine focused on low-latency search and modern C++ design. He holds a B.S. in Computer Engineering from the University of Washington.
---
CppCon is the annual, week-long face-to-face gathering for the entire C++ community. The conference is organized by the C++ community for the community. You will enjoy inspirational talks and a friendly atmosphere designed to help attendees learn from each other, meet interesting people, and generally have a stimulating experience. Taking place this year in Aurora, Colorado, near the Denver airport, and including multiple diverse tracks, the conference will appeal to anyone from C++ novices to experts.
Annual CppCon Conference - cppcon.org
linkedin.com/company/cppcon
https://x.com/cppcon
facebook.com/CppConference
reddit.com/r/cppcon
https://mastodon.social/@CppCon
---
Videos Filmed & Edited by Bash Films: BashFilms.com
YouTube Channel Managed by Digital Medium Ltd: events.digital-medium.co.uk
---
#cpp #cplusplus #cppcon #cppprogramming #cplusplusprogramming #softwaredevelopment #softwareengineering #coding #code #computerscience #technology #technews #programming #programmer










