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()
现在我想在python 3中复制游戏suduko,当我点击棋盘上的方框询问号码时我需要帮助,然后你可以将方框更改为所需的数字,我有{{1我要激活并将空框更改为所需的数字。谢谢你的帮助。