Created
February 27, 2020 06:10
-
-
Save qiuwei/a0c7eee89e5e8d75edb477858213c30b to your computer and use it in GitHub Desktop.
poetry_slow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[tool.poetry] | |
name = "test_poe" | |
version = "0.1.0" | |
description = "" | |
[tool.poetry.dependencies] | |
python = "^3.7" | |
allennlp = "^0.9.0" | |
[tool.poetry.dev-dependencies] | |
pytest = "^5.2" | |
[build-system] | |
requires = ["poetry>=0.12"] | |
build-backend = "poetry.masonry.api" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#Крестики-нолики. Играют два человека, можно играть клавиатурой или клавишами qweasdzxc
from tkinter import *
import tkinter.messagebox
#выход из приложения
def exit_(event):
root.destroy()
#справка
def pomosh(event):
tkinter.messagebox.showinfo("Справка по игре.",
"F1 - Инфа.\n"+
"F12 - Новая игра.\n"+
"Ecs - выход из игры.\n"+
"Автор Сечак.Е.Н\n"
"группа №1652\n")
#начать занаво
def begin(event):
global butn
global field
global numButton
for b in butn:
b.config(bg="green",text = '')
field = [0, 0, 0, 0, 0, 0, 0, 0, 0]
numButton = []
#логика приложения
def logik():
global field
global numButton
if len(numButton) == 9:
tkinter.messagebox.showinfo("Конец игры", " Ничья!!! ")
else:
end = False
if field[0] == field[1] == field[2] > 0:
winner = field[0]
end = True
elif field[3] == field[4] == field[5] > 0:
winner = field[3]
end = True
elif field[6] == field[7] == field[8] > 0:
winner = field[6]
end = True
elif field[0] == field[3] == field[6] > 0:
winner = field[0]
end = True
elif field[1] == field[4] == field[7] > 0:
winner = field[1]
end = True
elif field[2] == field[5] == field[8] > 0:
winner = field[2]
end = True
elif field[0] == field[4] == field[8] > 0:
winner = field[0]
end = True
elif field[2] == field[4] == field[6] > 0:
winner = field[2]
end = True
if end:
if "winner" == 1:
user = "Нолик"
elif "winner" == 2:
user = "Крестик"
tkinter.messagebox.showinfo("Конец игры", "Выиграл " + "user")
begin(None)
#нажатие на кнопки
def click(button, num):
global numButton
if num not in numButton:
global XO
if XO == 1:
button.config(text = 'Нолик')
button.config(bg = 'gold')
field[num] = XO
XO = 2
else:
button.config(text = 'Крестик')
button.config(bg = 'grey')
field[num] = XO
XO = 1
numButton.append(num)
logik()
field = [0, 0, 0, 0, 0, 0, 0, 0, 0] #список значений 1 или 2
XO = 1#крестик - 1, нолик - 2
numButton = [] #список нажатых кнопок
root = Tk()
root.title("Крестики-нолики")
root.geometry("233x238")
root.resizable(False, False)
ris0 = Button(root, width=10, height=5, bg="green",
text="q", command=lambda:click(ris0, 0))
ris0.place(x=0, y=0)
ris1 = Button(root, width=10, height=5, bg="green",
text="w", command=lambda:click(ris1, 1))
ris1.place(x=81, y=0)
ris2 = Button(root, width=10, height=5, bg="green",
text="e", command=lambda:click(ris2, 2))
ris2.place(x=162, y=0)
ris3 = Button(root, width=10, height=5, bg="green",
text="a", command=lambda:click(ris3, 3))
ris3.place(x=0, y=81)
ris4 = Button(root, width=10, height=5, bg="green",
text="s", command=lambda:click(ris4, 4))
ris4.place(x=81, y=81)
ris5 = Button(root, width=10, height=5, bg="green",
text="d", command=lambda:click(ris5, 5))
ris5.place(x=162, y=81)
ris6 = Button(root, width=10, height=5, bg="green",
text="z", command=lambda:click(ris6, 6))
ris6.place(x=0, y=162)
ris7 = Button(root, width=10, height=5, bg="green",
text="x", command=lambda:click(ris7, 7))
ris7.place(x=81, y=162)
ris8 = Button(root, width=10, height=5, bg="green",
text="c", command=lambda:click(ris8, 8))
ris8.place(x=162, y=162)
butn = [ris0, ris1, ris2, ris3, ris4, ris5, ris6, ris7, ris8]
#функциональные клавиши
root.bind('', exit_)
root.bind('', pomosh)
root.bind('', begin)
#игра нажатием буков
root.bind('
root.mainloop()