• R/O
  • HTTP
  • SSH
  • HTTPS

learning: Commit


Commit MetaInfo

Revision5167323ce1392e45a5268b8d64e8c8b41734c59a (tree)
Time2018-01-16 16:55:02
Authoryamat0jp <yamat0jp@yaho...>
Commiteryamat0jp

Log Message

後退しております

Change Summary

Incremental Difference

--- a/network.py
+++ b/network.py
@@ -67,8 +67,11 @@ class Comp():
6767 k += 1
6868 if s == False:
6969 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
7275 X,Y = np.array(self.past),np.array(Y)
7376 X = np.reshape(np.float32(self.past),(-1,8,8,5))
7477 Y = np.reshape(Y,(1,1))
@@ -81,16 +84,20 @@ class Comp():
8184 s = []
8285 for i in range(8):
8386 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)
8693 continue
8794 if len(self.past) == 5:
8895 temp = self.past[0]
8996 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)
9299 t = self.hyouka.predict(np.reshape(np.float32(self.past),(-1,8,8,5)))
93- np.append(s,t)
100+ s.append(t[0])
94101 self.past.pop(len(self.past)-1)
95102 self.past.insert(0,temp)
96103 return s
@@ -113,9 +120,9 @@ class Comp():
113120 self.gakushu(Z)
114121 scores = self.calscore(X_train,Y_train)
115122 self.hyouka.save_weights(self.filename)
116- if scores != None:
117- res = (res + np.reshape(np.array(scores),(1,64)) ) / 2
123+ if scores:
118124 print(scores)
125+ res = (res + np.reshape(np.array(scores),(1,64)) ) / 2
119126 while True:
120127 s = np.argmax(res)
121128 if res[0][s] == 0:
--- a/reversi.py
+++ b/reversi.py
@@ -246,8 +246,10 @@ def GetBanmen(X,pos):
246246 for i in range(8):
247247 for j in range(8):
248248 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
251253
252254 def CompStone():
253255 stone_grid.active = False
Show on old repository browser