WeSearch

Ask HN: How do you model temporarily invalid data structures

·1 min read · 0 reactions · 0 comments · 15 views
#programming#data structures#game development#chess game
⚡ TL;DR · AI summary

The article discusses the challenges of modeling temporarily invalid data structures in a chess game. It raises questions about whether to use an existing Board type while avoiding invalid states or to create a separate InvalidBoard type. The author seeks insights on how others have approached this issue in various contexts.

Key facts
Original article
Ycombinator
Read full at Ycombinator →
Opening excerpt (first ~120 words) tap to expand

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.

Excerpt limited to ~120 words for fair-use compliance. The full article is at Ycombinator.

Anonymous · no account needed
Share 𝕏 Facebook Reddit LinkedIn Threads WhatsApp Bluesky Mastodon Email

Discussion

0 comments

More from Ycombinator