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


The main menu

Playing a game

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

Source

You can download the source code here:



GPL version 3

Return to Veche.Net Home.