How to write a Solitaire game (DOS programming)

preview_player
Показать описание
Earlier this year, I recorded a video series to teach you how to writing FreeDOS programs in the C programming language. As part of that series, I wrote a simple turn-based game; the ancient Egyptian board game, Senet.

At the time, I decided not to write a Solitaire game, because Solitaire has a lot of details that quickly become tricky. But the question remains: how would you write a Solitaire game in C? Let's take a look!

Want to learn more? Watch and follow along with the "C programming" series:

Buy my book 'Writing FreeDOS Programs in C' - this will go out of print after December 2020.

Join us on Facebook

Follow us on Twitter

Consider supporting me on Patreon
Рекомендации по теме
Комментарии
Автор

This is so dope watching programming on ms-dos. Love your content.

davidhart
Автор

Coding on DOS is so pleasant.
Thanks again for this teaching material.

LMchip
Автор

Respect. In 2020 Still following your amazing works on dos

quovadisdorime
Автор

It was a long time ago. I was a DOS programmer. I always used the Turbo C IDEs. They were so easy to use. It was just a lot of fun back then. This is a very good card sorting program.

jeffwise
Автор

I like programming in DOS. No libs to update. No OS upgrades. No "no longer supported libs" Just you and the C compiler.

MichaelRusso
Автор

the is_black function could be further optimized to a macro IS_BLACK(suit) ( (suit) & 2 )

Or you could drop the struct since there's 52 cards in a deck meaning the whole set can be represented in 6 bits AABBBB where B represents 0-13 and A represents the suit. The whole thing can fit in a single uint8_t (saving 3 bytes over the struct), with an extra 2 bits leftover, perhaps useful for identifying the owner of the card in a game of up to 4 players.

IS_BLACK(card) ( (card) & 0x20 )
VALUE_OF(card) ( (card) & 0xF )
SUIT_OF(card) ( (card >> 4) & 0x3 )
OWNER_OF(card) ( (card >> 6) & 0x3 )

BradenBest
Автор

Nice to see another C video. Now I know why in some games I have the same RNG seed when I run two instances at the same time. Thanks!

emem
Автор

DOS is still the best desktop operating system.

spearPYN
Автор

Very cool! Never used the editor you are using, I will have to check that out!

RetroTechChris
Автор

Fantastic! How would you then delete a card once it has been dealt in the game?

stupossibleify
Автор

Can you write Turbo Pascal/C IDE clone ?

MarioLacko