[Edu-sig] Cards n stuff...

Kirby Urner pdx4d@teleport.com
Tue, 13 Mar 2001 17:24:24 -0800


Just for the fun of it, I added a little more code, tweaked 
what I already had, to make a game _something like_ Blackjack.  

I say _something like_ because I don't actually know much 
about card games and I've probably messed up the rules some 
-- plus I left out the whole thing about money, and there's 
only one other player etc. etc. -- plenty of room for 
improvement.

A game loop looks like this:

 >>> reload(cards)
 <module 'cards' from 'g:\python21\ocn\cards.py'>
 >>> cards.play()
 Your hand: [6 of Diamonds, 2 of Diamonds], Value: 8
 Other guy: [8 of Diamonds, 6 of Clubs], Value: 14
 Do you want a card? (Y/N)y
 Your hand: [6 of Diamonds, 2 of Diamonds, 10 of Spades], Value: 18
 Other guy: [8 of Diamonds, 6 of Clubs, 8 of Spades], Value: 22
 You win!!
 Play again? (Y/N)y
 Your hand: [7 of Diamonds, 8 of Diamonds], Value: 15
 Other guy: [Ace of Spades, Ace of Diamonds], Value: 2
 Do you want a card? (Y/N)n
 Your hand: [7 of Diamonds, 8 of Diamonds], Value: 15
 Other guy: [Ace of Spades, Ace of Diamonds, 9 of Hearts], Value: 11
 You win!!
 Play again? (Y/N)n

The module is here:
http://www.inetarena.com/~pdx4d/ocn/python/cards.py

Kirby