void PushRelabel::discharge (uint32_t vertex) { while (excess_[vertex] > 0) { uint32_t &toVertex = pointer_[vertex]; if (toVertex == network_->getNOfVertices()) { relabel (vertex); toVertex = 0; continue; } if (canPush (vertex, toVertex)) { uint32_t deltaFlow = std::min (excess_[vertex], network_->getTubes()(vertex, toVertex).getResidualCapacity()); push (vertex, toVertex, deltaFlow); } toVertex++; } }
void worldSpace::moveChar(int dir) { //Move left / west if(dir == 0) { if(cYpos == 0) return; if(traversable(cdir)) cYpos -= 1; else if(!traversable(cdir) && canPush(cdir)) { push(cdir); cYpos -= 1; } } //Move right / east else if(dir == 1) { if(cYpos >= COL-1) return; if(traversable(cdir)) cYpos += 1; else if(!traversable(cdir) && canPush(cdir)) { push(cdir); cYpos += 1; } } //Move down / south else if(dir == 2) { if(cXpos >= ROW-1) return; if(traversable(cdir)) cXpos += 1; else if(!traversable(cdir) && canPush(cdir)) { push(cdir); cXpos += 1; } } //move up / north else if(dir == 3) { if(cXpos == 0) return; if(traversable(cdir)) cXpos -= 1; else if(!traversable(cdir) && canPush(cdir)) { push(cdir); cXpos -= 1; } } if(onPortal() == 'd') teleportal(0); else if(onPortal() == 'u') teleportal(1); /* if(lvl1 == lvl2) std::cout << "Level 1 is equal to level 2." << std::endl; else std::cout << "Level 1 and level 2 are different." << std::endl; */ update(); emit moved(); }