C Durak
What is C Durak?
C Durak is an implementation of the card game Durak, popular throughout much of the former Soviet Union, written in C. It is entirely terminal-based, drawn using a basic text user interface using box drawing characters or ASCII. It includes two different versions of the game, Podkidnoi (standard) and Perevodnoi (passing) Durak.
The code at present is still a little bit buggy, but these bugs (at least as far as I can tell) do not impact actual gameplay; the biggest issues are simply the game messages losing track of who is who, though as far as game rules are concerned there are no issues. I also have not checked the code extensively for memory leaks, but whatever ones there may be at present, they are not significant.
The AI is very basic, but it shouldn't be too hard to make it more interesting.
Screenshots
What's It Written In?
The entire code was written in C.
Installation Instructions
Simply download the code, run make and then make install to move the compiled binary to /usr/local/bin. To run, just run durak.
How to Play
For game rules, enter 3 at the main menu.
To play a card, enter the number displayed directly below the card. To play the fourth card in your hand, for instance, enter 4.
To end your turn, type end.
To pass, type pass.
For a hint, type hint. If it is your turn to make the first move, a "?" will appear beneath the card that the AI would play if it had your hand. At any other time, a "^" will appear under every card that is currently legal to play.
To quit and return to the main menu, type quit.
Graphical Issues
If you try to run the game and you see a bunch of random letters rather than clean lines (like in the screenshots), there are two things you can do.
First, try typing the following line into the terminal:
echo "X[mX(BX)0OX[?5lX7X[rX8" | tr "XO" "\033\017"
C Durak draws in the terminal by switching into and out of a graphical character set in VT100-like terminals. If for whatever reason the terminal is unable to perform the character set translation, the above line should reset the translation tables between ASCII and the box-drawing character set. I've confirmed this works in both Mac OS X and Ubuntu, at the very least.
If that still doesn't work, try switching to the lower-quality ASCII-based graphics. From the main menu, select "Options" (5), and then "Low-Quality (ASCII)" (2). It doesn't look quite as nice, but it's better than the alternative.
Version History
- 0.2.1 (9 March 2011)
- Graphical improvements: player names will now always stay aligned with their hand, even when they have a small number of cards or no cards at all
- User input is now validated to make sure it's a legal play. No more cheating!
- Changed the start conditions so that the player with the lowest trump goes first, not just Player 1 all the time.
- Bugfix: Perevods in two-player games and strings of three or four perevods in a row are now recognized correctly
- 0.2.0 (6 March 2011)
- Added the 'throw-in' round that takes place after a player decides they are taking cards. All major features of the game are now present
- A few minor improvements to how the game board is drawn
- Bugfix: Fixed the deck shuffling glitch when the user visited the options page prior to starting a new game
- 0.1.7 (5 March 2011)
- Added (very basic) input validation; it still doesn't make sure you've made a legal move, but it checks everything else
- Added recognition of drawn games (no loser)
- Added in-game "quit" command to immediately end a game and return to the main menu
- Bugfix: Passing and taking cards is now functioning correctly at the end of the game
- Bugfix: Status messages are now displaying the correct information towards the end of the game
- Bugfix: "hint" is now fully functional, and will now recommend cards other than hearts in first-round attacks
- Bugfix: Game now correctly handles passing (though the status messages are screwy if one or more players is out)
- Bugfix: Cards will actually be dealt if the opponent takes a card immediately with no counter
- Bugfix: Dealing animation should now work properly when the trump is being dealt
- 0.1.6 (24 February 2011)
- Perevodnoi is now functional. However, the AI doesn't know how to use it yet.
- Bugfix: Using "hint" when doing a non-first-round attack now works.
- Bugfix: Fixed "hint" in perevodnoi mode for counterattacks.
- New Bug: There appear to be some issues with players being skipped when passing takes place
- 0.1.5 (17 February 2011)
- Partial Georgian localization. Will be completed at some point.
- 0.1.4 (12 February 2011)
- Added French localization
- 0.1.3 (11 February 2011)
- Added Ukrainian localization
- 0.1.2 (10 February 2011)
- Reworked string handling to make strings modular more easily editable.
- Added low-quality graphics mode, if box drawing characters do not work
- Added Russian localization
- 0.1.1 (7 February 2011)
- Endgame bugfixes
- Implemented a (buggy) perevodnoi module
- Code is now compilable on Linux, though not without a lot of warnings; TUI not yet functional
- 0.1.0 (6 February 2011)
- Functional game release for Mac OS X
- Podkidnoi durak largely functional, though missing throw-ins when a player takes cards
- Includes rule page and about page
- Main menu present
Source
You can download the source code here:
- durak_v0_2_1.zip (41KB compressed, 180KB uncompressed)
- durak_v0_2_1.tar.gz (29KB compressed, 180KB uncompressed)
Return to Veche.Net Home.

