Compare commits

...

2 Commits

Author SHA1 Message Date
OMGOMG 0124fbf489 add man page 2022-04-07 01:42:17 +02:00
OMGOMG 4e10cd3a72 pick more sensible file names 2022-04-07 01:24:07 +02:00
4 changed files with 55 additions and 8 deletions

View File

@ -1,11 +1,17 @@
Simple card game.
# Fire
# Usage
A simple card game.
`./play.bash`
## Usage
`./fire`
Play a single game.
`./stats.bash`
`./stats`
Play a number of games and look at the stats.
`man -l fire.6`
Read the manual.

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Usage:
# ./play.bash
# ./fire
alice_sum=0
bob_sum=0

41
fire.6 Normal file
View File

@ -0,0 +1,41 @@
.TH FIRE 6 2022-04-07 "1.0" "Card game"
.SH NAME
fire - a fun card game
.SH SYNOPSIS
.B ./fire
.br
.B ./stats
[ num_trials ]
.SH DESCRIPTION
.B fire
simulates a game of cards between Alice and Bob. The game is played with a deck
of cards with multiple suits, and ranks defined in the file
.IR deck .
Each player gets a hand consisting of all the cards of a given suit, and one suit is also distributed in the
.IR prize
pile. This pile is shuffled.
Each round consists of a card placed faced up from the
.IR prize
pile, after which Alice plays a card of the same rank, and Bob plays a random
card. The player with the highest card adds the rank of the
.IR prize
card to his or her score. When all cards have been played, the game is over, and
the player with the highest score wins.
.B stats
runs the game a number of times and prints some statistics.
.SH OPTIONS
None.
.SH BUGS
None known.
.SH "SEE ALSO"
.BR shuf (1),
.BR paste (1),
.BR awk (1)

View File

@ -1,13 +1,13 @@
#!/usr/bin/env bash
# Usage
# ./stats.bash
# ./stats
# or
# ./stats.bash NUM_SIMULATIONS
# ./stats NUM_SIMULATIONS
for ((i=0; i < ${1:-100}; i++))
do
./play.bash
./fire
done | awk '
/^[[:alnum:]]+ vinner!$/ {
win[$1]++