M
MercyNews
Home
Back
Storing Chess Positions in 26 Bytes
Technology

Storing Chess Positions in 26 Bytes

Hacker News4d ago
3 min read
📋

Key Facts

  • ✓ A chess position can be stored in 26 bytes using bit-level manipulation.
  • ✓ 6 bytes are allocated for the board state.
  • ✓ 1 byte is used for the active player, 1 byte for castling rights, and 1 byte for en passant.
  • ✓ This method optimizes memory usage for high-performance chess engines.

In This Article

  1. Quick Summary
  2. The 26-Byte Breakdown
  3. Bit-Level Magic Explained
  4. Why Efficiency Matters
  5. Implementation Considerations

Quick Summary#

A technical guide has outlined a method for storing a complete chess position using only 26 bytes. This represents a significant optimization compared to standard data structures, which often consume significantly more memory. The technique relies on bit-level manipulation to pack all necessary game state information into a compact format.

The breakdown of the 26 bytes is precise. Six bytes are dedicated to the board state, representing the 64 squares. One byte handles the active player, while another manages castling rights. A single byte is also used for the en passant target square. The remaining bytes store the halfmove clock and fullmove number. This efficiency is vital for chess engines that perform millions of calculations per second, where memory access speeds and cache utilization are critical performance factors.

The 26-Byte Breakdown#

The core of the method lies in the specific allocation of memory for each component of a chess position. To store the location of pieces on the board, the method uses 6 bytes. Since there are 64 squares, and 6 bits are required to represent the 12 unique piece types (plus empty), the total bit requirement is 384 bits. However, the article suggests a more optimized approach using 6 bytes (48 bits) per square, or rather, a bitboard approach where pieces are tracked by type. The specific implementation details suggest using 6 bytes to represent the board state efficiently.

Additional critical game state data is stored in the remaining bytes:

  • 1 Byte: Stores the active player (White or Black).
  • 1 Byte: Encodes castling rights (Kingside/Queenside for both players).
  • 1 Byte: Represents the en passant target square, if available.
  • 2 Bytes: Allocated for the halfmove clock and fullmove number.

This structure ensures that every aspect of the game state is captured without wasting space.

Bit-Level Magic Explained#

The efficiency of this storage method is achieved through bit-level magic. Instead of using standard integer types that often occupy 32 or 64 bits regardless of the value stored, this approach packs data tightly. For example, castling rights only require 4 bits (one for each side), but storing them in a standard byte allows for future expansion or simpler alignment. The 'magic' refers to the bitwise operations used to read and write these values.

By using bitwise AND, OR, and XOR operations, a chess engine can quickly check or update specific flags within the byte. This avoids the overhead of accessing larger memory structures. For the board representation, bitboards are often used, where each bit corresponds to a square. While a full bitboard for all pieces requires 64 bits (8 bytes) per piece type, the article suggests a hybrid approach to fit the entire position into the 26-byte constraint.

Why Efficiency Matters#

Memory optimization is critical for chess engines. During a search, an engine generates millions of positions. If each position takes up excessive memory, the engine's cache performance degrades, leading to slower move calculation. Storing positions in just 26 bytes allows the engine to keep more nodes in the CPU cache, significantly speeding up the search depth.

Furthermore, this compact format benefits transposition tables. These tables store previously evaluated positions to avoid redundant calculations. With smaller entry sizes, the engine can store more entries in the same amount of RAM, increasing the hit rate and overall playing strength. This technique is a standard practice in high-level engine development.

Implementation Considerations#

While the concept is mathematically sound, implementing this storage requires careful handling of endianness and data alignment. Developers must ensure that bitwise operations are portable across different architectures. The use of bit-level magic often involves precomputed tables or specific compiler intrinsics to ensure maximum speed.

The method described provides a blueprint for developers looking to reduce the memory footprint of their chess applications. By adhering to this 26-byte standard, developers can ensure their engines remain competitive in terms of speed and efficiency.

Continue scrolling for more

AI Transforms Mathematical Research and Proofs
Technology

AI Transforms Mathematical Research and Proofs

Artificial intelligence is shifting from a promise to a reality in mathematics. Machine learning models are now generating original theorems, forcing a reevaluation of research and teaching methods.

Just now
4 min
172
Read Article
Ben Horowitz says that investing teams shouldn't be 'too much bigger than basketball teams'
Technology

Ben Horowitz says that investing teams shouldn't be 'too much bigger than basketball teams'

Ben Horowitz said investment teams should be the size of a playing five in basketball. Phillip Faraone/Getty Images for WIRED Ben Horowitz said his rule of thumb is about five people on an investing team. He said Andreessen Horowitz maintains lean teams and strong communication across verticals. AI tools are enabling startups and VCs to thrive with fewer employees. Ben Horowitz is a big fan of tiny teams. On an episode of the A16z podcast, the Andreessen Horowitz cofounder shared how his venture capital firm maintains a lean operation despite being one of the world's largest. "An investing team shouldn't be too much bigger than a basketball team," he said, referring to advice he got from famed American investor David Swensen in 2009. He added, "A basketball team is five people who start, and the reason for that is the conversation around the investments really needs to be a conversation." Horowitz cofounded the Silicon Valley VC firm with Marc Andreessen in 2009. Before A16Z, he ran enterprise software company Opsware, which Hewlett-Packard acquired. A16z has backed marquee companies including Meta, Airbnb, GitHub, and Coinbase. The VC said he always kept the basketball team size in mind but also knew that the firm had to expand to keep up with how "software was eating the world," his signature phrase. The solution was to split the firm into different investment verticals. To maintain good communication, staff attend other teams' meetings when investment themes overlap. The firm also organizes a two to three-day offsite twice a year, "with not much agenda." Horowitz said that people who join them from other firms say that A16Z has "less politics" than firms with 10 or 11 people because his firm has a culture where politicking is "disincentivized." A16z might have been early to the tiny team trend, but it's catching on fast with VCs and startups across the world. Startups are actively seeking to stay small, with many having fewer than 10 people. Founders told Business Insider that AI and vibe coding tools have boosted their productivity, allowing them to get things done with far fewer people. Less politics and bureaucracy are also big pluses, they say. "We're going to see 10-person companies with billion-dollar valuations pretty soon," OpenAI CEO Sam Altman said in February 2024. "In my little group chat with my tech CEO friends, there's this betting pool for the first year there is a one-person billion-dollar company, which would've been unimaginable without AI. And now will happen." Read the original article on Business Insider

1h
3 min
0
Read Article
Tempest: American Missile Buggy Scores 20+ Kills in Ukraine
World_news

Tempest: American Missile Buggy Scores 20+ Kills in Ukraine

A new American off-road buggy equipped with guided missiles has entered service in Ukraine, where crews report significant success against Russian drone threats. The Tempest system offers mobile air defense against Shahed loitering munitions.

1h
5 min
3
Read Article
Creator income inequality is rising as top influencers rake in big paydays from brands
Economics

Creator income inequality is rising as top influencers rake in big paydays from brands

Top creator Jimmy Donaldson, a.k.a. MrBeast, at the "Beast Games" season 2 premiere. JC Olivera/Variety via Getty Images Creator income inequality is rising, with the top 1% earning 21% of brand spending, per new CreatorIQ data. The trend has continued in each of the last two years. Big brands often favor top creators, making it harder for smaller influencers to compete. Creators are raking in the ad dollars — but the wealth is being shared less and less equally. New data from the influencer-marketing platform CreatorIQ shows that the income gap in the creator economy is widening. The top 10% of creators on CreatorIQ's platform received 62% of ad payments in 2025, up from 53% in 2023. Similarly, the top 1% received 21% of the total ad payment volume, up from 15% in 2023. CreatorIQ, which included the 2025 data in a new report released on Wednesday, examined 65,000 payments over a three-year period from brands and agencies to creators who received flat payments through its software. The data reflects an overall pattern in the creator economy. Brands are shifting more of their marketing dollars to creators, with payments more than doubling over the last two years in CreatorIQ's dataset. Overall, US advertiser spending on creators was expected to hit $37 billion in 2025, according to a November report from the Interactive Advertising Bureau. At the same time, much of the ad money is going to a relatively narrow segment of top talent. While many creators also make money outside influencer marketing — such as from subscriptions or direct payments from platforms like YouTube — brand sponsorships are generally the industry's top revenue source. Jasmine Enberg, cofounder and co-CEO of Scalable, a new media company focused on the creator economy, said the numbers show the industry is starting to resemble traditional entertainment, where top players rake in substantial sums, leaving smaller ones to compete for the leftovers. Enberg said the divide would only grow as big creators get larger projects, such as TV campaigns or Netflix deals. "We need to empower brands to diversify their investment more confidently," Brit Starr, CMO of CreatorIQ, said of the industry. CreatorIQ's survey of 300 creators found that only 11% earned $100,000 or more. About one-quarter of the creators surveyed fell into each of the "$50,000 to $100,000" and the "$25,000 to $50,000" categories. CreatorIQ's report included additional data points that help explain the current dynamics of the creator economy. The number of creators receiving payments within CreatorIQ's network more than doubled from 2023 to 2025, which could indicate an overall surge in influencers entering the market. While the average earnings per creator rose to $11,400 in 2025 from $9,200 in 2023, the median actually declined slightly, from $3,500 to $3,000. That suggests that top creators are pulling the average higher, while the typical creator is earning less. What's driving the pay gap Enberg said major advertisers have contributed to the sector's income inequality because they're more likely to allocate their budgets to a small number of top creators. Talent managers who spoke with Business Insider said earnings distribution had been lumpy. Budgets have definitely grown, but they haven't kept pace with the expansion of the creator population, said Kyle Hjelmeseth, CEO of G&B Digital Management. "There are now many more small accounts that will take $25 to post, for example," he said. Meanwhile, advertisers often spend a large chunk of their influencer budgets directly with social media platforms, making it harder for creators — especially smaller ones — to develop direct and potentially lasting relationships with brands, creator-industry insiders said. Becca Bahrke, the CEO of Illuminate Social, a creator management firm, said the CreatorIQ payment concentration data reflect what she's seeing among her own clients. She said she'd seen some full-time creators take the off-ramp to a different job. "You may have earned over $400,000 in one year, but if you're not showing up consistently on the platform, treating it as a full-time job, you can see the earnings fall," Bahrke said. "It's a lot of work. It's not for the faint of heart." Read the original article on Business Insider

1h
3 min
0
Read Article
KB Files Patent for Hybrid Stablecoin Credit Card
Economics

KB Files Patent for Hybrid Stablecoin Credit Card

South Korean financial giant KB has filed a patent application for a groundbreaking hybrid payment system. This technology aims to bridge the gap between digital assets and traditional finance.

1h
5 min
7
Read Article
Technology

AI will compromise your cybersecurity posture

Article URL: https://rys.io/en/181.html Comments URL: https://news.ycombinator.com/item?id=46612001 Points: 7 # Comments: 1

2h
3 min
0
Read Article
Culture

1000 Blank White Cards

Article URL: https://en.wikipedia.org/wiki/1000_Blank_White_Cards Comments URL: https://news.ycombinator.com/item?id=46611823 Points: 3 # Comments: 0

3h
3 min
0
Read Article
Russia Opens Crypto Market to Non-Qualified Investors
Cryptocurrency

Russia Opens Crypto Market to Non-Qualified Investors

Anatoly Aksakov confirms a draft bill is ready to let non-qualified investors trade crypto, marking a significant shift in Russia's digital asset regulations.

3h
5 min
24
Read Article
Technology

The Gleam Programming Language

Article URL: https://gleam.run/ Comments URL: https://news.ycombinator.com/item?id=46611667 Points: 9 # Comments: 0

3h
3 min
0
Read Article
Technology

Stop using natural language interfaces

Article URL: https://tidepool.leaflet.pub/3mcbegnuf2k2i Comments URL: https://news.ycombinator.com/item?id=46611550 Points: 4 # Comments: 1

4h
3 min
0
Read Article
🎉

You're all caught up!

Check back later for more stories

Back to Home