Пример #1
0
std::vector<int> MazeSolver::SolveMaze2(std::vector<std::vector<int> > walls) {
	/*
		1. Find a dead end, ignoring the start and end cells
		2. Close all of the cells in the dead end path with walls (4 walls for the closed cells)
		3. Repeat over the entire maze, ignoring the start and end cells
		4. The solution is the only path left
		5. Place solution in path collection
	*/

	int mazeSize = std::sqrt(walls.size());
	int mazeStart = 0;
	int mazeEnd = mazeSize * mazeSize - 1;
	fillDeadEnds(&walls, mazeSize, mazeStart, mazeEnd);	

	std::vector<int> path;
	int current = mazeStart;
	int directionToLast = -1;
	int i = 0;
	while (current != mazeEnd) {
		path.push_back(current);
		int direction = getFreeDirection(walls[current], directionToLast);
		current = getRelative(current, direction, mazeSize);
		directionToLast = getOppositeDirection(direction);
	}
	path.push_back(current);

	return path;
}
Пример #2
0
void ofApp::audioOut(float* output, int bufferSize, int nChannels) {
	float sum = 0;
	for (int i = 0; i < bufferSize; i++){
		output[i * nChannels] = floatBuffer[bufferPosition * nChannels];
		output[i * nChannels + 1] = floatBuffer[bufferPosition * nChannels + 1];
		
		curBuffer[i * nChannels] = output[i * nChannels] * (1<<15);
		curBuffer[i * nChannels + 1] = output[i * nChannels + 1] * (1<<15);
	
		if(i % 2 == 0) { // drop 96khz to 48khz
			bufferPosition++;
			if(bufferPosition == bufferFrames) {
				bufferPosition = 0;
				relativePosition = 0;
				exportXml();
			}
		}
	}
	
	timecoder_submit(&timecoder, &curBuffer[0], bufferSize);
	relativeTtm[ttmPosition] = getRelative();
	absoluteTtm[ttmPosition] = getAbsolute();
	if(exporting) {
		wholeBuffer.push_back(absoluteTtm[ttmPosition] );
	}
	pitchTtm[ttmPosition] = getPitch();
	ttmPosition++;
	if(ttmPosition == relativeTtm.size()) {
		ttmPosition = 0;
	}
}
Пример #3
0
void fillDeadEnd(std::vector<std::vector<int> >* walls, int size, int start, int end, int index, int recurLevel = 0, int maxRecurLevel = -1) {
	std::vector<int>* cell = &(*walls)[index];
	if (index != start && index != end && isDeadEnd(*cell)) {
		int free = getFreeDirection(*cell);
		int next = getRelative(index, free, size);
		(*cell)[free] = 1;
		(*walls)[next][getOppositeDirection(free)] = 1;
		if (maxRecurLevel == -1 || recurLevel < maxRecurLevel) {
			fillDeadEnd(walls, size, start, end, next, recurLevel + 1, maxRecurLevel);
		}
	}
}
Пример #4
0
String Path::getRelativeNoExtension(){
	String rel=getRelative();

	int i;

	for(i=0; i<rel.size(); i++){
		if(rel[i]=='.'){
			break;
		}else{
			
		}
	}

	return rel.substrIndex(0,i);

}
Пример #5
0
Tile *Tile::getRelative(sf::Vector2i pRelativePosition)
{
	return getRelative(pRelativePosition.x, pRelativePosition.y);
}