Skip to content

Commit 4730691

Browse files
committed
chess and graph
1 parent b8e5561 commit 4730691

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

chess.py

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
'''
2+
8 ♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
3+
7 ♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟
4+
6
5+
5
6+
4
7+
3
8+
2 ♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙
9+
1 ♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖
10+
a b c d e f g h
11+
12+
'''
13+
14+
board = [
15+
'♜', '♞', '♝', '♛', '♚', '♝', '♞', '♜', '♟', '♟', '♟', '♟', '♟', '♟', '♟', '♟',
16+
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
17+
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
18+
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
19+
'♙', '♙', '♙', '♙', '♙', '♙', '♙', '♙', '♖', '♘', '♗', '♕', '♔', '♗', '♘', '♖',
20+
]
21+
hor_line = '-----------------'
22+
ver_line_char = '|'
23+
24+
while True:
25+
26+
# Чистим экран
27+
for y in range(30):
28+
print("")
29+
30+
# Рисуем доску
31+
cur_x = 0
32+
cur_y = 0
33+
print(hor_line)
34+
for c in board:
35+
if cur_x == 0:
36+
print(ver_line_char, sep="", end="")
37+
38+
print(c, sep="", end=ver_line_char)
39+
40+
cur_x += 1
41+
if cur_x > 7:
42+
cur_x = 0
43+
cur_y += 1
44+
print("")
45+
print(hor_line)
46+
47+
x1 = int(input("Введите х1:"))
48+
y1 = int(input("Введите y1:"))
49+
x2 = int(input("Введите х2:"))
50+
y2 = int(input("Введите y2:"))
51+
52+
# Делаем ход
53+
char1 = board[y1*8 + x1]
54+
char2 = board[y2*8 + x2]
55+
if char1 == ' ' or not char2 == ' ':
56+
print("Ход невозможен")
57+
else:
58+
board[y2*8 + x2] = char1
59+
board[y1*8 + x1] = char2
60+

text_graph.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import math
2+
3+
max_x = 64
4+
max_y = 12
5+
6+
mid_x = max_x / 2
7+
mid_y = max_y / 2
8+
9+
for y in range(max_y):
10+
print("")
11+
for x in range(max_x):
12+
cur_x = x - mid_x
13+
cur_y = -(y - mid_y)
14+
function = 5 * math.sin(cur_x / 10)
15+
16+
cur_char = " "
17+
if cur_y == function // 1:
18+
cur_char = "*"
19+
elif y == mid_y:
20+
cur_char = "-"
21+
elif x == mid_x:
22+
cur_char = "|"
23+
24+
print(cur_char, sep="",end="")

0 commit comments

Comments
 (0)