我創建了一個python應用程序來玩遊戲Perudo(或者說謊者的骰子)。將微型列表添加到更大的列表
我正在嘗試創建一個函數來計算玩家(或AI)允許進行的所有可能的移動,並返回它們的列表,以便它可以拒絕非法移動。
圈數存儲爲2個數字的列表,例如, [10,6]代表十六個。 如果起始變量currentbid
是[19,3]
(十九三分),並且有20個骰子在場,那麼唯一可能的移動方式是19四十九,五十九,六六十,二十三,二十三,二十四,二十五和二十六。打電話是不允許的。 程序應該輸出上面爲:
[[19,4],[19,5],[19,6],[20,2],[20,3],[20,4],[20,5],[20,6]]
,而是將其作爲:
[[20,6],[20,6],[20,6],[20,6],[20,6],[20,6],[20,6],[20,6]]
我在做什麼錯?
def calcpossiblemoves(self, currentbid, totalnoofdice):
self.possiblemoves = [] # Create a list of possible moves that will be added too
self.bid = currentbid
while self.bid[0] <= totalnoofdice:
while self.bid[1] < 6:
self.bid[1] += 1
self.possiblemoves.append(self.bid) # <- I think the problem is something to do with this line
print(self.possiblemoves) #For tracking the process
# Increase 1st number, reset 2nd number to 1
self.bid[0] += 1
self.bid[1] = 1 # Which will get increased to 2
#print("Reached 6")
return self.possiblemoves
唔......聽起來有點像大話骰或Perudo但沒有1的是特殊的... –
@JonClements是的,我已經把那在後,但它似乎已經消失了!回到現在。 1是特殊的,但我還沒有把它放在:P現在它們只是不可接受的。 – tburrows13