On 03/23/2013 10:35 AM, Robert Sjoblom wrote:
As I said, I don't really understand why a roulette outcome has a name in
the first place, but given that it does, I don't any problem with comparing
the names directly. Still, I would probably write it as an __eq__ method,
since it's easier to write a == b than a.name == b.name.
I figured that it would be easier if outcomes had names. Consider that
each Bin (where the ball lands) can contain between 2 to 14 different
winning outcomes. Each Bin() collects various Outcome()s, each
Outcome() handles the amount won. Consider the '1' Bin, it contains
the following winning Outcome()s:
  “1”, “Red”, “Odd”, “Low”, “Column 1”, “Dozen 1-12”, “Split 1-2”,
“Split 1-4”, “Street 1-2-3”, “Corner 1-2-4-5”, “Five Bet”, “Line
1-2-3-4-5-6”, “00-0-1-2-3”, “Dozen 1”. All of these bets will payoff
if the wheel spins a “1”.

I'm almost done with the Outcome() class (just writing the unittests
for it), after that I'll tackle the Bin class, at which point I will
definitely return for more questions. As I said before, thanks to
everyone who answered.


So you're using the name attribute to match the Outcome instance in the Bin slot against the Outcome instance in the Betting slot? Have you considered just making exactly one instance of each Outcome, and then you can use something like:

for mybet in bets:
    if mybet.outcome in bin[1]:
           ...do calculation

bin is a simple list describing the wheel, and mybet describes an individual bet. mybet.outcome is the particular Outcome, like "Odd".

--
DaveA
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to