[Tutor] Having trouble with a component of the random module

Alan Gilfoy agilfoy at frontiernet.net
Sun Aug 31 18:24:26 CEST 2008


In this case, I was trying to pull 1 card from a 5-card pool, which  
should have worked. There was a typo in my code that I have since  
fixed, and it is working.

I have to make sure manually that I'm not telling the program to pick  
more cards than exist in the list. I can do this two ways: Make the  
list long enough, and tell the selector function to pick a small  
enough amount from that pool.

The following is not related to my code per se, but rather to an  
aspect of MTG booster packs that I have successfully replicated:

In most cases, every common appears at the same frequency as every  
other common, so I normally put each name on the commons list exactly  
once. (and so on for other lists/other rarity levels) Thus, each card  
will be displayed only once per pack, unless I repeat the same name in  
the source list multiple times. (The program sees those repetitions as  
different entities.)

Quoting OmerT <Jaggojaggo+Py at gmail.com>:

> Bob, Kent,
>
> I understood all that from the context and yet do not feel familiar
> enough with the information nor had the time to lookup.
>
> The point I'm making is that Alan has a logical problem with his
> generator regarding the question of repetitive cards in a booster:
> On one hand, the script does not allow to repeat cards. On the other-
> he tries to display 8 cards out of a 5 card pool, which is impossible
> without repeating cards.
>
> That's all..
>
> On Sun, Aug 31, 2008 at 4:00 PM, bob gailer <bgailer at gmail.com> wrote:
>> OmerT wrote:
>>>
>>> I'm unfamiliar with the random.sample function, yet I can't help but
>>> wonder:
>>> Do you ever got the same card twice?
>>>
>>
>> Quoting the manual:
>>
>> sample( population, k)
>> Return a k length list of unique elements chosen from the population
>> sequence. Used for random sampling without replacement.
>>
>> --
>> Bob Gailer
>> Chapel Hill NC 919-636-4239
>>
>> When we take the time to be aware of our feelings and needs we have more
>> satisfying interatctions with others.
>>
>> Nonviolent Communication provides tools for this awareness.
>>
>> As a coach and trainer I can assist you in learning this process.
>>
>> What is YOUR biggest relationship challenge?
>>
>>
>





More information about the Tutor mailing list