Revision | 5167323ce1392e45a5268b8d64e8c8b41734c59a (tree) |
---|---|
Time | 2018-01-16 16:55:02 |
Author | yamat0jp <yamat0jp@yaho...> |
Commiter | yamat0jp |
後退しております
@@ -67,8 +67,11 @@ class Comp(): | ||
67 | 67 | k += 1 |
68 | 68 | if s == False: |
69 | 69 | break |
70 | - if (s == True)and(k > 32): | |
71 | - Y += 10 | |
70 | + if s == True: | |
71 | + if k > 32: | |
72 | + Y += 10 | |
73 | + else: | |
74 | + Y -= 10 | |
72 | 75 | X,Y = np.array(self.past),np.array(Y) |
73 | 76 | X = np.reshape(np.float32(self.past),(-1,8,8,5)) |
74 | 77 | Y = np.reshape(Y,(1,1)) |
@@ -81,16 +84,20 @@ class Comp(): | ||
81 | 84 | s = [] |
82 | 85 | for i in range(8): |
83 | 86 | for j in range(8): |
84 | - if result[i][j] == 0: | |
85 | - np.append(s,0) | |
87 | + if result[i][j] != 0: | |
88 | + s.append(0) | |
89 | + continue | |
90 | + k = GetBanmen(X,(i,j)) | |
91 | + if k == None: | |
92 | + s.append(0) | |
86 | 93 | continue |
87 | 94 | if len(self.past) == 5: |
88 | 95 | temp = self.past[0] |
89 | 96 | self.past.pop(0) |
90 | - s = np.reshape(np.array(GetBanmen(X,(i,j))),(8,8)) | |
91 | - self.past.append(s) | |
97 | + print('true') | |
98 | + self.past.append(k) | |
92 | 99 | t = self.hyouka.predict(np.reshape(np.float32(self.past),(-1,8,8,5))) |
93 | - np.append(s,t) | |
100 | + s.append(t[0]) | |
94 | 101 | self.past.pop(len(self.past)-1) |
95 | 102 | self.past.insert(0,temp) |
96 | 103 | return s |
@@ -113,9 +120,9 @@ class Comp(): | ||
113 | 120 | self.gakushu(Z) |
114 | 121 | scores = self.calscore(X_train,Y_train) |
115 | 122 | self.hyouka.save_weights(self.filename) |
116 | - if scores != None: | |
117 | - res = (res + np.reshape(np.array(scores),(1,64)) ) / 2 | |
123 | + if scores: | |
118 | 124 | print(scores) |
125 | + res = (res + np.reshape(np.array(scores),(1,64)) ) / 2 | |
119 | 126 | while True: |
120 | 127 | s = np.argmax(res) |
121 | 128 | if res[0][s] == 0: |
@@ -246,8 +246,10 @@ def GetBanmen(X,pos): | ||
246 | 246 | for i in range(8): |
247 | 247 | for j in range(8): |
248 | 248 | grid.item.grid[i][j] = X[i][j] |
249 | - grid.CanSetStone(black,pos[0],pos[1],True) | |
250 | - return grid.item.grid | |
249 | + if grid.CanSetStone(black,pos[0],pos[1],True) == True: | |
250 | + return grid.item.grid | |
251 | + else: | |
252 | + return None | |
251 | 253 | |
252 | 254 | def CompStone(): |
253 | 255 | stone_grid.active = False |