所以我下载了Deuces,用于扑克手评估的代码,最初我认为是在Python 2中,因为所有的print语句都没有括号。我把所有这些都修好了,除了最后一部分,一切似乎都正常。这是它的代码:
def get_lexographically_next_bit_sequence(self, bits):
"""
Bit hack from here:
http://www-graphics.stanford.edu/~seander/bithacks.html#NextBitPermutation
Generator even does this in poker order rank
so no need to sort when done! Perfect.
"""
t = (bits | (bits - 1)) + 1
next = t | ((((t & -t) / (bits & -bits)) >> 1) - 1)
yield next
while True:
t = (next | (next - 1)) + 1
next = t | ((((t & -t) / (next & -next)) >> 1) - 1)
yield next我在网上发现他们是位操作符,但我不明白为什么python不认识他们。我需要导入什么吗?还是那些运算符没有在python 3中使用?
File "/Volumes/PROJECTS/deuces/All_poker.py", line 709, in get_lexographically_next_bit_sequence
next = t | ((((t and -t) / (bits and -bits)) // 2) - 1)TypeError:不支持的操作数类型(S),用于:“浮动”和“浮点数”
这是我得到的错误,代码可以在https://github.com/vitamins/deuces/tree/8222a6505979886171b8a0c581ef667f13c5d165找到
它是查找类的最后一部分。
当我写
board = [ Card.new('Ah'), Card.new('Kd'), ('Jc') ]
hand = [ Card.new('Qs'),Card.new('Th')]
evaluator=Evaluator()在最后一行代码中,我得到了错误。所有代码都可以在链接中找到。
发布于 2017-06-03 01:26:40
这是/符号,就像这位先生上面说的,它应该是地板分割的,而且是快速修复的,它工作得很好。
发布于 2017-06-02 19:09:43
与Arrivillaga的评论一致,我刚刚修改了您在这里发布的内容。
def get_lexographically_next_bit_sequence(bits):
"""
Bit hack from here:
http://www-graphics.stanford.edu/~seander/bithacks.html#NextBitPermutation
Generator even does this in poker order rank
so no need to sort when done! Perfect.
"""
t = (bits | (bits - 1)) + 1
next = t | ((((t & -t) // (bits & -bits)) >> 1) - 1)
yield next
while True:
t = (next | (next - 1)) + 1
next = t | ((((t & -t) // (next & -next)) >> 1) - 1)
yield next
for i, g in enumerate(get_lexographically_next_bit_sequence(123)):
print (g)
if i > 10:
break这些结果是否合理?
125
126
159
175
183
187
189
190
207
215
219
221https://stackoverflow.com/questions/44335494
复制相似问题