Hacker News

Ask HN: How do you model temporarily invalid data structures

Hacker News - Tue, 05/26/2026 - 3:56pm

Say you’re making a chess game. A valid board only has one piece per square, or zero. But, you have an algo that generates boards by moving pieces around and during that algo you may move a piece on top of another and then later decide to move one of them to get back to valid.

Do you try to use some existing Board type and just avoid in your algo those invalid states (like by using a stack or some data structure to avoid iteratively moving pieces one at a time).

Do you have a separate InvalidBoard type that allows multiple pieces per square?

I think it’s context dependent but I’m curious how you’ve seen this handled in different ways.

Comments URL: https://news.ycombinator.com/item?id=48285139

Points: 1

# Comments: 0

Categories: Hacker News

Sinclair-O-Matic

Hacker News - Tue, 05/26/2026 - 3:55pm

Article URL: https://dpt.github.io/SinclairLogo/

Comments URL: https://news.ycombinator.com/item?id=48285123

Points: 2

# Comments: 0

Categories: Hacker News

Pages