All files / src/search treeSearch.js

100% Statements 0/0
100% Branches 0/0
100% Functions 0/0
100% Lines 0/0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38                                                                           
"use strict";
 
 
//~ /**
//~ * Does breath first tree search.
//~ * 
//~ * Needless to say, it is only suitable for tree structures as it does not take repeated states into account. For graphs, it will run until it runs iut of memory.
//~ */
//~ module.exports.treeSearch = function (paramaters)
//~ {
//~ return function (problem)
//~ {
//~ //console.log('SEARCH', problem);
//~ const frontier = [{
//~ state: problem.state,
//~ steps: []
//~ }];
//~ const goal = problem.goal || paramaters.goal;
//~ while (frontier.length > 0)
//~ {
//~ const leaf = frontier.shift();
//~ if (paramaters.isGoalState(leaf.state, goal))
//~ {
//~ return leaf.steps;
//~ }
//~ for (let action in paramaters.getActions(leaf.state))
//~ {
//~ const resultingState = paramaters.performAction(leaf.state, action);
//~ frontier.push({
//~ state: resultingState,
//~ steps: leaf.steps.concat([action])
//~ });
//~ }
//~ }
//~ return null;
//~ };
//~ };