@@ -13,7 +13,7 @@ export default class GomokuRLEnvironment extends RLEnvironmentBase {
1313
1414 this . _size = [ 8 , 8 ]
1515
16- this . _board = new GomokuBoard ( this . _size , this . _evaluation )
16+ this . _board = new GomokuBoard ( this . _size )
1717
1818 this . _reward = {
1919 win : 1 ,
@@ -50,16 +50,6 @@ export default class GomokuRLEnvironment extends RLEnvironmentBase {
5050 return s
5151 }
5252
53- set evaluation ( func ) {
54- if ( func ) {
55- this . _board . _evaluator = this . _evaluation = ( board , turn ) => {
56- return func ( this . _makeState ( board , turn , this . _turn ) )
57- }
58- } else {
59- this . _board . _evaluator = this . _evaluation = null
60- }
61- }
62-
6353 _makeState ( board , agentturn , gameturn ) {
6454 const s = [ gameturn ]
6555 for ( let i = 0 ; i < this . _size [ 0 ] ; i ++ ) {
@@ -72,7 +62,7 @@ export default class GomokuRLEnvironment extends RLEnvironmentBase {
7262 }
7363
7464 _state2board ( state , turn ) {
75- const board = new GomokuBoard ( this . _size , this . _evaluation )
65+ const board = new GomokuBoard ( this . _size )
7666 const opturn = board . nextTurn ( turn )
7767 for ( let i = 0 , p = 1 ; i < this . _size [ 0 ] ; i ++ ) {
7868 for ( let j = 0 ; j < this . _size [ 1 ] ; j ++ , p ++ ) {
@@ -164,8 +154,7 @@ export default class GomokuRLEnvironment extends RLEnvironmentBase {
164154}
165155
166156class GomokuBoard {
167- constructor ( size , evaluator ) {
168- this . _evaluator = evaluator
157+ constructor ( size ) {
169158 this . _size = size
170159 this . _a = 5
171160 this . _count = 0
@@ -215,7 +204,7 @@ class GomokuBoard {
215204 }
216205
217206 copy ( ) {
218- const cp = new GomokuBoard ( this . _size , this . _evaluator )
207+ const cp = new GomokuBoard ( this . _size )
219208 for ( let i = 0 ; i < this . _size [ 0 ] ; i ++ ) {
220209 for ( let j = 0 ; j < this . _size [ 1 ] ; j ++ ) {
221210 cp . _board [ i ] [ j ] = this . _board [ i ] [ j ]
@@ -226,9 +215,6 @@ class GomokuBoard {
226215 }
227216
228217 score ( turn ) {
229- if ( this . _evaluator ) {
230- return this . _evaluator ( this , turn )
231- }
232218 const winner = this . winner
233219 const nt = this . nextTurn ( turn )
234220 if ( winner === turn ) return this . _size [ 0 ] * this . _size [ 1 ] * 100 - this . _count
0 commit comments