Optimizing Bishop, Rook, and Queen Move Generation in a Chess Engine - Aryan Naraghi - CppCon 2026 @CppCon
Optimizing Bishop, Rook, and Queen Move Generation in a Chess Engine - Aryan Naraghi - CppCon 2026  @CppCon
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
Optimizing Bishop, Rook, and Queen Move Generation in a Chess Engine - Aryan Naraghi - CppCon 2026Back to Basics: Rvalues and Move Semantics in C++ - Amir Kirsh - CppCon 2024Implement the C++ Standard Library: Design, Optimisations, Testing while Implementing Libc++Lightning Talk: Rust Programming in 5 Minutes - Tyler Weaver - CppCon 2024Lightning Talk: Do You Love or Hate Your C++ Build System? - Helen Altshuler - CppCon 2024Back to Basics: How to Refactor C++ Code - Amir KirshLightning Talk: DevSecOps for C++? Keep Calm and use Conan - Luis Caro Campos - CppCon 2024Lightning Talk: What LLMs Wont Ever be Able to Do - Ben Deane - CppCon 2024Unsatisfied with the C++ Standard Library? Join The Beman Project! - River WuYour Future in C++ Starts at CppCon - 12th - 18th Sept 2026Master Linux Debugging: Essential GDB & System ToolsUsing Floating-point in C++: What Works, What Breaks, and Why - Egor Suvorov - CppCon 2025
CppCon |

Optimizing Bishop, Rook, and Queen Move Generation in a Chess Engine - Aryan Naraghi - CppCon 2026

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER