private void GetFurthestWayCommandExecute() { var searchParameters = new SearchParameters(new PersonState(StartId, StartItems.ToList()), SearchAlgorithm.Value); List<SearchResultState> newWay = null; // TODO: Change to application start settings Thread thread = new Thread(() => newWay = m_Book.GetWay(searchParameters), 256 * 1024 * 1024); ComputingRunning = true; thread.Start(); thread.Join(); ComputingRunning = false; FoundWay = ConvertWay(newWay); }
public List<SearchResultState> GetWay(SearchParameters parameters) { LastSearchParameters = parameters; // remove unuse items parameters.StartState.Items.RemoveAll(item => !item.BasicItem.InUse || !item.BasicItem.IsProhibiting); var stopwatch = Stopwatch.StartNew(); IPathFinder pathFinder = null; // TODO: Add mapping switch (parameters.Algorithm) { case SearchAlgorithm.Bfs: pathFinder = new LongestPathFinder(new BfsPathStateGenerator()); break; case SearchAlgorithm.Dfs: pathFinder = new LongestPathFinder(new DfsPathStateGenerator(false)); break; case SearchAlgorithm.RandomDfs: pathFinder = new LongestPathFinder(new DfsPathStateGenerator(true)); break; case SearchAlgorithm.DiscoverNewParagraph: pathFinder = new BasePathFinder(new BfsPathStateGenerator(), new DiscoverNewParagraphPathFormator(m_Paragraphs)); break; } var result = pathFinder.FindPath(parameters.StartState, m_Edges); stopwatch.Stop(); if (result != null) { HandleNewPath(result); LastGeneratedWay = result; } return result; }