当前位置: 首页>>代码示例>>C++>>正文


C++ Coord::c方法代码示例

本文整理汇总了C++中Coord::c方法的典型用法代码示例。如果您正苦于以下问题:C++ Coord::c方法的具体用法?C++ Coord::c怎么用?C++ Coord::c使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Coord的用法示例。


在下文中一共展示了Coord::c方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pathExists

bool pathExists(char maze[][10], int sr, int sc, int er, int ec)
{
	//returns true if there is a path from (sr, sc) to (er,ec) thru
	//the maze; otherwise false

	//maze is 10x10, x == wall, . == walkway.
	//coords range from (0,0) to (9,9)

	queue<Coord> coordQueue;
	Coord c(sr, sc);
	coordQueue.push(c);
	maze[sr][sc] = '@'; //this indicates we have checked this spot
	//need to check the surrounding paths 
	while (coordQueue.size() != 0)
	{
		Coord curr = coordQueue.front();
		coordQueue.pop(); //gets the first value in the stack
		if (curr.c() == ec && curr.r() == er) //at the end
			return true;

		int r = curr.r();
		int c = curr.c();
		//check all 4 directions
		if (maze[r-1][c] == '.') //N
		{
			coordQueue.push(Coord(r-1, c)); //if we can move N, pushes onto stack
			maze[r-1][c] = '@';
		}

		if (maze[r][c+1] == '.') //e
		{
			coordQueue.push(Coord(r, c+1));
			maze[r][c+1] = '@';
		}

		if (maze[r+1][c] == '.') //S
		{
			coordQueue.push(Coord(r+1, c));
			maze[r+1][c] = '@';
		}
		if (maze[r][c-1] == '.') //W
		{
			coordQueue.push(Coord(r, c-1));
			maze[r][c-1] = '@';
		}
		
	}
	return false;
}
开发者ID:YurieCo,项目名称:CS_classwork,代码行数:49,代码来源:mazequeue.cpp

示例2: pathExists

bool pathExists(string maze[], int nRows, int nCols, int sr, int sc, int er, int ec){
    // Return true if there is a path from (sr,sc) to (er,ec)
    // through the maze; return false otherwise
    queue<Coord> list;
    Coord begin(sr, sc);
    Coord end(er, ec);
    list.push(begin);
    maze[sr][sc] = '-';

    while (!list.empty()) {
        Coord top = list.front();
        cout << "Row: " << top.r() << "\tCol: " <<top.c() <<endl;
        list.pop();
        if (top.r() == er && top.c() == ec)
            return true;
        if (maze[top.r()-1][top.c()] == '.'){ // check north
            maze[top.r()-1][top.c()] = '-';
            list.push(Coord(top.r()-1, top.c()));
        }
        if (maze[top.r()][top.c()+1] == '.'){ // check east
            maze[top.r()][top.c()+1] = '-';
            list.push(Coord(top.r(), top.c()+1));
        }
        if (maze[top.r()+1][top.c()] == '.'){ // check south
            maze[top.r()+1][top.c()] = '-';
            list.push(Coord(top.r()+1, top.c()));
        }
        if (maze[top.r()][top.c()-1] == '.'){ // check west
            maze[top.r()][top.c()-1] = '-';
            list.push(Coord(top.r(), top.c()-1));
        }
    }
    
    return false;
    
}
开发者ID:gsuresh97,项目名称:CS32Homework2,代码行数:36,代码来源:mazequeue.cpp

示例3: pathExists

bool pathExists(string maze[], int nRows, int nCols, int sr, int sc, int er, int ec){
    stack<Coord> coordStack;

    Coord start_point(sr, sc);
    Coord end_point(er, ec);
    coordStack.push(start_point);
    maze[start_point.r()][start_point.c()] = 'O';

    while(!coordStack.empty()){
        Coord curr = coordStack.top();
	//cerr << "( " << curr.r() << ", " << curr.c() << " )" << endl;
	coordStack.pop();


	int curr_r = curr.r();
	int curr_c = curr.c();
	if(curr_r == end_point.r() && curr_c == end_point.c()) 
	    return true;
	else{
	    if(curr_r - 1 >= 0 && maze[curr_r - 1][curr_c] == '.'){ // North
	        Coord next_point(curr_r - 1,  curr_c);
		maze[curr_r - 1] [curr_c] = 'O';
		coordStack.push(next_point);
	    }
	    if(curr_c + 1 < nCols && maze[curr_r][curr_c + 1] == '.'){ // East
	        Coord next_point(curr_r,  curr_c + 1);
		maze[curr_r] [curr_c + 1] = 'O';
		coordStack.push(next_point);
	    }   
	    if(curr_r + 1 < nRows && maze[curr_r + 1][curr_c] == '.'){ // South
	        Coord next_point(curr_r + 1,  curr_c);
		maze[curr_r + 1][curr_c] = 'O';
		coordStack.push(next_point);
	    }
	    if(curr_c - 1 >= 0 && maze[curr_r ][curr_c - 1] == '.'){ // West
	        Coord next_point(curr_r,  curr_c - 1);
		maze[curr_r][curr_c - 1] = 'O';
		coordStack.push(next_point);
	    }
	}
    }
    return false;
}
开发者ID:wenliwen64,项目名称:cs32,代码行数:43,代码来源:mazestack.cpp

示例4: pathExists

bool pathExists(string maze[], int nRows, int nCols, int sr, int sc, int er, int ec)
{
    // Return true if there is a path from (sr,sc) to (er,ec)
    // through the maze; return false otherwise

	queue<Coord> coordStack;
	coordStack.push(Coord(sr, sc));
	maze[sr][sc] = '*';

	while (! coordStack.empty())
	{
		Coord front = coordStack.front();
		coordStack.pop();

		int front_r = front.r();
		int front_c = front.c();

		if (front_r == er && front_c == ec)
			return true;

		if (front_r-1 >= 0 && front_r-1 < nRows && maze[front_r-1][front_c] == '.')		// North
		{
			coordStack.push(Coord(front_r-1, front_c));
			maze[front_r-1][front_c] = '*';
		}
		if (front_c+1 >= 0 && front_c+1 < nCols && maze[front_r][front_c+1] == '.')		// East
		{
			coordStack.push(Coord(front_r, front_c+1));
			maze[front_r][front_c+1] = '*';
		} 
		if (front_r+1 >= 0 && front_r+1 < nRows && maze[front_r+1][front_c] == '.')		// South
		{
			coordStack.push(Coord(front_r+1, front_c));
			maze[front_r+1][front_c] = '*';
		}
		if (front_c-1 >= 0 && front_c-1 < nCols && maze[front_r][front_c-1] == '.')		// West
		{
			coordStack.push(Coord(front_r, front_c-1));
			maze[front_r][front_c-1] = '*';
		}
	}
	return false;
}
开发者ID:thenathanyang,项目名称:UCLA,代码行数:43,代码来源:mazequeue.cpp

示例5: pathExists

bool pathExists(string maze[], int nRows, int nCols, int sr, int sc, int er, int ec)
{
	stack<Coord> coordStack; //create a stack of Coords
	coordStack.push(Coord(sr,sc));
	maze[sr][sc] = '#';

	while(!coordStack.empty())
	{
		Coord x = coordStack.top(); // obtain the latest Coord in the queue           
        coordStack.pop(); //pop the latest Coord off the stack
        int row = x.r(); //set row and col equal to the row and col of the popped Coord
        int col = x.c();

		if((row == er) && (col == ec)) //check if we are at ending position
			return true;

		if(maze[row-1][col] == '.') //check slot to the NORTH		
		{
			coordStack.push(Coord(row-1,col));
			maze[row-1][col] = '#';
		}

		if(maze[row][col+1] == '.') //check slot to the EAST
		{
			coordStack.push(Coord(row,col+1));
			maze[row][col+1] = '#';
		}

		if(maze[row+1][col] == '.') //check slot to the SOUTH
		{
			coordStack.push(Coord(row+1,col));
			maze[row+1][col] = '#';
		}

		if(maze[row][col-1] == '.') //check slot to the WEST
		{
			coordStack.push(Coord(row,col-1));
			maze[row][col-1] = '#';
		}
	}
	return false;	
}
开发者ID:puneethv29,项目名称:CS32,代码行数:42,代码来源:mazestack.cpp

示例6: pathExists

bool pathExists(string maze[], int nRows, int nCols, int sr, int sc, int er, int ec)
// Return true if there is a path from (sr,sc) to (er,ec)
// through the maze; return false otherwise
{
	queue<Coord> coordStack;
	coordStack.push(Coord(sr,sc));
	maze[sr][sc] = '*';
	while (!coordStack.empty())
	{
		Coord curr = coordStack.front();
		coordStack.pop();
		if (curr.r() == er && curr.c() == ec)
			return true;
		//if can move north
		if (maze[curr.r()-1][curr.c()] != 'X' && maze[curr.r()-1][curr.c()] != '*')
		{
			coordStack.push( Coord(curr.r()-1, curr.c() ));
			maze[curr.r()-1][curr.c()] = '*';
		}
		//if can move east
		if (maze[curr.r()][curr.c()+1] != 'X' && maze[curr.r()][curr.c()+1] != '*')
		{
			coordStack.push( Coord(curr.r(), curr.c()+1 ));
			maze[curr.r()][curr.c()+1] = '*';
		}
		//if can move south
		if (maze[curr.r()+1][curr.c()] != 'X' && maze[curr.r()+1][curr.c()] != '*')
		{
			coordStack.push( Coord(curr.r()+1, curr.c() ));
			maze[curr.r()+1][curr.c()] = '*';
		}
		//if can move west
		if (maze[curr.r()][curr.c()-1] != 'X' && maze[curr.r()][curr.c()-1] != '*')
		{
			coordStack.push( Coord(curr.r(), curr.c()-1 ));
			maze[curr.r()][curr.c()-1] = '*';
		}
	}
	return false; //no solution
}
开发者ID:shirley-zhou,项目名称:CS32,代码行数:40,代码来源:mazequeue.cpp

示例7: pathExists

bool pathExists(string maze[], int nRows, int nCols, int sr, int sc, int er, int ec)
{
    // Return true if there is a path from (sr,sc) to (er,ec)
    // through the maze; return false otherwise
    
    queue<Coord> coordQueue;
    coordQueue.push(Coord(sr,sc));
    while(!coordQueue.empty())
    {
        Coord frontOfQueue = coordQueue.front();
        cerr << frontOfQueue.r() << " " << frontOfQueue.c() << " popped" << endl;
        coordQueue.pop();
        
        if(frontOfQueue.r() == er && frontOfQueue.c() == ec)
            return true;
        if(maze[frontOfQueue.r()-1][frontOfQueue.c()] == '.')
            coordQueue.push(Coord(frontOfQueue.r()-1,frontOfQueue.c()));
        
        if(maze[frontOfQueue.r()][frontOfQueue.c()+1] == '.')
            coordQueue.push(Coord(frontOfQueue.r(),frontOfQueue.c()+1));
        
        if(maze[frontOfQueue.r()+1][frontOfQueue.c()] == '.')
            coordQueue.push(Coord(frontOfQueue.r()+1,frontOfQueue.c()));
        
        if(maze[frontOfQueue.r()][frontOfQueue.c()-1] == '.')
            coordQueue.push(Coord(frontOfQueue.r(),frontOfQueue.c()-1));
        
        
        maze[frontOfQueue.r()][frontOfQueue.c()] = 'X';
        
        
    }
    return false;
}
开发者ID:dannyolaugh,项目名称:CS32,代码行数:34,代码来源:mazequeue.cpp

示例8: pathExists

bool pathExists(string maze[], int nRows, int nCols, int sr, int sc, int er, int ec)
{
	// Return true if there is a path from (sr,sc) to (er,ec)
	// through the maze; return false otherwise

	queue<Coord> coordQueue;
	coordQueue.push(Coord(sr,sc));
	maze[sr][sc] = '*';
	while(!coordQueue.empty())
	{
		Coord cur = coordQueue.front();
		if(cur.r() == er && cur.c() == ec)
			return true;
		coordQueue.pop();

		if(cur.r() >= 0 && maze[cur.r()-1][cur.c()] == '.')
		{
			coordQueue.push(Coord(cur.r()-1,cur.c()));
			maze[cur.r()-1][cur.c()] = '*';
		}
		if(cur.c() < nCols && maze[cur.r()][cur.c()+1] == '.')
		{
			coordQueue.push(Coord(cur.r(),cur.c()+1));
			maze[cur.r()][cur.c()+1] = '*';
		}
		if(cur.r() < nRows && maze[cur.r()+1][cur.c()] == '.')
		{
			coordQueue.push(Coord(cur.r()+1,cur.c()));
			maze[cur.r()+1][cur.c()] = '*';
		}
		if(cur.c() >= 0 && maze[cur.r()][cur.c()-1] == '.')
		{
			coordQueue.push(Coord(cur.r(),cur.c()-1));
			maze[cur.r()][cur.c()-1] = '*';
		}
	}

	return false;
}
开发者ID:zachyee,项目名称:CS-32,代码行数:39,代码来源:mazequeue.cpp

示例9: stepsToPlayer

int StudentWorld:: stepsToPlayer(int x, int y)
{
    int Map[64][64];
    for (int k = 0; k < 64; k++)
    {
        for (int j = 0; j < 64; j++)
        {
            if (isOpen(k, j))
                Map[k][j] = 999;
            else
                Map[k][j] = -1;
        }
    }
    
    queue<Coord> QQ;
    int x2 = player->getX();
    int y2 = player->getY();
    
    QQ.push(Coord(x,y));
    Coord current = QQ.front();
    Map[x][y] = 0;
    
    while (!QQ.empty())
    {
        current = QQ.front();
        QQ.pop();
        
        if (current.r() == x2 && current.c() == y2)
        {
            break;
        }
        
        if (Map[current.r()+1][current.c()] > Map[current.r()][current.c()]+1)
        {
            QQ.push(Coord(current.r()+1, current.c()));
            Map[current.r()+1][current.c()]= min(Map[current.r()][current.c()]+1, Map[current.r()+1][current.c()]);
        }
        if (Map[current.r()][current.c()+1] > Map[current.r()][current.c()]+1)
        {
            QQ.push(Coord(current.r(), current.c()+1));
            Map[current.r()][current.c()+1]= min(Map[current.r()][current.c()]+1, Map[current.r()][current.c()+1]);
        }
        if (Map[current.r()-1][current.c()] > Map[current.r()][current.c()]+1)
        {
            QQ.push(Coord(current.r()-1, current.c()));
            Map[current.r()-1][current.c()]= min(Map[current.r()][current.c()]+1, Map[current.r()-1][current.c()]);
        }
        if (Map[current.r()][current.c()-1] > Map[current.r()][current.c()]+1)
        {
            QQ.push(Coord(current.r(), current.c()-1));
            Map[current.r()][current.c()-1]= min(Map[current.r()][current.c()]+1, Map[current.r()][current.c()-1]);
        }
    }
    
    return Map[x2][y2];
}
开发者ID:roflcopterprime,项目名称:FrackMan,代码行数:56,代码来源:StudentWorld.cpp

示例10: if

void StudentWorld:: moveShortPath(int x1, int y1, int x2, int y2, Actor* acty)
{
    
    int Map[64][64];
    for (int k = 0; k < 64; k++)
    {
        for (int j = 0; j < 64; j++)
        {
            if (isOpen(k, j))
                Map[k][j] = 999;
            else
                Map[k][j] = -1;
        }
    }
    
    queue<Coord> QQ;
    stack<Coord> stacky;
    
    QQ.push(Coord(x1,y1));
    Map[x1][y1] = 0;
    
    while (!QQ.empty())
    {
        Coord current = QQ.front();
        QQ.pop();
        
        if (current.r() == x2 && current.c() == y2)
        {
            break;
        }
        
        if (Map[current.r()+1][current.c()] > Map[current.r()][current.c()]+1)
        {
            QQ.push(Coord(current.r()+1, current.c()));
            Map[current.r()+1][current.c()]= min(Map[current.r()][current.c()]+1, Map[current.r()+1][current.c()]);
        }
        if (Map[current.r()][current.c()+1] > Map[current.r()][current.c()]+1)
        {
            QQ.push(Coord(current.r(), current.c()+1));
            Map[current.r()][current.c()+1]= min(Map[current.r()][current.c()]+1, Map[current.r()][current.c()+1]);
        }
        if (Map[current.r()-1][current.c()] > Map[current.r()][current.c()]+1)
        {
            QQ.push(Coord(current.r()-1, current.c()));
            Map[current.r()-1][current.c()]= min(Map[current.r()][current.c()]+1, Map[current.r()-1][current.c()]);
        }
        if (Map[current.r()][current.c()-1] > Map[current.r()][current.c()]+1)
        {
            QQ.push(Coord(current.r(), current.c()-1));
            Map[current.r()][current.c()-1]= min(Map[current.r()][current.c()]+1, Map[current.r()][current.c()-1]);
        }
    }
    
    bool found = false;
    Coord firstStep = Coord(60,60);
    
    stacky.push(Coord(x2,y2));
    
    while (!found && !stacky.empty())
    {
        Coord current = stacky.top();
        stacky.pop();
        
        if (current.r() == x1 && current.c() == y1)
        {
            found = true;
            break;
        }
        
        if (Map[current.r()-1][current.c()] == Map[current.r()][current.c()]-1)
        {
            stacky.push(Coord(current.r()-1, current.c()));
            firstStep = Coord(current.r(), current.c());
        }
        if (Map[current.r()][current.c()+1] == Map[current.r()][current.c()]-1)
        {
            stacky.push(Coord(current.r(), current.c()+1));
            firstStep = Coord(current.r(), current.c());
        }
        if (Map[current.r()+1][current.c()] == Map[current.r()][current.c()]-1)
        {
            stacky.push(Coord(current.r()+1, current.c()));
            firstStep = Coord(current.r(), current.c());
        }
        if (Map[current.r()][current.c()-1] == Map[current.r()][current.c()]-1)
        {
            stacky.push(Coord(current.r(), current.c()-1));
            firstStep = Coord(current.r(), current.c());
        }
        
    }
    
    Actor::Direction dir;
    int x = acty->getX();
    int y = acty->getY();
    if (firstStep.r() > acty->getX())
    {
        dir = Actor::right;
        acty->setDirection(dir);
        acty->moveTo(x+1, y);
//.........这里部分代码省略.........
开发者ID:roflcopterprime,项目名称:FrackMan,代码行数:101,代码来源:StudentWorld.cpp

示例11: createShortestDistance

void MyMaze::createShortestDistance(int sr, int sc, int m_dist[][MAZE_WIDTH])
{
	//Set every element of the m_distance array to 99.
	for (int row = 0; row < MAZE_HEIGHT; row ++)	{
		for (int col = 0; col < MAZE_WIDTH; col ++)
			m_dist[row][col]	= 99;
	}
	
	//Set position (sr,sc) of the m_distance array to 0.
	m_dist [sr][sc]	= 0;
	
	//Push the starting coordinate (sr,sc) onto the coordinate stack.
	stack<Coord> coordStack;
	coordStack.push(Coord(sr, sc));
	
	while (!coordStack.empty())
	{
		Coord cur	= coordStack.top();		//uses Copy Contructor of Coord class
		coordStack.pop();
		
		/*
		 m_dist [cur.r()-1][cur.c()]			//above (NORTH) of current location
		 m_dist [cur.r()+1][cur.c()]			//below (SOUTH) of current location
		 m_dist [cur.r()][cur.c()-1]			//left  (WEST) of current location
		 m_dist [cur.r()][cur.c()+1]			//right (EAST) of current location
		 */
		
		int m	=	m_dist [cur.r()-1][cur.c()];	//finds the smallest value between the 4 directions
		if (m_dist [cur.r()+1][cur.c()] < m)	   //directions centered at m_dist [cur.r()][cur.c()]
			m	= m_dist [cur.r()+1][cur.c()];
		if (m_dist [cur.r()][cur.c()-1] < m)
			m	= m_dist [cur.r()][cur.c()-1];
		if (m_dist [cur.r()][cur.c()+1] < m)
			m	= m_dist [cur.r()][cur.c()+1];
		
		if (m_dist [cur.r()][cur.c()] > m+1)	//reached a number on m_distance array thats smaller than current path
			m_dist [cur.r()][cur.c()]	= m+1;	//prevent overwriting previous path on m_distance array
		
		const int v	=	m_dist [cur.r()][cur.c()];	//holds current value on m_distance array
		//Move North?
		if (GetGridContents(cur.c(), cur.r()-1) != WALL && m_dist [cur.r()-1][cur.c()] > v+1)
		{	
			m_dist [cur.r()-1][cur.c()]	= v+1;
			coordStack.push(Coord(cur.r()-1, cur.c()));
		}
		//Move East?
		if (GetGridContents(cur.c()+1, cur.r()) != WALL && m_dist [cur.r()][cur.c()+1] > v+1)
		{
			m_dist [cur.r()][cur.c()+1]	= v+1;
			coordStack.push(Coord(cur.r(), cur.c()+1));
		}
		//Move South?
		if (GetGridContents(cur.c(), cur.r()+1) != WALL && m_dist [cur.r()+1][cur.c()] > v+1)
		{
			m_dist [cur.r()+1][cur.c()]	= v+1;
			coordStack.push(Coord(cur.r()+1, cur.c()));
		}
		//Move West?
		if (GetGridContents(cur.c()-1, cur.r()) != WALL && m_dist [cur.r()][cur.c()-1] > v+1)
		{
			m_dist [cur.r()][cur.c()-1]	= v+1;
			coordStack.push(Coord(cur.r(), cur.c()-1));
		}
	}
}
开发者ID:vchen02,项目名称:Pac-Man-Game,代码行数:65,代码来源:MyMaze.cpp

示例12: pathExists

bool pathExists(string maze[], int nRows, int nCols, int sr, int sc, int er, int ec)
{
	stack<Coord> coordStack;
	coordStack.push(Coord(sr, sc));
	maze[sr][sc] = '$';
	while (!coordStack.empty())
	{
		Coord c = (coordStack.top());
		cerr << "(" << c.r() << ", " << c.c() << ")" << endl;
		coordStack.pop();
		if (c.r() == er && c.c() == ec)
			return true;
		else
		{
			if ((c.r() - 1) >= 0 && maze[c.r() - 1][c.c()] == '.')
			{
				coordStack.push(Coord(c.r() - 1, c.c()));
				maze[c.r() - 1][c.c()] = '$';
			}
			if ((c.c() + 1) < nCols && maze[c.r()][c.c() + 1] == '.')
			{
				coordStack.push(Coord(c.r(), c.c() + 1));
				maze[c.r()][c.c() + 1] = '$';
			}
			if ((c.r() + 1) < nRows && maze[c.r() + 1][c.c()] == '.')
			{
				coordStack.push(Coord(c.r() + 1, c.c()));
				maze[c.r() + 1][c.c()] = '$';
			}
			if ((c.c() - 1) >= 0 && maze[c.r()][c.c() - 1] == '.')
			{
				coordStack.push(Coord(c.r(), c.c() - 1));
				maze[c.r()][c.c() - 1] = '$';
			}
		}
	}
	return false;
}
开发者ID:GNYORLY,项目名称:CS32-HW2,代码行数:38,代码来源:mazestack.cpp

示例13: pathExists

bool pathExists(char maze[][10], int sr, int sc, int er, int ec)
{
    // Return true if there is a path from (sr,sc) to (er,ec)
    // through the maze; return false otherwise
    
    stack<Coord> coordStack; // declare a stack of Coords
    
    //Push the starting coordinate (sr,sc) onto the coordinate stack and
    //update maze[sr][sc] to indicate that the algorithm has encountered
    //it (i.e., set maze[sr][sc] to have a value other than '.').
    
    Coord startPoint(sr, sc);
    coordStack.push(startPoint);
    maze[sr][sc] = '#';
    
    while(!coordStack.empty()) //While the stack is not empty
    {
        //Pop the top coordinate off the stack. This gives you the current
        //(r,c) location that your algorithm is exploring.
        Coord cur = coordStack.top();
        //cerr << '(' << cur.r() << ',' << cur.c() << ')'<< endl;
        coordStack.pop();
        
        if(cur.r() == er && cur.c() == ec)//If the current (r,c) coordinate is equal to the ending coordinate,
            return true;    //then we've solved the maze so return true!
        
        //Check each place you can move from the current cell:
        if(maze[cur.r()-1][cur.c()] == '.') //try to move NORTH
        {
            Coord curPoint(cur.r()-1, cur.c());
            coordStack.push(curPoint);
            maze[cur.r()-1][cur.c()] = '#'; //update maze[r-1][c] to indicate the algorithm has encountered it.
        }
        if(maze[cur.r()][cur.c()+1] == '.') //try to move EAST
        {
            Coord curPoint(cur.r(), cur.c()+1);
            coordStack.push(curPoint);
            maze[cur.r()][cur.c()+1] = '#'; //update maze[r][c+1] to indicate the algorithm has encountered it.
        }
        if(maze[cur.r()+1][cur.c()] == '.') //try to move SOUTH
        {
            Coord curPoint(cur.r()+1, cur.c());
            coordStack.push(curPoint);
            maze[cur.r()+1][cur.c()] = '#'; //update maze[r+1][c] to indicate the algorithm has encountered it.
        }
        if(maze[cur.r()][cur.c()-1] == '.') //try to move WEST
        {
            Coord curPoint(cur.r(), cur.c()-1);
            coordStack.push(curPoint);
            maze[cur.r()][cur.c()-1] = '#'; //update maze[r][c-1] to indicate the algorithm has encountered it.
        }
        
    }
    return false;
}
开发者ID:tsengliwei,项目名称:UCLA-CS-32-HW2,代码行数:55,代码来源:mazestack.cpp


注:本文中的Coord::c方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。