| ▲ | ranger_danger 2 hours ago | |
I like to think I'm decent with C, and I thought I would be able to make my own solitaire, but just trying to wrap my head around how in the world I was supposed to lay out all the cards in memory and keep track of all the different states had me giving up pretty quickly. | ||
| ▲ | to11mtm 28 minutes ago | parent | next [-] | |
Probably depends on the kind of solitaire IMO. I feel like Klondike, -should- be simple enough with a set of vectors/arrays/lists, the biggest thing is making sure you have the traversal logic right. [0] [0] - I mean, here's an example in VB.NET, where a lot of the game logic is FBOW integrated into the form logic, but hey it apparently is NET8! https://github.com/DualBrain/Solitaire/blob/master/Solitaire... | ||
| ▲ | steve_taylor 31 minutes ago | parent | prev [-] | |
I'd start by identifying all the known boundaries: 52 cards, so each card can be represented by a byte. Cards are arranged into 4 stacks of up to 13 cards each, 7 columns of up to 13 cards each, and a pile of up to 24 remaining cards. (You don't need two piles of remaining cards.) That's 167 (4 * 13 + 7 * 13 + 24) bytes for the cards, 12 bytes to store lengths, and 1 byte to store the current index in the pile of remaining cards. It's a fixed number of fixed-length byte arrays and a fixed number of bytes to track lengths and one index. | ||