-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp.py
160 lines (124 loc) · 7.28 KB
/
temp.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
''' if ((cnt1-2 >=0 and cnt1-2 <= 7) and (cnt2-2 >=0 and cnt2-2 <= 7)):
print parent.state[cnt1-2][cnt2-2],cnt1-2,cnt2-2
if (list(parent.state[cnt1-1][cnt2-1])[0] == 'C'):
#recursive call and move to this position
print "pri3"
temp_state = copy.deepcopy(parent.state)
#check for super-imposing moves on the last node
if (temp_state[cnt1-2][cnt2-2] != '0') and (cnt1-2 == 0):
last_row_cond = int(list(temp_state[cnt1-2][cnt2-2])[1])
last_row_cond += 1
temp_state[cnt1-2][cnt2-2] = "S" + str(last_row_cond)
else:
temp_state[cnt1-2][cnt2-2] = 'S1'
temp_state[cnt1][cnt2] = '0'
temp_state[cnt1-1][cnt2-1] = '0'
temp_node = Node(0, temp_state, parent)
print "------------------------------------------------------------"
depth_cntr-=1
if depth_cntr < 0:
return
else:
self.move_generation(depth_cntr,temp_node)
else:
#skip
print "pri33"
if ((cnt1-2 >=0 and cnt1-2 <= 7) and (cnt2+2 >=0 and cnt2+2 <= 7)):
print parent.state[cnt1-2][cnt2+2],cnt1-2,cnt2+2
if ((parent.state[cnt1-2][cnt2+2] == '0') and (list(parent.state[cnt1-1][cnt2+1])[0] == 'C')):
#recursive call and move to this position
print "pri4"
temp_state = copy.deepcopy(parent.state)
temp_state[cnt1-2][cnt2+2] = 'S1'
temp_state[cnt1][cnt2] = '0'
temp_state[cnt1-1][cnt2+1] = '0'
temp_node = Node(0, temp_state, parent)
print "------------------------------------------------------------"
depth_cntr-=1
if depth_cntr < 0:
return
else:
self.move_generation(depth_cntr,temp_node)
else:
#skip
print "pri44" '''
''' if ((cnt1+2 >=0 and cnt1+2 <= 7) and (cnt2-2 >=0 and cnt2-2 <= 7)):
print parent.state[cnt1+2][cnt2-2],cnt1-2,cnt2-2
if ((parent.state[cnt1+2][cnt2-2] == '0') and (list(parent.state[cnt1+1][cnt2-1])[0] == 'S')):
#recursive call and move to this position
print "pri3"
temp_state = copy.deepcopy(parent.state)
temp_state[cnt1+2][cnt2-2] = 'C1'
temp_state[cnt1][cnt2] = '0'
temp_state[cnt1+1][cnt2-1] = '0'
temp_node = Node(1, temp_state, parent)
print "------------------------------------------------------------"
depth_cntr-=1
if depth_cntr < 0:
return
else:
self.move_generation(depth_cntr,temp_node)
else:
#skip
print "pri33"
if ((cnt1+2 >=0 and cnt1+2 <= 7) and (cnt2+2 >=0 and cnt2+2 <= 7)):
print parent.state[cnt1+2][cnt2+2],cnt1-2,cnt2+2
if ((parent.state[cnt1+2][cnt2+2] == '0') and (list(parent.state[cnt1+1][cnt2+1])[0] == 'S')):
#recursive call and move to this position
print "pri4"
temp_state = copy.deepcopy(parent.state)
temp_state[cnt1+2][cnt2+2] = 'C1'
temp_state[cnt1][cnt2] = '0'
temp_state[cnt1+1][cnt2+1] = '0'
temp_node = Node(1, temp_state, parent)
print "------------------------------------------------------------"
depth_cntr-=1
if depth_cntr < 0:
return
else:
self.move_generation(depth_cntr,temp_node)
else:
#skip
print "pri44"'''
''' #print "Internal pass counter: ",
if pass_check_cntr == 4:
pass_cntr += 1
print "INTERNAL PASS: ",pass_cntr
if pass_cntr == 2:
print "INTERNAL PASS: Terminated"
return
else:
parent.player = 0
move_generation(depth_cntr, parent)'''
if len(parent.children) == 0: #pass check
pass_cntr += 1
print "PASS: ",pass_cntr
if pass_cntr == 2:
print "PASS: Terminated"
return
else:
parent.player = 0
move_generation(depth_cntr, parent)
if pass_check_cntr_circle == 4: #pass check
pass_cntr_star += 1
print "PASS Inside: ",pass_cntr_star
if pass_cntr_star == 2:
print "PASS Inside: Terminated"
depth_cntr = 0
breaker = 1
break
else:
parent.player = 1
move_generation(depth_cntr, parent)
if breaker == 1:
break
print "********************************************************"
print "\nNode Name: ",parent.name
for i in parent.state:
print "\n"
for j in i:
print j,
print "\nDepth: ",depth_cntr
print "\nPlayer: ",parent.player
print "\nNo of children: ",len(parent.children)
print "********************************************************"