public SearchNode < O , T > makeNode ( Successor successor ) throws SearchNotExhaustiveException { SearchNode newNode ; try { // Create a new instance of this class newNode = getClass ( ) . newInstance ( ) ; // Set the state, operation, parent, depth and cost for the new search node newNode . state = successor . getState ( ) ; newNode . parent = this ; newNode . appliedOp = successor . getOperator ( ) ; newNode . depth = depth + 1 ; newNode . pathCost = pathCost + successor . getCost ( ) ; // Check if there is a repeated state filter and copy the reference to it into the new node if so if ( repeatedStateFilter != null ) { newNode . setRepeatedStateFilter ( repeatedStateFilter ) ; } return newNode ; } catch ( InstantiationException e ) { // In practice this should never happen but may if the nodes if some class loader error were to occur whilst // using a custom node implementation. Rethrow this as a RuntimeException. throw new IllegalStateException ( "InstantiationException during creation of new search node." , e ) ; } catch ( IllegalAccessException e ) { // In practice this should never happen but may if the nodes to use are not public whilst using a custom node // implementation. Rethrow this as a RuntimeException. throw new IllegalStateException ( "IllegalAccessException during creation of new search node." , e ) ; } }
Makes a new node of the same type as this one from a Successor state .