[Tutor] Baccarat code check.
Dave Angel
d at davea.name
Sat Dec 17 10:40:21 CET 2011
On 12/16/2011 03:29 AM, col speed wrote:
> If anyone has the time, please have a look at the attached text file
> and let me know any comments on how to improve it.
> Thanks a lot
> Col
>
I don't see any response for 24 hours, so I'd say that nobody has the
time. However, you could have improved the odds substantially by giving
us a clue what you were looking for.
Is this a program that runs properly, correctly and quickly enough, and
you just want advice on making the code cleaner and clearer?
Or does the program run apparently normally, but gets the wrong results,
and you need help fixing that? If so, tell us specifically what seems
to be wrong: what happens when you run it, and what did you expect
different?
Or does the program die with some exception? in that case, tell us how
to reproduce the symptom, and show us the full traceback when it dies.
Or something else?
....
I can only guess the first case is your supposed situation. So I'll
look it over. I'm not running it, so all i can comment on is obvious
bugs and stylistic errors. I also have to assume you're running it on a
Linux type machine, with Python 2.7.
I don't know baccarat, so I make mistakes on that account.
First obvious problem is that each player has its own kitty. I don't
know of any card game where that is done. But maybe in baccarat the
word means something totally different.
Naming difficulty, getPlayers() cannot reasonably be called more than
once, so it's better named something like init_players().
In class Card, your final else clause looks like a good place for
assert(). It'll never happen in production, but only till the program
has passed its test suite.
In placeBets(), there doesn't seem to be any indication of which person
(name) is betting each time. That should probably be part of the prompt
to raw_input.
In (), the raw_input() that's assigned to standordraw, it doesn't
include the player name in the prompt. This is even more important than
the last, since only a few of the players will get prompted like this
each round.
hope that helps some.
--
DaveA
More information about the Tutor
mailing list