Solitaire with text-based interface in C
github.comI've just finished implementing my Solitaire game with curses interface in C. Solitaire was the first computer game I have played and I never got around to implementing it.
This is a writeup of how the game was made, using the vim+gcc+gdb stack.
Although working on a completely different tech stack at work, I like C, there's something zen-like about being close to the machine and almost universally portable.
Good post, but why not link to the post on your github.io domain? https://jborza.github.io/games/2020/07/12/solitaire-cli.html
I probably would have opted for the array representation instead of linked lists, but that is somewhat subjective thing. I do note that each card can be represented by single byte fairly easily (2 bits for suit, 4 bits for rank, 1 bit for revealed (maybe)), which would reduce memory consumption if that is concern. Thinking more of it, I think the whole board-state could be represented with 13+52 byte array, having markers between the cards to indicate different piles. Not that I'd recommend that approach unless you are extremely memory constrained, it probably would bit annoying to handle
fyi I noticed that your mallocz seems to reimplement calloc: https://pubs.opengroup.org/onlinepubs/009695399/functions/ca...
> I think the whole board-state could be represented with 13+52 byte array, having markers between the cards to indicate different piles.
A multiple-gap buffer is more difficult to handle than a linked list, yeah.
Neat. I've made an implementation of Solitaire in JS (React/HTML/GSAP) - https://online-solitaire.com/ - but really interesting how it can be done in a low-level language like C.
Good game and good implementation;
Mac need to use ncurses and no tinfo and not sure the implication.
And do not type c8, segment fault. Thought it use linked list not array ...
Very good game and play a few round
Thanks for finding the bug - I haven’t caught this one! It crashes because it wasn’t checking the column id, that’s an array of piles in game_state, the piles themselves are linked lists.
Linking without tinfo shouldn’t be a problem
Still playing it and do a pull request even, plus a further plan to upgrade yous. But the pull request has a minor bug which I fix. Life in a day of programmer I supposed.
Just stop to have more idea ... like multi user ... AI study etc. and touching for awhile. A new branch is developed as a base for my future self to work with. Need to do more serious work for my lovely fallen place. In the mean time, I guess I understand why again those hacker in the 70s doing text game (and also one on cathode tube) using the Internet then. It is all addictive. Have to stop :-)
Other than no typing c8, finish at least two full game and it is ok. Better not to play it la. Too addictive.