Settings

Theme

Klondike Solitaire game for curses in 5k of C

nanochess.org

102 points by nanochess 6 days ago · 17 comments

Reader

QuaternionsBhop 3 days ago

I recently wrote klondike in Rust after getting frustrated with bugs in my friend's LLM-written version. I highly recommend it as a recreational programming exercise, the first 4 hour blitz filling out the types was a blast. Later, trying to make as many invalid moves unexpressable by the given types as possible was a fun challenge. I ended up with a 232 byte struct for the board state with all values stack-allocated. The only way to make it considerably smaller would probably be to encode card permutations.

baudaux 3 days ago

I put csol in https://exaequos.com:

https://github.com/nielssp/csol

Type: /usr/games/csol in the terminal (or find solitaire)

userbinator 3 days ago

Everyone knows that the != operator is a surplus of the C language, use only the minus operator.

It's notable that on most CPUs, the comparison instruction is equivalent to a subtraction but without writing the actual result.

  • badc0ffee 3 days ago

    Wouldn't XOR or something be much quicker than all the steps involved in subtraction?

    • Sharlin 3 days ago

      They’ve both had the exact same cost (both throughput and latency) on just about any ALU designed in the last several decades. There are no separate steps involved in the function of a full adder.

ares623 3 days ago

I thought games need GPU acceleration and React? How is this possible?

0fflineuser 3 days ago

Made me remember these neovim plugins :

https://github.com/rktjmp/playtime.nvim

https://github.com/rktjmp/shenzhen-solitaire.nvim

The author does some cool stuff.

saurabhsinghvi 3 days ago

My god this is insane! You'll steal a lot of hearts

yalue 3 days ago

Truly the biggest prize of the IOCCC is getting your name listed next to geniuses like the author of nanochess.

mgc8 3 days ago

This is seriously cool, and as a bonus reminds me to brush up on my C knowledge to finally submit an IOCCC entry...

Hugsbox 3 days ago

That source code is melting my brain

patdoli 3 days ago

undo is always where these tiny games stop being tiny

indianmouse 3 days ago

Fantastic read and article.

As an ardent follower of IOCCC since ages (where I learnt a trick or two during the initial C days around late 90s) this is seriously cool!

Many may not even appreciate the power of C! Becoz hardly it is getting taught and used nowadays. People who know knows it better. The laziness and wrappers have taken over the programming world and now AI is taking it to another level.

In near future, I guess people might even forget to code! Where to optimize and obfuscate then? Skilled ones would need to be preserved with awe!

Need to document them (not as a training material for AI for sure!), but somewhere else where it could be learnt by the one who needs it! Privately!

Having it on the internet is definitely prone to stealing / misusing it in the name of fair use policy.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection