HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
tromp
ChessPositionRanking
Haskell2021–2026
tromp / ChessPositionRanking

ChessPositionRanking

Software suite for ranking chess positions and accurately estimating the number of legal chess positions

7Distinct people
36Mentions
0Explicit recommenders
183GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Software suite for ranking chess positions and accurately estimating the number of legal chess positions

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 5:04:57 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year36 dated mentions

Observed mentions: 2021-08-08 14:42:51 UTC to 2026-01-28 02:19:51 UTC.

0510152021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 15 mentions; 3 submissions, 12 comments20212022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 8 mentions; 2 submissions, 6 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 4 mentions; 1 submissions, 3 comments20232024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 6 mentions; 0 submissions, 6 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2026-01-01 00:00:00 UTC to 2027-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments. Incomplete calendar period.2026*

* An incomplete calendar period is marked with an outlined bar. Its count is not directly comparable with a full period.

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC15312
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC826
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC413
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC606
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC101
2026 (partial)2026-01-01 00:00:00 UTC2027-01-01 00:00:00 UTC202

What Hacker News says

36 sources
96 bits is not nearly enough, as there are ~4.8 * 10^44 > 2^148 legal chess positions (with side to move/castling/ep info) [1]. Chess Position Ranking provides a 153 bit encoding but it's very slow to decode. If the encoding only needs to work for the set of positions occurring in some database, then there's almost no limit to the number of coding optimizations one can make (until the encoding just becomes an index in the set of all unique db positions). [1] https://github.com/tromp/ChessPositionRanking
In How to store a chess position in 26 bytes (2022)
> “No, no,” said God, “it was really tough. More than 10^35 legal positions God should know there are approximately 4.8*10^44 legal positions [1]. > Secondly Ken was predicting that the game of chess was a draw, i.e. that probably a majority of all legal positions, including the starting position, would lead to a draw with perfect play. Only the latter is what the game being drawn means. The majority of legal positions is in fact overwhelmingly to one side's advantage, as is clear from sampling a few dozen random legal positions. [1] https://github.com/tromp/ChessPositionRanking
In How God Plays Chess (2018)
> For one, gpt-3.5-turbo-instruct rarely suggests illegal moves, even in the late game. This requires “understanding” chess. Here's one way to test whether it really understands chess. Make it play the next move in 1000 random legal positions (in which no side is checkmated yet). Such positions can be generated using the ChessPositionRanking project at [1]. Does it still rarely suggest illegal moves in these totally weird positions, that will be completely unlike any it would have seen in training (and in which the legal move choice is often highly restricted) ? While good for testing legality of next moves, these positions are not so useful for distinguishing their quality, since usually one side already has an overwhelming advantage. [1] https://github.com/tromp/ChessPositionRanking
In OK, I can partly explain the LLM chess weirdness now
It doesn't really matter, since every position with 24 pieces can change into one with fewer. So you need the sum of all of those values. For a more sophisticated estimation of the number of legal positions, taking into account _true_ legality (a legal position must be reachable by a sequence of legal moves from the starting position, however dumb), see https://github.com/tromp/ChessPositionRanking. You can probably filter their sample by number of pieces to gain pretty accurate estimations for number of 29-piece positions if you wish.
In Los Alamos Chess
The optimum compression seems to be an index into the list of all legal moves. But one can do better on average, by assuming that moves are not uniformly distributed. Let an engine assign each legal move m some probability p of being played. The worse the move, the lower the probability we assign to it. Then a more optimal code for move m is -log p bits, corresponding to an entropy (expected surprise) of sum -p log p bits for the distribution over legal moves. Related: accurately estimating the number of legal positions of chess [1]. [1] https://github.com/tromp/ChessPositionRanking
In Compressing chess moves for fun and profit
Yes, although 1. You'd definitely want to deduplicate positions of identical pieces for even more savings 2. That only handles the case where no pieces have been captured, and the full arithmetic coding would probably need separate "sections" of the integer range for different cases, and the number of sections is also quite high. 3. There's extra nuanced things you might want to handle in the coding, like that pawns can't be on their own back row. That is significantly harder. It looks to me like https://github.com/tromp/ChessPositionRanking has resolved these sorts of issues, but I haven't dug into exactly how.
In How to store a chess position in 26 bytes using bit-level magic (2022)
The permutation ranking algorithm described in the article can be generalized to a so-called multinomial ranking, one of several rankings implemented in Haskell [1]. E.g. > let r = multinomialRanking (zip "abc" [1..3]) > size r 60 > unrank r 42 "cbcabc" > rank r "cbcabc" 42 Various types of rankings, together with combinators to build up more complex ones, were implemented as part of the chess position ranking project [2] which aims to rank a subset of all chess positions that includes all legal ones: > let cpr = sideToMoveRanking `composeURI` (caseRanking `composeRI` wArmyStatRanking `composeURI` bArmyStatRanking `composeRI` guardRanking `composeRI` enPassantRanking `composeURI` epOppRanking `composeURI` sandwichRanking `composeRI` opposeRanking `composeURI` pawnRanking `composeURI` castleRanking `composeURI` wA
Read the rest
rmyRanking `composeURI` bArmyRanking `composeURI` pieceRanking) $ emptyURPosition > size cpr 8726713169886222032347729969256422370854716254 > writeFEN . toPosition . unrank cpr $ 2389124290426577024216048831051262280148947032 "1r6/1qrRPk2/1rn1Rn1n/1RQRR2R/3P4/3b2BN/1Knn1b1b/1BR5 w - - 0 1" > rank cpr . fromPosition . readFEN $ "1r6/1qrRPk2/1rn1Rn1n/1RQRR2R/3P4/3b2BN/1Knn1b1b/1BR5 w - - 0 1" 2389124290426577024216048831051262280148947032 Position data includes side to move, castling status, and en-passant status. This ranking allows one to sample millions of random such positions, determine how many are legal, and thus obtain an accurate estimate of 4.8 * 10^44 legal chess positions. [1] https://github.com/tromp/ChessPositionRanking/blob/main/src/... [2] https://github.com/tromp/ChessPositionRanking
In Permutation iteration and random access
In late 2013 I came up with the first memory hard Proof-of-Work puzzle, Cuckoo Cycle [1], based on finding fixed-length cycles in random graphs. Recently, custom chips were developed to solve it more efficiently than GPUs can. That probably had more impact than the Binary Lambda Calculus language I designed [2] or the logical rules of Go I co-formulated [3]. Computing the number of Go positions [4] or approximating the number of Chess positions [5] had little impact beyond satisfying my intellectual curiosity. [1] https://github.com/tromp/cuckoo [2] https://tromp.github.io/cl/cl.html [3] https://tromp.github.io/go.html [4] https://tromp.github.io/go/legal.html [5] https://github.com/tromp/ChessPositionRanking#readme
In Ask HN: What is the most impactful thing you've built?

Showing the 15 most recent of 36 sources. Enable JavaScript to search and browse every indexed mention.

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.