Skip to content

Commit

Permalink
Update node functions (add readNode)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreKavalerski committed Jul 4, 2020
1 parent f58d4a0 commit ad45c37
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/functions/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { State } from '../utils/state';
import { calcHValue } from './heuristic';
import { applyOperation } from './operations';
import HeuristicValue from '../classes/HeuristicValue';
import { readState } from './state';

function generateNodeList(node: NodeInfo, goalState: State): NodeInfo[]{
let childrenNodes: NodeInfo[] = [];
Expand Down Expand Up @@ -41,4 +42,15 @@ function generateNode(state: State, op: operations, goalState: State, gValue: nu
return new NodeInfo(heuristicValue, op, state, previousNode);
}

export { generateNodeList, generateNode }

function readNode(node: NodeInfo): NodeInfo{
readState(node.state);
if(node.previousNode){
return readNode(node.previousNode);
}
else{
return node;
}
}

export { generateNodeList, generateNode, readNode }

0 comments on commit ad45c37

Please sign in to comment.