-
Notifications
You must be signed in to change notification settings - Fork 2
/
connect_four.py
45 lines (42 loc) · 1 KB
/
connect_four.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from module.casiofx import *
calc = Calculator()
# Grid (7x6)
calc.goto(-24.5, 21)
for _ in range(7):
calc.pendown()
calc.goto(-calc.x, calc.y)
calc.penup()
calc.goto(-calc.x, calc.y-7)
calc.goto(-24.5, 21)
for _ in range(8):
calc.pendown()
calc.goto(calc.x, -calc.y)
calc.penup()
calc.goto(calc.x+7, -calc.y)
calc.goto(100, 100)
# Stacking
m = 1111111
d = 0
while True:
a = int(calc.askValue('a')) # Integer needed to avoid overflowerror
b = 7 - a
c = Ent(m/10**b) - (Ent(m/10**(b+1))*10)
calc.penup()
calc.goto(-22.5+7*(a-1), -19+7*(c-1))
calc.pendown()
if d == 0:
calc.goto(calc.x+3, calc.y+3)
calc.penup()
calc.goto(calc.x, calc.y-3)
calc.pendown()
calc.goto(calc.x-3, calc.y+3)
d = 1
else:
calc.goto(calc.x, calc.y+3)
calc.goto(calc.x+3, calc.y)
calc.goto(calc.x, calc.y-3)
calc.goto(calc.x-3, calc.y)
d = 0
calc.penup()
calc.goto(100, 100)
m = m + 1*10**b