77 */
88
99import Game from '../core/game' ;
10- import { CreateGameReducer } from '../core/reducer' ;
10+ import { InitializeGame } from '../core/reducer' ;
1111import { MAKE_MOVE , GAME_EVENT } from '../core/action-types' ;
1212import { makeMove } from '../core/action-creators' ;
1313import { Simulate , Bot , RandomBot , MCTSBot } from './bot' ;
@@ -86,16 +86,14 @@ describe('Simulate', () => {
8686 } ;
8787
8888 test ( 'multiple bots' , ( ) => {
89- const reducer = CreateGameReducer ( { game : TicTacToe } ) ;
90- const state = reducer ( undefined , { type : 'init' } ) ;
89+ const state = InitializeGame ( { game : TicTacToe } ) ;
9190 const { state : endState } = Simulate ( { game : TicTacToe , bots, state } ) ;
9291 expect ( endState . ctx . gameover ) . not . toBe ( undefined ) ;
9392 } ) ;
9493
9594 test ( 'single bot' , ( ) => {
9695 const bot = new RandomBot ( { seed : 'test' , enumerate } ) ;
97- const reducer = CreateGameReducer ( { game : TicTacToe } ) ;
98- const state = reducer ( undefined , { type : 'init' } ) ;
96+ const state = InitializeGame ( { game : TicTacToe } ) ;
9997 const { state : endState } = Simulate ( {
10098 game : TicTacToe ,
10199 bots : bot ,
@@ -146,8 +144,7 @@ describe('MCTSBot', () => {
146144
147145 test ( 'game that never ends' , ( ) => {
148146 const game = Game ( { } ) ;
149- const reducer = CreateGameReducer ( { game } ) ;
150- const state = reducer ( undefined , { type : 'init' } ) ;
147+ const state = InitializeGame ( { game } ) ;
151148 const bot = new MCTSBot ( { seed : 'test' , game, enumerate : ( ) => [ ] } ) ;
152149 const { state : endState } = Simulate ( { game, bots : bot , state } ) ;
153150 expect ( endState . ctx . turn ) . toBe ( 0 ) ;
@@ -165,17 +162,17 @@ describe('MCTSBot', () => {
165162 } ) ,
166163 } ;
167164
168- const reducer = CreateGameReducer ( { game : TicTacToe } ) ;
165+ const initialState = InitializeGame ( { game : TicTacToe } ) ;
169166
170167 for ( let i = 0 ; i < 5 ; i ++ ) {
171- const state = reducer ( undefined , { type : 'init' } ) ;
168+ const state = initialState ;
172169 const { state : endState } = Simulate ( { game : TicTacToe , bots, state } ) ;
173170 expect ( endState . ctx . gameover ) . not . toEqual ( { winner : '0' } ) ;
174171 }
175172 } ) ;
176173
177174 test ( 'MCTSBot vs. MCTSBot' , ( ) => {
178- const reducer = CreateGameReducer ( { game : TicTacToe } ) ;
175+ const initialState = InitializeGame ( { game : TicTacToe } ) ;
179176 const iterations = 400 ;
180177
181178 for ( let i = 0 ; i < 5 ; i ++ ) {
@@ -195,7 +192,7 @@ describe('MCTSBot', () => {
195192 iterations,
196193 } ) ,
197194 } ;
198- const state = reducer ( undefined , { type : 'init' } ) ;
195+ const state = initialState ;
199196 const { state : endState } = Simulate ( { game : TicTacToe , bots, state } ) ;
200197 expect ( endState . ctx . gameover ) . toEqual ( { draw : true } ) ;
201198 }
@@ -209,8 +206,7 @@ describe('MCTSBot', () => {
209206 } ,
210207 } ) ;
211208
212- const reducer = CreateGameReducer ( { game : TicTacToe } ) ;
213- const state = reducer ( undefined , { type : 'init' } ) ;
209+ const state = InitializeGame ( { game : TicTacToe } ) ;
214210
215211 for ( let i = 0 ; i < 10 ; i ++ ) {
216212 const bot = new MCTSBot ( {
0 commit comments