import random
pOnePos =[0,0]
pTwoPos =[0,0]
board = [['1','2','3','4','5','6','7'],
['8','9','10','11','12','13','14'],
['15','16','17','18','19','20','21'],
['22','23','24','25','26','27','28'],
['29','30','31','32','33','34','35'],
['36','37','38','39','40','41','42'],
['43','44','45','46','47','48','49']]
newpos = pOnePos
rnd = random.randrange(1,7)
newpos[1] += rnd
board[pOnePos[0]][pOnePos[1]]="P1"
for row in board:
print("\t".join(row))
任何人都可以放弃一些光线,这样我就可以继续,我不希望任何人做解决方案,但解释我如何跳元素并保留一个数字,当然我也将保持与此总数所以我知道即时通讯位置33,如果我掷骰子到达这个数字。感谢
答案 0 :(得分:0)
您可以将卷的总和存储在附加变量
中sum_of_rolls+=rnd
并将行计算为
row=sum_of_rolls//size_of_row
其中size_of_row在您的情况下为7,然后计算列(行中的位置)为
column=sum_of_rolls-row*size_of_row
然后访问董事会
board[row][column]