0
您好我一直在嘗試在Python中構建井字遊戲,因此我正在檢查相鄰符號的列表清單。我知道代碼並不優雅。但我主要關心的是,這個例程給我隨機結果。你們能看到爲什麼嗎?Python。相鄰空格列表檢查列表
def winx(self):
if self.current_table [0][0] and self.current_table [0][1] and self.current_table[0][2]== "x":
print "Good Boy, you won"
self.winner=1
elif self.current_table [1][0] and self.current_table [1][1] and self.current_table[1][2]== "x":
print "Good Boy, you won"
self.winner=1
elif self.current_table [2][0] and self.current_table [2][1] and self.current_table[2][2]== "x":
print "Good Boy, you won"
self.winner=1
elif self.current_table [0][0] and self.current_table [1][0] and self.current_table[2][0]== "x":
print "Good Boy, you won"
self.winner=1
elif self.current_table [0][1] and self.current_table [1][1] and self.current_table[2][1]== "x":
print "Good Boy, you won"
self.winner=1
elif self.current_table [0][2] and self.current_table [1][2] and self.current_table[2][2]== "x":
print "Good Boy, you won"
self.winner=1
elif self.current_table [0][0] and self.current_table [1][1] and self.current_table[2][2]== "x":
print "Good Boy, you won"
self.winner=1
elif self.current_table [0][2] and self.current_table [1][1] and self.current_table[2][0]== "x":
print "Good Boy, you won"
self.winner=1
else:
self.winner=None "
Maan ....我的大腦融化了..謝謝! – 2014-08-30 20:28:11