资 源 简 介
This program was written with copious comments to illustrate some aspects of Python that may help the beginner with the language. The nominal purpose of the program is to have the computer play the card game of war against itself.
The program is called class-warfare because I"ve tried to use object-oriented methods wherever possible.
An interesting phenomenon was discovered during the writing of this program: if the cards captured by the victor are returned to the winner"s hand without being shuffled, there is a chance that the game will devolve into an infinite loop. There are two command line options that can demonstrate this.
If the program is run with these options:
$ ./class-warfare-v2.0.py -s -f
The program will bail after 5000 rounds as it is most likely headed into an infinite loop.
The -s option directs the program to use a simplified deck. The -f option directs the program to not shuffle the spoils (the captured cards) as they are