In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "python how to achieve simple tic-tac-toe Mini Game". The content in the article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "how to achieve simple tic-tac-toe-chess Mini Game with python".
Window
Omnipotent windows, implementation windows can be simply modified to use:
From tkinter import * root = Tk () # window name root.title ("Han Gang") f1=Frame (root) f1.pack () w1 = Canvas (F1, width=580,height=580,background='lightcyan') # create a canvas, set the size and background color w1.pack () root.mainloop ()
Draw a chessboard
# draw the chessboard for i in range (0,4): w1.create_line (I * 180 + 20,560) w1.create_line (20,180 + 20560, I * 180 + 20)
Draw horizontal and vertical lines, four horizontal lines and four vertical lines to generate nine grids. Can also draw two horizontal and two vertical, closer to the shape of the well character. Just draw fewer lines, for example:
For i in range (1,3): w1.create_line (I * 180 + 20,20,560) w1.create_line (20,180 + 20,560, I * 180 + 20)
Num = 0 # record the number of clicks, which is used to determine which figure to draw after clicking A = np.full ((3,3), 0) # graphic algorithm for recording each location
After each click, we have to draw pictures and determine whether we meet the conditions for winning.
Setting function
Def dawn (event): global W1 global num, A for i in range (0,3): for j in range (0,3): if 20 + j * 180 < event.y and event.y
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.