-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueen.py
62 lines (55 loc) · 1.03 KB
/
queen.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import random
class queen:
def __init__(self) -> None:
a=input("how large is the chess board")
self.board=[ [j for j in range (8)]for i in range (8)]
self.list=[' ' for i in range(9)]
self.q=a
def place(self,bd):
bd=[]
pass
def win(self):
pass
def loss(self):
pass
def avail(self):
return i
def __str__(self) -> str:
pass
q=queen()
avail=[i for i in range(9)]
bd =q.board
#kJ$2*iG
def place(avail):
n=q.q
j=0
for i in avail:
bd[i] =j
if i == n-1 :
return True
else:
soln= place(avail)
if soln :
return True
else:
pass
#undo move
#return false
else :
return False
#if no more moves are possible we need to stop
# return false
#undo move
def play(q,bd):
a= q.avial(bd)
#gaudl sf'
if q.win():
print(bd)
return bd
elif q.loss():
#make the previous move null
#continue to place in other square
return
for i in a:
q.play(bd)
play(q,q.board)