• R/O
  • HTTP
  • SSH
  • HTTPS

learning: Commit


Commit MetaInfo

Revisionb15191ad556a8d3e2c8155c7f6eeb66bafb34c8a (tree)
Time2018-01-16 14:11:05
Authoryamat0jp <yamat0jp@yaho...>
Commiteryamat0jp

Log Message

理論的にはあってるはずなんですがこれからです

Change Summary

Incremental Difference

--- a/network.py
+++ b/network.py
@@ -8,7 +8,6 @@ from keras.layers import Dense,Activation,Flatten,Dropout
88 from keras.layers import InputLayer,Conv2D
99 import numpy as np
1010 import os
11-from reversi import GetBanmen
1211
1312 class Comp():
1413 def __init__(self):
@@ -76,13 +75,14 @@ class Comp():
7675 self.hyouka.fit(X,Y)
7776
7877 def calscore(self,X,result):
78+ from reversi import GetBanmen
7979 if len(self.past) < 5:
8080 return None
8181 s = []
8282 for i in range(8):
8383 for j in range(8):
8484 if result[i][j] == 0:
85- s.append(0)
85+ np.append(s,0)
8686 continue
8787 if len(self.past) == 5:
8888 temp = self.past[0]
@@ -90,7 +90,7 @@ class Comp():
9090 s = np.reshape(np.array(GetBanmen(X,(i,j))),(8,8))
9191 self.past.append(s)
9292 t = self.hyouka.predict(np.reshape(np.float32(self.past),(-1,8,8,5)))
93- s.extend(t[0])
93+ np.append(s,t)
9494 self.past.pop(len(self.past)-1)
9595 self.past.insert(0,temp)
9696 return s
@@ -115,6 +115,7 @@ class Comp():
115115 self.hyouka.save_weights(self.filename)
116116 if scores != None:
117117 res = (res + np.reshape(np.array(scores),(1,64)) ) / 2
118+ print(scores)
118119 while True:
119120 s = np.argmax(res)
120121 if res[0][s] == 0:
--- a/reversi.py
+++ b/reversi.py
@@ -7,6 +7,7 @@ import pygame,os,sys
77 from pygame.locals import *
88 from network import Comp
99
10+
1011 none, black, white = 0,1,2
1112
1213 size = 50
@@ -241,15 +242,12 @@ def hyouka():
241242 return i
242243
243244 def GetBanmen(X,pos):
244- stone_grid.buffer.Assign(stone_grid.item)
245+ grid = StoneGrid()
245246 for i in range(8):
246247 for j in range(8):
247- stone_grid.item[i][j] = X[i][j]
248- stone_grid.CanSetStone(Player.index,pos[0],pos[1],True)
249- s = Grid()
250- s.Assign(stone_grid.item)
251- stone_grid.item.Assign(stone_grid.buffer)
252- return s
248+ grid.item.grid[i][j] = X[i][j]
249+ grid.CanSetStone(black,pos[0],pos[1],True)
250+ return grid.item.grid
253251
254252 def CompStone():
255253 stone_grid.active = False
Show on old repository browser