fn expand_children<R : Rng + ?Sized>(&self, game_tree : &mut GameTree, rollout_strategy : RolloutStrategy,
                                         network_config : &NetworkConfig, rng : &mut R) -> Vec<f32> {

        let current_node_index = self.current_node_index();

        let child_num_turns = self.game_state.get_remaining_turns() - 1;

        let current_set_size = self.game_state.get_num_matrices();
        let current_distance = self.game_state.get_distance();
        let target = self.game_state.get_target();

        let mut result = Vec::new();

        let mut edges = Vec::new();
        let mut child_distances = Vec::new();

        let children_start_index = game_tree.nodes.len();

        //For the first double-loop, update the edges for sure, since we can do that,
        //and maybe update the nodes in the case that they're the last turn
        for i in 0..current_set_size {
            let left_matrix = self.game_state.matrix_set.get(i);
            for j in 0..current_set_size {
                let right_matrix = self.game_state.matrix_set.get(j);

                let added_matrix = left_matrix.dot(&right_matrix);

                let dist_to_added = sq_frob_dist(added_matrix.view(), target);
                let child_current_distance = current_distance.min(dist_to_added);

                child_distances.push(child_current_distance);

                //We're going to create a roll-out for the node in a bit, which
                //is why the visit count here is 1 and not zero.
                let visit_count = 1;

                let edge = GameTreeEdge {
                    added_matrix : added_matrix.clone(),
                    visit_count
                };

                edges.push(edge);

                //In the case where this comprises the last turn, just go ahead and update the game
                //tree nodes with this information.
                if (child_num_turns == 0) {
                    result.push(child_current_distance);

                    let game_end_distance_distribution = NormalInverseChiSquared::Certain(child_current_distance as f64);
                    let node = GameTreeNode {
                        maybe_expanded_edges : Option::None,
                        current_distance : child_current_distance,
                        game_end_distance_distribution
                    };
                    game_tree.nodes.push(node);
                }
            }
        }

        //Now, if there are still turns left for performing rollouts, perform the rollouts
        //and use that to populate the values for the new nodes here
        if (child_num_turns > 0) {
            //First, perform the rollouts
            let rollout_distances = rollout_strategy.complete_rollouts(self.game_state.clone(), 
                                                     network_config, rng);
            
            //Then, update the nodes and the returned result
            for i in 0..current_set_size {
                for j in 0..current_set_size {
                    let ind = i * current_set_size + j;
                    let child_current_distance = child_distances[ind];
                    let rollout_distance = rollout_distances[ind];

                    result.push(rollout_distance);

                    let game_end_distance_distribution = 
                        NormalInverseChiSquared::Uninformative.update(rollout_distance as f64);

                    let node = GameTreeNode {
                        maybe_expanded_edges : Option::None,
                        current_distance : child_current_distance,
                        game_end_distance_distribution
                    };
                    game_tree.nodes.push(node);
                }
            }
        }
        let expanded_edges = ExpandedEdges {
            children_start_index,
            edges
        };
        game_tree.nodes[current_node_index].maybe_expanded_edges = Option::Some(expanded_edges);
        result
    }
///Expands the children under the traverser's position using the given
///NetworkConfig for performing rollouts (if needed). Returns a collection
///of all of the distanced derived from rollouts (or from the actual values, if terminal nodes)
///which came from the expanded children
Expands the children under the traverser's position using the given
NetworkConfig for performing rollouts (if needed). Returns a collection
of all of the distanced derived from rollouts (or from the actual values, if terminal nodes)
which came from the expanded children
Expands the children under the traverser ' s position using the given NetworkConfig for performing rollouts ( if needed ) . Returns a collection of all of the distanced derived from rollouts ( or from the actual values if terminal nodes ) which came from the expanded children
fn expand_children<R : Rng + ?Sized>(&self, game_tree : &mut GameTree, rollout_strategy : RolloutStrategy,
                                         network_config : &NetworkConfig, rng : &mut R) -> Vec<f32> {
        let current_node_index = self.current_node_index();
        let child_num_turns = self.game_state.get_remaining_turns() - 1;
        let current_set_size = self.game_state.get_num_matrices();
        let current_distance = self.game_state.get_distance();
        let target = self.game_state.get_target();
        let mut result = Vec::new();
        let mut edges = Vec::new();
        let mut child_distances = Vec::new();
        let children_start_index = game_tree.nodes.len();
        //For the first double-loop, update the edges for sure, since we can do that,
        //and maybe update the nodes in the case that they're the last turn
        for i in 0..current_set_size {
            let left_matrix = self.game_state.matrix_set.get(i);
            for j in 0..current_set_size {
                let right_matrix = self.game_state.matrix_set.get(j);
                let added_matrix = left_matrix.dot(&right_matrix);
                let dist_to_added = sq_frob_dist(added_matrix.view(), target);
                let child_current_distance = current_distance.min(dist_to_added);
                child_distances.push(child_current_distance);
                //We're going to create a roll-out for the node in a bit, which
                //is why the visit count here is 1 and not zero.
                let visit_count = 1;
                let edge = GameTreeEdge {
                    added_matrix : added_matrix.clone(),
                    visit_count
                };
                edges.push(edge);
                //In the case where this comprises the last turn, just go ahead and update the game
                //tree nodes with this information.
                if (child_num_turns == 0) {
                    result.push(child_current_distance);
                    let game_end_distance_distribution = NormalInverseChiSquared::Certain(child_current_distance as f64);
                    let node = GameTreeNode {
                        maybe_expanded_edges : Option::None,
                        current_distance : child_current_distance,
                        game_end_distance_distribution
                    };
                    game_tree.nodes.push(node);
                }
            }
        }
        //Now, if there are still turns left for performing rollouts, perform the rollouts
        //and use that to populate the values for the new nodes here
        if (child_num_turns > 0) {
            //First, perform the rollouts
            let rollout_distances = rollout_strategy.complete_rollouts(self.game_state.clone(), 
                                                     network_config, rng);
            //Then, update the nodes and the returned result
            for i in 0..current_set_size {
                for j in 0..current_set_size {
                    let ind = i * current_set_size + j;
                    let child_current_distance = child_distances[ind];
                    let rollout_distance = rollout_distances[ind];
                    result.push(rollout_distance);
                    let game_end_distance_distribution = 
                        NormalInverseChiSquared::Uninformative.update(rollout_distance as f64);
                    let node = GameTreeNode {
                        maybe_expanded_edges : Option::None,
                        current_distance : child_current_distance,
                        game_end_distance_distribution
                    };
                    game_tree.nodes.push(node);
                }
            }
        }
        let expanded_edges = ExpandedEdges {
            children_start_index,
            edges
        };
        game_tree.nodes[current_node_index].maybe_expanded_edges = Option::Some(expanded_edges);
        result
    }
fn expand_children < R : Rng + ? Sized > ( & self , game_tree : & mut GameTree , rollout_strategy : RolloutStrategy , network_config : & NetworkConfig , rng : & mut R ) -> Vec < f32 > { let current_node_index = self . current_node_index ( ) ; let child_num_turns = self . game_state . get_remaining_turns ( ) - 1 ; let current_set_size = self . game_state . get_num_matrices ( ) ; let current_distance = self . game_state . get_distance ( ) ; let target = self . game_state . get_target ( ) ; let mut result = Vec :: new ( ) ; let mut edges = Vec :: new ( ) ; let mut child_distances = Vec :: new ( ) ; let children_start_index = game_tree . nodes . len ( ) ; //For the first double-loop, update the edges for sure, since we can do that, //and maybe update the nodes in the case that they're the last turn for i in 0 .. current_set_size { let left_matrix = self . game_state . matrix_set . get ( i ) ; for j in 0 .. current_set_size { let right_matrix = self . game_state . matrix_set . get ( j ) ; let added_matrix = left_matrix . dot ( & right_matrix ) ; let dist_to_added = sq_frob_dist ( added_matrix . view ( ) , target ) ; let child_current_distance = current_distance . min ( dist_to_added ) ; child_distances . push ( child_current_distance ) ; //We're going to create a roll-out for the node in a bit, which //is why the visit count here is 1 and not zero. let visit_count = 1 ; let edge = GameTreeEdge { added_matrix : added_matrix . clone ( ) , visit_count } ; edges . push ( edge ) ; //In the case where this comprises the last turn, just go ahead and update the game //tree nodes with this information. if ( child_num_turns == 0 ) { result . push ( child_current_distance ) ; let game_end_distance_distribution = NormalInverseChiSquared :: Certain ( child_current_distance as f64 ) ; let node = GameTreeNode { maybe_expanded_edges : Option :: None , current_distance : child_current_distance , game_end_distance_distribution } ; game_tree . nodes . push ( node ) ; } } } //Now, if there are still turns left for performing rollouts, perform the rollouts //and use that to populate the values for the new nodes here if ( child_num_turns > 0 ) { //First, perform the rollouts let rollout_distances = rollout_strategy . complete_rollouts ( self . game_state . clone ( ) , network_config , rng ) ; //Then, update the nodes and the returned result for i in 0 .. current_set_size { for j in 0 .. current_set_size { let ind = i * current_set_size + j ; let child_current_distance = child_distances [ ind ] ; let rollout_distance = rollout_distances [ ind ] ; result . push ( rollout_distance ) ; let game_end_distance_distribution = NormalInverseChiSquared :: Uninformative . update ( rollout_distance as f64 ) ; let node = GameTreeNode { maybe_expanded_edges : Option :: None , current_distance : child_current_distance , game_end_distance_distribution } ; game_tree . nodes . push ( node ) ; } } } let expanded_edges = ExpandedEdges { children_start_index , edges } ; game_tree . nodes [ current_node_index ] . maybe_expanded_edges = Option :: Some ( expanded_edges ) ; result }
Expands the children under the traverser's position using the given
NetworkConfig for performing rollouts (if needed).
Expands the children under the traverser ' s position using the given NetworkConfig for performing rollouts ( if needed ) .
&self
game_tree
&mut GameTree
rollout_strategy
RolloutStrategy
network_config
&NetworkConfig
rng
&mut R
&self
game_tree
&mut GameTree
rollout_strategy
RolloutStrategy
network_config
&NetworkConfig
rng
&mut R