Skip to content

Latest commit

 

History

58 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kozmonot

Kozmonot

Batak, the Turkish trick-taking game, in plain bash. One file, no dependencies, four players: you and three machines that bid their hands and play defence like they mean it.

a trick in progress, waiting on your card

running it

chmod +x Kozmonot.sh
./Kozmonot.sh

Options, all optional:

-r, --rounds N   deals to play (default 5)
    --seed N     same shuffle every run, if you want a rematch
    --fast       skip the little pauses
    --ascii      S H D C instead of suit symbols
    --no-color   monochrome

You need bash and a terminal that can clear itself. Colors come from tput and degrade gracefully; a UTF-8 locale gets you real suit symbols, anything else falls back to letters on its own. Written against bash 5 and kept working on 3.2, which is what /bin/bash still is on a Mac. Around 64 columns of width is plenty.

While playing you steer with the arrow keys. Left and right walk along the cards you are allowed to play, enter puts the highlighted one down. Cards the rules forbid are greyed out and the cursor skips straight past them, so you cannot pick one by accident. h pulls up what has been played, q quits.

Bids are still typed, as is the trump suit when you win one. If you pipe input in rather than sitting at a terminal you get the old typed card prompt instead (qs for the queen of spades, 10d or td for the ten of diamonds), which is handy for scripting it.

the game, briefly

Everyone gets 13 cards. Starting left of the dealer, players bid the number of tricks they promise to take, minimum 5, each bid higher than the last, pass and you are out of the auction. If all four pass the dealer is stuck with a contract of 4. The winner names trump; there is no notrump in this game.

The bid winner leads. Three rules give batak its flavor. You cannot lead trump until a trump has been played some other way, unless your hand is nothing but trump. When you cannot follow suit you must play a trump if you hold one. And if you can follow suit, you have to beat whatever is winning the trick when you can, and any card that tops it will do, so you can drop the nine and keep the ace back.

Highest card of the led suit takes the trick unless somebody trumped; then the highest trump takes it.

Scoring each deal:

  • bidder makes the contract: 10 x bid, plus 1 per overtrick
  • bidder falls short: minus 10 x bid
  • everyone else: 1 point per trick taken
  • a non-bidder who takes no tricks at all loses the bid instead

Dealer moves one seat per deal. Highest total after the last deal wins.

reading the screen

The middle of the table shows what has been played this trick, with a ? on whoever it is waiting for. Your hand sits underneath, one row per suit. Playable cards are bright, the rest go dim, and the one under the cursor is inverted and bracketed on the line below. Trump is drawn in yellow wherever it appears, so ♥ stands out from the red of a plain heart when hearts are trump.

The line under the table spells out what you can play, and when the rules have narrowed things it says why. (you have to beat ♣9) saves you working that out for yourself.

h, for what has gone

Counting cards in your head is half the game and none of the fun, so h does it for you. Per suit: what has been played, what you are holding, and what is therefore still in somebody else's hand. That last row is the one you cannot get by staring at the table.

the h screen, showing played and outstanding cards by suit

tests

make test runs the rule and scoring units plus a batch of seeded games with the computer in every seat. make referee is the paranoid one: it replays 60 rounds and re-checks every card against the rules written out longhand, so a bug in the legality check can't pass by agreeing with itself. make check runs both.

TESTING.md has the manual checklist and the debugging knobs (fixed seeds, autoplay, fast mode).

About

Trick-taking card game for your terminal. One bash script, no dependencies.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages