[Tutor] Programming the behavior of a set of domino
chainsawtiney at gmail.com
Fri Feb 23 19:07:48 CET 2007
I am a newbie in computer programming and I am also not a native
English Speaker. I love to play domino and I would like to program a
simple domino game in python. Also a good opportunity for me to learn
some computer programming.
I need some help in my code which programming the behaviors of a set of domino.
Here is the code, generally a modification of the code from the deck
of card example in How to Think like a Computer Scientist.
if self.a_end==other.b_end and self.b_end==other.a_end:
self.dominoes = 
self.set_type = set_type
for a_end in range(self.set_type+1):
for b_end in range(self.set_type+1):
for domino in self.dominoes:
newdomino = deck(12)
each piece of domino have a_end and b_end. domino (1,2) and
domino(2,1) is the same and thus one of them should be removed. Now,
deck(12) will return 169 dominoes while the expected number of
dominoes is 91. Even I wrote a __cmp__ method for domino, list
membership (i.e. x in list) is not working because they are not a
Can anyone shed me some light to solve this problem?
"The scientists of today think deeply instead of clearly. One must be
sane to think clearly, but one can think deeply and be quite insane."
More information about the Tutor