@@ -154,13 +154,14 @@ impl Node {
154154 . iter ( )
155155 . map ( |& m| Node :: new ( m, self . config ) )
156156 . collect ( ) ;
157- if self . children . len ( ) <= ( game. size ( ) * game. size ( ) / 10 ) as usize {
157+ let size = game. size ( ) as usize ;
158+ if self . children . len ( ) <= ( size * size / 10 ) {
158159 if !self . config . play_out_aftermath || game. winner ( ) == game. next_player ( ) {
159160 //don't pass if we're losing on the board on CGOS, but otherwise it's OK
160161 self . children . push ( Node :: new ( Pass ( game. next_player ( ) ) , self . config ) ) ;
161162 }
162163 }
163-
164+
164165 self . descendants = self . children . len ( ) ;
165166 }
166167 }
@@ -172,31 +173,31 @@ impl Node {
172173 . iter ( )
173174 . map ( |m| self . new_leaf ( board, m) )
174175 . collect ( ) ;
175-
176+
176177 self . priors ( & mut children, board) ;
177178 self . children = children;
178-
179- if self . children . len ( ) <= ( board . size ( ) * board . size ( ) / 10 ) as usize {
179+ let size = board . size ( ) as usize ;
180+ if self . children . len ( ) <= ( size * size / 10 ) {
180181 let player = board. next_player ( ) ;
181182 if !self . config . play_out_aftermath || board. winner ( ) == player {
182183 //don't pass if we're losing on the board on CGOS, but otherwise it's OK
183184 self . children . push ( Node :: new ( Pass ( player) , self . config ) ) ;
184185 }
185-
186+
186187 }
187188 }
188189
189-
190+
190191 self . descendants = self . children . len ( ) ;
191192 not_terminal
192193 }
193-
194+
194195 pub fn priors ( & self , children : & mut Vec < Node > , board : & Board ) {
195196 let color = board. next_player ( ) . opposite ( ) ;
196197
197198 let in_danger = board. chains ( ) . iter ( )
198199 . filter ( |chain| chain. color ( ) == color && chain. coords ( ) . len ( ) == 1 && chain. liberties ( ) . len ( ) <= 2 ) ;
199-
200+
200201 for one_stone in in_danger {
201202 if let Some ( solution) = board. capture_ladder ( one_stone) {
202203 if let Some ( node) = children. iter_mut ( ) . find ( |c| c. m ( ) == solution) {
@@ -205,10 +206,10 @@ impl Node {
205206 }
206207 }
207208 }
208-
209+
209210 let in_danger = board. chains ( ) . iter ( )
210211 . filter ( |chain| chain. color ( ) == color && chain. coords ( ) . len ( ) > 1 && chain. liberties ( ) . len ( ) <= 2 ) ;
211-
212+
212213 for many_stones in in_danger {
213214 if let Some ( solution) = board. capture_ladder ( many_stones) {
214215 if let Some ( node) = children. iter_mut ( ) . find ( |c| c. m ( ) == solution) {
@@ -240,7 +241,7 @@ impl Node {
240241 }
241242 node
242243 }
243-
244+
244245 fn in_empty_area ( & self , board : & Board , m : & Move ) -> bool {
245246 m. coord ( ) . manhattan_distance_three_neighbours ( board. size ( ) )
246247 . iter ( )
0 commit comments