[Tutor] A class list

Robert Berman bermanrl at cfl.rr.com
Fri Dec 24 20:09:57 CET 2010


I am working on the second part of the 'Bingo' problem defined at the Bingo
Praxis web page, http://programmingpraxis.com/2009/02/19/bingo/. 

My notes as how to best define and build the problem:

'In a large game with five hundred cards in play, what is the average number
of calls required before any card achieves bingo?'

In this version of the simulation we generate 500 unique cards which, by
definition, implies 500 players. Initially, the rules insist there is only one
pass through  the cage.  Since there are 500 players, we have to define a
methodology such that the order of play is random. We first create 500 cards
and assign them to a list so that the first card is referenced by cardlist[0]
and the last card is represented by cardlist[499].
We then generate a random non-replaceable list of these same values (0-499).
This becomes the ordering queue of which card will be played with the current
value pulled from the cage. list.pop() determines the card in action.
Since we only care about the game until it is won, as soon as one card has
bingo, the entire game is finished and the value of all other cards is not
considered in the simulation.
The call counter is incremented every time the cage is accessed.

I am building the program in incremental steps with each step to accomplish a
set functionality. Each step I hope is designed to be tested with relative
simplicity and rather obvious points of success and failure. The first
function is simply to create an array(list) of classes. Rather than testing
for 500 cards in the list, I am currently using 5 cards.

Both the class and the list building function can be seen at:
http://pastebin.com/QNPVec8L .

The problem that is confounding me is that the list is returned where any
member of bingocard.mycard is identical to all the other members of
bingocard.mycard in the list. 
Through a number of tests I have learned that the last card of the list seems
to permeate upward to the first. I have researched building a list of classes
and I think I have done it correctly, but obviously at this point I am not
going to say it should work. What I am asking is 1) Why is the function doing
what it is doing rather than what I thought I programmed it to do, and 2) How
can I code it to do what I want it to do: Produce N number of non duplicated
cards.

OS:  Windows 7.
Python version 2.6.4
IDE: Pycharm 1.1 EAP

Thank you for any and all assistance.

Robert 


--
I am using the free version of SPAMfighter.
We are a community of 7 million users fighting spam.
SPAMfighter has removed 174 of my spam emails to date.
Get the free SPAMfighter here: http://www.spamfighter.com/len

The Professional version does not have this message




More information about the Tutor mailing list