Python Suduko在单击时询问号码并打印 来自处理导入的* 回合=无 玩家字母=无 计算机字母=无 board=[[None,None,None,None,None,None,None,None], [无,无,无,无,无,无,无,无,无,无], [无,无,无,无
Suduko在单击时询问号码并打印 来自处理导入的Python Suduko在单击时询问号码并打印 来自处理导入的* 回合=无 玩家字母=无 计算机字母=无 board=[[None,None,None,None,None,None,None,None], [无,无,无,无,无,无,无,无,无,无], [无,无,无,无,python,Python,Suduko在单击时询问号码并打印 来自处理导入的* 回合=无 玩家字母=无 计算机字母=无 board=[[None,None,None,None,None,None,None,None], [无,无,无,无,无,无,无,无,无,无], [无,无,无,无,无,无,无,无,无,无], [无,无,无,无,无,无,无,无,无,无], [无,无,无,无,无,无,无,无,无,无], [无,无,无,无,无,无,无,无,无,无], [无,无,无,无,无,无,无,无,无,无], [无,无,无,无,无,无,无,
*
回合=无
玩家字母=无
计算机字母=无
board=[[None,None,None,None,None,None,None,None],
[无,无,无,无,无,无,无,无,无,无],
[无,无,无,无,无,无,无,无,无,无],
[无,无,无,无,无,无,无,无,无,无],
[无,无,无,无,无,无,无,无,无,无],
[无,无,无,无,无,无,无,无,无,无],
[无,无,无,无,无,无,无,无,无,无],
[无,无,无,无,无,无,无,无,无,无],
[无,无,无,无,无,无,无,无,无,无],]
x=输入(“您想要什么号码”)
def牵引板(板):
对于范围内的y(透镜(板)):
对于范围内的x(len(板[0]):
冲程重量(5,0,0,0)
noFill()
rect(0,0150150)
rect(150,0150150)
rect(300,0150150)
rect(0150150)
rect(0300150150)
rect(150150)
rect(150300150150)
rect(300150150)
rect(300150150)
冲程(0,0,0)
冲程重量(1,0,0,0)
矩形(x*50,y*50,50,50)
def提款信(董事会):
对于范围内的行(len(board)):
对于范围内的列(len(板[0]):
如果板[行][列]!=无:
文本大小(32)
填充(0,0,0)
文本(板[行][col],col*50+12.5,
行*50+37.5)
def get_starting_player():
随机数=int(随机数(2))
返回“玩家”
def run_player_turn(球员字母):
全球董事会
如果按下mouse.y//50][mouse.x//50]==None和(mouse.x<450),则(mouse.y请在您的技术问题中更具体一点。我想这样做,当我点击一个框时,我可以输入一个数字,它会将变量X更改为它,然后每次我点击另一个框时,它都会重复这个过程。我建议您不要将整个程序作为问题发布。只是您需要帮助的部分。我们无法解决您的一般问题,但我们很乐意帮助您解决您需要的主要问题的每一部分。到目前为止,我只能看到一个大代码和一个格式不太好的问题。这就是我发表评论的原因。
from processing import *
turn = None
player_letter = None
computer_letter = None
board = [ [None, None, None, None, None, None, None, None, None],
[None, None, None, None, None, None, None, None, None],
[None, None, None, None, None, None, None, None, None],
[None, None, None, None, None, None, None, None, None],
[None, None, None, None, None, None, None, None, None],
[None, None, None, None, None, None, None, None, None],
[None, None, None, None, None, None, None, None, None],
[None, None, None, None, None, None, None, None, None],
[None, None, None, None, None, None, None, None, None],]
x = input("What number would you want")
def drawBoard(board):
for y in range(len(board)):
for x in range(len(board[0])):
strokeWeight(5,0,0,0)
noFill()
rect(0,0,150,150)
rect(150,0,150,150)
rect(300,0,150,150)
rect(0,150,150,150)
rect(0,300,150,150)
rect(150,150,150,150)
rect(150,300,150,150)
rect(300,150,150,150)
rect(300,300,150,150)
stroke(0,0,0)
strokeWeight(1,0,0,0)
rect(x*50, y*50, 50, 50)
def drawLetters(board):
for row in range(len(board)):
for col in range(len(board[0])):
if board[row][col] != None:
textSize(32)
fill(0,0,0)
text(board[row][col], col*50+12.5,
row*50+37.5)
def get_starting_player():
random_num = int(random(2))
return 'player'
def run_player_turn(player_letter):
global board
if mouse.pressed and board[mouse.y//50][mouse.x//50] == None and (mouse.x< 450) and (mouse.y<450):
board[mouse.y//50][mouse.x//50] = player_letter
x = input("What number would you want")
return True
else:
return False
def setup():
size(450, 450)
global board
global turn
drawBoard(board)
turn = get_starting_player()
global player_letter
global computer_letter
if turn == 'player':
player_letter = x
computer_letter = '2'
else:
player_letter = x
computer_letter = '2'
def check_win(board, letter):
return False
def check_tie(board):
for row in range(len(board)):
for col in range(len(board[0])):
if board[row][col] == None:
return False
return True
game_ended = False
def draw():
global board
global player_letter
global computer_letter
global turn
global game_ended
if turn == 'player' and game_ended == False:
if run_player_turn(player_letter):
if check_win(board, player_letter):
game_ended = True
elif check_tie(board):
game_ended = True
print("ya tied person so sad")
else:
turn = 'player'
drawLetters(board)
run()