void explorePaths(const char** paths, int pathsCount, std::list<Path>& collectedFiles) throw (FileException)
{
    INFO("%s", "Starting to explore paths...");

    for (int i = 0; i < pathsCount; i++)
    {
        explorePath(paths[i], collectedFiles);
    }
}
示例#2
0
文件: explore.c 项目: pd0wm/epo2
/**
 * Explores the grid
 * @param startNd
 */
void explore(int startNd) {
	// Create starting branch
	int branch = createBranch(-1);

	if (getPath(startNd, branch) == -1) {
		printf("An error occurred: starting node not included in any path.\n");
	} else {
		//		printf("Starting exploration\n");
		pathReturned = explorePath(startNd, NULL, 0, 0);
		//		printf("Exploration finished!\n");
	}
}
void PSP_FileManager ::explore (  void )
{
       
    
   
    //reason: nextTime, can go to here
    
    
    
    CommonString pathString;
    pathString = msRoot;
    //this->currentPathString.setString ( msRoot );
    //const unsigned char *p;
    //p = currentPathString.getChar_p_readonly() ;
    /*CommonString pathlocal;
    pathlocal.setString ( p );
    p = pathlocal.getChar_p_readonly();
*/
    //unsigned char buffer[1024];

    PSP_GRAPHICS::getScreenImageToBitMap(  wholeScreenBMP );
   
    do
    {  


        //p = pathlocal.getChar_p_readonly();
        //sprintf( (char *)buffer , "explorePath (p )  p is %s", (char *)p );

      //  this->showMessage ( buffer  );

       // do not care the return value here
       // because it should reEnter forever.
        //explorePath (  this->currentPathString.getChar_p_readonly() );
        
         ExploreResult r;
         r = explorePath (  pathString  );
         if ( r == cancel ) 
         break;
        //pathlocal.setString ( p  );

//        wait(6);

    }while ( true );
    


}
示例#4
0
文件: explore.c 项目: pd0wm/epo2
/**
 * Explores a path
 * @param  node
 * @param  currPath
 * @param  currPathSize
 * @param  node
 * @param  currPath
 * @param  currPathSize
 * @param  branch
 * @return
 */
int* explorePath(int node, int* currPath, int currPathSize, int branch) {
	//	printf("Call at node %d [branch: %d]\n", node, branch);

	// First get the path
	int startPath = getPath(node, branch);
	int startEven = getPathEven;

	// Get the position in the path
	int pos = -1, i, x;

	if (startEven) {
		for (i = 0; i < evenPathsSizes[startPath]; i++) {
			if (evenPaths[startPath][i] == node) {
				pos = i;
				//				printf("Encountered even path %d [cue at %d]\n", startPath, pos);
			}
		}
	} else {
		for (i = 0; i < oddPathsSizes[startPath]; i++) {
			if (oddPaths[startPath][i] == node) {
				pos = i;
				//				printf("Encountered odd path %d [cue at %d]\n", startPath, pos);
			}
		}
	}

	if (pos == -1) {
		printf("An error occurred: no cue found (starPath: %d, startEven: %d).\n", startPath, startEven);

		return NULL;
	}

	// Now create the left and right path
	// First determine the complete path to walk
	int *pathLeft = malloc(sizeof (int) *MAX_PATH_LENGTH);
	int pathLeftSize = 0;

	// Now process both even and odd paths differently
	if (startEven) {
		// For l: add from pos to end + from 1 to (including) pos
		for (i = pos; i < evenPathsSizes[startPath]; i++) pathLeft[pathLeftSize++] = evenPaths[startPath][i];
		for (i = 1; i <= pos; i++) pathLeft[pathLeftSize++] = evenPaths[startPath][i];
	} else {
		// For l: add from pos to 0 + from 0 to end + from end to pos
		for (i = pos; i >= 0; i--) pathLeft[pathLeftSize++] = oddPaths[startPath][i];
		for (i = 1; i < oddPathsSizes[startPath]; i++) pathLeft[pathLeftSize++] = oddPaths[startPath][i];
		for (i = oddPathsSizes[startPath] - 2; i >= pos; i--) pathLeft[pathLeftSize++] = oddPaths[startPath][i];
	}

	//	getchar();

	// Initialize the paths possibly taken
	int **currPaths = malloc(sizeof (int) *MAX_PATH_LENGTH * MAX_BRANCHES);
	int *currPathsSizes = malloc(sizeof (int) *MAX_BRANCHES);
	int currPathsSize = 0;
	// Mark current path to walked
	if (startEven) walkedEvenPaths[branch][walkedEvenPathsSizes[branch]++] = startPath;
	else walkedOddPaths[branch][walkedOddPathsSizes[branch]++] = startPath;

	// branches contains the branch IDs, branchesPID contains the id in currPath[id] of the path associated with the branch
	int masterBranch = branch;
	//	int branchLeft, branchRight;
	int *branches = malloc(sizeof (int) *MAX_BRANCHES);
	int *branchesPID = malloc(sizeof (int) *MAX_BRANCHES);
	int branchesSize = 0;
	int PID, BID;


	//	printf("Processing standard path\n");

	PID = branchesPID[branchesSize] = createNewCurrPath(currPaths, currPathsSizes, &currPathsSize, currPath, currPathSize);
	BID = branches[branchesSize] = createBranch(masterBranch);

	for (i = 0; i < pathLeftSize; i++) {
		if (getPath(pathLeft[i], BID) == -1) {
			// Just a normal step
			currPaths[PID][currPathsSizes[PID]++] = pathLeft[i];
		} else {
			// Another path found -> recursion!
			currPaths[PID] = explorePath(pathLeft[i], currPaths[PID], currPathsSizes[PID], BID);

			// Find size
			for (x = 0; currPaths[PID][x] != -1; x++);
			currPathsSizes[PID] = x;
		}

		// ALTERNATIVE FOR LOOP_PATH_NOT
		//		 Check if path is complete, if so: i = pathLeftSize. :D
#if LOOP_PATH == 1
		if (pathIsComplete(currPaths[PID], currPathsSizes[PID])) {
			//			printf("Branch %d finished\n", BID);
			i = pathLeftSize;
		}
#endif
	}

	branchesSize++;

	// Find best branch and return that one
	// branchBest id local branch id, branches[branchBest] is global branch id
	int branchBest = -1, branchBestRating = 0;

	for (i = 0; i < branchesSize; i++) {
		// Get rating
		int rating = currPathsSizes[branchesPID[i]];

		// Compare and select
		if (branchBest == -1 || branchBestRating > rating) {
			branchBest = i;
			branchBestRating = rating;
		}
	}

	if (branchBest == -1) {
		printf("An error occurred: no branches were created!\n");
		return NULL;
	}

	//	printf("Merge branch %d (master branch) and %d (local branch: %d) into %d\n", masterBranch, branches[branchBest], branchBest, masterBranch);
	overrideBranch(masterBranch, branches[branchBest]);

	// Pack size and return best branch
	currPaths[branchesPID[branchBest]][currPathsSizes[branchesPID[branchBest]]++] = -1;
	return currPaths[branchesPID[branchBest]];
}