War

About war:

War is an Ada 95 program that repeatedly plays the children's card game of war. After playing a number of games, the program tallies up some statistics on wins and losses. It also prints out an ASCII plot of how long the games took.

The inspiration for many of the algorithms used in the program came from Dr. Michael B. Feldman's book Software Construction and Data Structures with Ada 95, Addison-Wesley, 1997, ISBN 0-201-88795-9.

Sample output:

Working...
Of 10000 games, 9896 ended before 1200 plays.
West won:       4971
East won:       4925
Average length: 317
Standard dev.:  221
Longest game:   1197
Shortest game:  33
W: K 4 T 9 A A 8 6 J J A 4 2 7 Q 6 Q Q Q 5 K 9 T J 8 3
E: 7 8 T 4 A 7 3 2 6 7 K K 9 4 3 5 8 9 J 3 T 5 5 2 6 2
Distribution of lengths:
0000-0100 |**********
0100-0200 |*****************************
0200-0300 |**********************
0300-0400 |***************
0400-0500 |**********
0500-0600 |*******
0600-0700 |****
0700-0800 |****
0800-0900 |**
0900-1000 |**
1000-1100 |*
1100-1200 |*

Source code:

Disclaimer:

Copyright 1998 by John B. Matthews. This program is distributed under the terms of the GNU General Public License (GPL), incorporated herein by reference. The author disclaims any liability arising out of use of this program, including (but not limited to) the time you waste playing with it. Happy programming!

Last updated 5-Jan-2019