import random from PIL import Image,ImageTk import math import random import time class Chess: def __init__(self): # 设计五子棋运行的数据结构 self.ChessData = [[{"Cstate": 0, "Cstep": 0} for j in range(19)] for i in range(19)] def main(self): i = random.randint(0, 18) j = random.randint(0, 18) for color in range(1, 3): self.ChessData[i][j]['Cstate'] = color print(self.ChessData[i][j]) if __name__ == '__main__': chess=Chess() chess.main()