我是初中的菜鸟。我有一小段代码不起作用:
board=[]
temp=[]
for var0 in range(17):
temp.append(' ')
for var in range(17):
board.append(temp)
class group:
def __init__(self):
self.f=[]
self.x=[]
self.y=[]
groupb=[]
groupw=[]
while 1:
for var0 in range(17):
for var1 in range(17):
if var1==16:
print((board[var0])[16])
else:
print((board[var0])[var1],end='')
move=input()
move=(move.lower()).split()
move[1]=int(move[1])
move[2]=int(move[2])
if move[0]=='b':
board[move[1]][move[2]]=' b'
for var0 in range(len(groupb)):
if (move[1]-1 in groupb[var0].x or move[1]+1 in groupb[var0].x or move[1] in groupb[var0].x) and (move[2]-1 in groupb[var0].y or move[2]+1 in groupb[var0].y or move[2] in groupb[var0].y):
(groupb[var0].x).append(move[1])
(groupb[var0].y).append(move[2])
temp=1
if temp!=1:
groupb.append('')
groupb[len(groupb)-1]=group()
elif move[0]=='w':
board[move[1]][move[2]]=' w'
for var0 in range(len(groupw)):
if (move[1]-1 in groupw[var0].x or move[1]+1 in groupw[var0].x or move[1] in groupw[var0].x) and (move[2]-1 in groupw[var0].y or move[2]+1 in groupw[var0].y or move[2] in groupw[var0].y):
(groupw[var0].x).append(move[1])
(groupw[var0].y).append(move[2])
if temp!=1:
groupw.append('')
groupw[len(groupb)-1]=group()
else:
print('TurnError')
但是每次我尝试运行它时,当我只想要一个字符时,它就会吐出一整列:
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
谁能告诉我我做错了什么?我真的很困惑。