[Tutor] list of objects?

bob gailer bgailer at gmail.com
Wed Nov 16 15:26:21 CET 2011

Please always reply-all so a copy goes to the list. Am forwarding this 
on your behalf.

I will reply this afternoon.

On 11/16/2011 7:18 AM, Elwin Estle wrote:
> Part of the reason I am writing this program is to learn OOP, hence 
> the use of classes.  Most of what little programming background I have 
> comes from working with various flavors of BASIC on old Atari 8-bit 
> computers back in the day, and more recently a little Tcl/Tk, so my 
> first instinct is to do everything from a procedural standpoint.  I'm 
> trying to get out of my comfort zone.
> As for the game, I am doing the 'easy' version of spider that uses 8 
> suits of spades.  I was planing to just re-draw the display after each 
> move.  Input-wise, I was just going to use raw_input.  My idea was to 
> have a move consist of a three character coordinate, The 10 dealt 
> piles would be named by letter, A-J, and the cards in each pile would 
> be by number, i.e. 1-nn.  A move would consist of the starting pile, 
> the number of the card in that pile, and the letter of the destination 
> pile, so 'B5H' would move everything from the 5th card down in pile B 
> and put it on pile H.
> ------------------------------------------------------------------------
> *From:* bob gailer <bgailer at gmail.com>
> *To:* Elwin Estle <chrysalis_reborn at yahoo.com>
> *Cc:* "tutor at python.org" <tutor at python.org>
> *Sent:* Tuesday, November 15, 2011 9:18 PM
> *Subject:* Re: [Tutor] list of objects?
> On 11/15/2011 8:40 AM, Elwin Estle wrote:
>> I am attempting to write a text based spider solitaire game.
> What are the rules of your version of Spider? The only spiders I know 
> have 10 dealt piles and 1 draw pile.
> I think you have greatly complicated things by using classes. Consider:
> deck = random.shuffle(range(13)*8) # list of 108 card "indexes" in 
> random order.
> values = "A23456789JQK" # display values corresponding to indexes
> piles = [deck[x:x+10] for x in range(0,108,10)]
> Anytime you want to display the value of a card use values[cardIndex]
> for example to display the last card in each pile:
> for pile in piles:
>   print values[pile[-1]],
> What will your actual display look llike?
> Will you completely reprint it after each move, or alter it in place?
> How will you get the moves from the player?
> -- 
> Bob Gailer
> 919-636-4239
> Chapel Hill NC

Bob Gailer
Chapel Hill NC

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111116/96ca1fc7/attachment.html>

More information about the Tutor mailing list