GTPWrapper::GTPWrapper(int bs, bool isp, double iovalue, double ikomi, int ilvl, int ieyesize, int tsteps) { // unstuckgnugno = true; // headingsupport = iheadingsupport; fheading = new int; sheading = new int; *fheading = 0; *sheading=0; thinksteps = tsteps; eyesize = ieyesize; ovalue = iovalue; pos1 = new int[2]; pos2 = new int[2]; sp = isp; komi = ikomi; lvl = ilvl; // for pure gnugo(production) // p1 = "--mode gtp --boardsize "; //with logging enabled, for debugging // p1 = "--input-log gnugo_log_i.txt --output-log gnugo_log_o.txt --error-log gnugo_log_e.txt gnugo --mode gtp --boardsize "; p1 = "--mode gtp --boardsize "; //dunno :P boyes test code // p1 = "-i /dev/ttyp6 -o /dev/ttyp6 -e /dev/ttyp6 gnugo --mode gtp --boardsize "; stringstream ss1; ss1 << p1; //setting up the cmdline for right boardsize. ss1 << bs << " --level " << lvl << " --komi " << komi; p1 = ss1.str(); bsize = bs; resetPos(); cout << "bsize: "<<bsize<<" pos1-0:"<<pos1[0]<<" pos2-0:" << pos2[0]<<endl; //board.insert(board.begin(),(bsize*bsize),0); board = state((int)pow(bsize,2)*2); // for(int i=0;i<(bsize*bsize);i++)//setting up the board.. // board.push_back(0); pipe(nPipeIn); pipe(nPipeOut); // runit(); toGnugo = new fdostream(); fromGnugo = new fdistream(); nChildFds = new int[3]; // string file = "logio"; // if (ConnectProcess("gnugo", p1, &fraGnugo, &tilGnugo, 0, 0, 0)) pid_t * nPid = new pid_t(); if (ConnectProcess(string("gnugo"), p1, toGnugo, fromGnugo, NULL, nPid, nChildFds)) { cerr << "Failed to change process image (execvp) in parent process to " << "gnugo" << ". System error message: " << strerror(errno) << "\n."; //return 1; } }
void Desk::setup () { resetPos (); _files.clear (); _rightMargin = 950; _debug_level = 0; _debug = 0; _do_writeDesk = false; _allow_dispose = true; _fbase_seq = 0; _row_count = 0; // our record of the last valid row count _dirty = false; }
void GiftListView::removeItem(CCNode* item) { for (int i=0;i<(int)mGiftItems.count();i++) { if (item == mGiftItems.objectAtIndex(i)) { mGiftItems.removeObject(item); item->removeAllChildrenWithCleanup(true); break; } } resetPos(); }
void Upload::resume(int64_t aStart, int64_t aSize) noexcept { setSegment(Segment(aStart, aSize)); setFlag(Upload::FLAG_RESUMED); delayTime = 0; auto s = stream.get()->releaseRootStream(); s->setPos(aStart); stream.reset(s); resetPos(); if((aStart + aSize) < fileSize) { stream.reset(new LimitedInputStream<true>(stream.release(), aSize)); } }
//update the balls position void Ball::update() { if(ballOn) { //signal that we have started to move from the pong if(moveCounter < 2) { moveCounter++; } //get the future/new position vector newpos; facingDir = normalize(facingDir); facingDir.x *= FACING_MULT; facingDir.y *= FACING_MULT; newpos.x = (int)(pos.x + facingDir.x); newpos.y = (int)(pos.y + facingDir.y); //check for collision int collision = checkMove(newpos.x, newpos.y); //are we are not hitting anything if(collision == 2) { //if we are not hitting the bricks if(level->getLevelInfo(newpos.x, newpos.y) == TILE_EMPTY) { //keep moving move(facingDir.x, facingDir.y); } //if we are hitting the BLOCKS else { //get the current blocks normal vector normDir; normDir = level->getEnemiesNormal((newpos.x / GRID_SIZE_WIDTH), (newpos.y / GRID_SIZE_HEIGHT)); //clamp the facingDir and store it in tmp //so when we move we dont visually overlap with the block we just hit vector tmp = clampBlocks(newpos.x, newpos.y); //move the ball on top of the block move(tmp.x,tmp.y); //kill the block level->emptyBlock(newpos.x / GRID_SIZE_WIDTH, newpos.y / GRID_SIZE_HEIGHT); //update our blocks and empty spaces level->updateEnemies(); //draw our ball drawArea->drawSprite(SPRITE_BALL, pos.x + tmp.x, pos.y + tmp.y); //bounce the ball off of the blocks normal and set //the last member to true meaning that we are conducting bounce off blocks bounceBall(normDir.x, normDir.y, true); } } //if we are hitting the pong player else if(collision == 1) { //bounce the ball based on the side of the player we hit bounceBall(0,0,false); } //if we are hitting the wall else if(collision == 0) { //just bounce the ball bounceBall(0,0,false); } //if we have died else if(collision == -1) { //if player is alive if(player->isAlive()) { //remove balls lives/players lives player->addLives(-1); addLives(-1); //reset the ball position and the players pos resetPos(); player->resetPos(); } } } }
void SlushMotor::setAsHome(void) { resetPos(); }
void BackGround::update(float dt, cocos2d::Layer* layer){ resetPos(layer, FLONTBG); resetPos(layer, BACKBG); }
int WidgetPDial::handle(int event) { double dragsize, min = minimum(), max = maximum(), result; int dy; if (event == FL_RELEASE && Fl::event_clicks() == 1) { Fl::event_clicks(0); value(reset_value); tipwin->hide(); value_damage(); if (this->when() != 0) do_callback(); return 1; } int old_mod_state; switch(event) { case FL_PUSH: mod_state = Fl::event_state() & MOD_MASK; if (!use_rounding) { if (integer_step) set_rounding(0); else if (mod_state == MOD_MASK) set_rounding(5); else if (mod_state == FL_SHIFT) set_rounding(4); else set_rounding((Fl::event_button3() || mod_state & FL_CTRL) ? 3 : 2); } oldvalue = value(); old_y = Fl::event_y(); case FL_DRAG: getPos(); old_mod_state = mod_state; mod_state = Fl::event_state() & MOD_MASK; if (old_mod_state != mod_state) { oldvalue = value(); old_y = Fl::event_y(); if (!use_rounding) { if (integer_step) set_rounding(0); else if (mod_state == MOD_MASK) set_rounding(5); else if (mod_state == FL_SHIFT) set_rounding(4); else set_rounding((Fl::event_button3() || mod_state & FL_CTRL) ? 3 : 2); } break; } dy = old_y - Fl::event_y(); if (dy < -1 || dy > 1) Fl::event_clicks(0); if (!integer_step && mod_state == MOD_MASK) dragsize = 200000.0f; else if (!integer_step && mod_state == FL_SHIFT) dragsize = 20000.0f; else dragsize = (Fl::event_button3() || mod_state & MOD_MASK) ? 1000.0f : 200.0f; value(clamp(oldvalue + dy / dragsize * (max - min))); tipwin->showValue(transform(value())); value_damage(); if(this->when() != 0) do_callback(); return 1; case FL_MOUSEWHEEL: if (Fl::event_buttons() || Fl::belowmouse() != this) return 1; mod_state = Fl::event_state() & MOD_MASK; dy = - Fl::event_dy(); if (integer_step) { if (!use_rounding) set_rounding(0); result = (int)(value() + dy * ((Fl::event_ctrl() || Fl::event_shift()) ? 1 : 8)); } else { float dragsize; if (mod_state == MOD_MASK) { dragsize = 100000.0; if (!use_rounding) set_rounding(5); } else if (mod_state == FL_SHIFT) { dragsize = 10000.0; if (!use_rounding) set_rounding(4); } else if (mod_state == FL_CTRL) { dragsize = 1000.0; if (!use_rounding) set_rounding(3); } else { dragsize = 100.0; if (!use_rounding) set_rounding(2); } result = value() + dy / dragsize * (max - min); } value(clamp(result)); tipwin->showValue(transform(value())); value_damage(); if(this->when() != 0) do_callback(); return 1; case FL_ENTER: getPos(); tipwin->showText(); return 1; case FL_HIDE: case FL_LEAVE: tipwin->hide(); resetPos(); break; case FL_RELEASE: if (integer_step) { float rounded = floorf(value() + 0.5); value(clamp(rounded)); } tipwin->hide(); resetPos(); if(this->when() == 0) do_callback(); return 1; } return 0; //#endif }
/** * \brief Default constructor */ SpecificWorker::SpecificWorker(MapPrx& mprx) : GenericWorker(mprx) { innerModel = new InnerModel("/home/robocomp/robocomp/files/innermodel/hexapod.xml"); proxies[0] = legcontroller1_proxy; proxies[1] = legcontroller2_proxy; proxies[2] = legcontroller3_proxy; proxies[3] = legcontroller4_proxy; proxies[4] = legcontroller5_proxy; proxies[5] = legcontroller6_proxy; numPata=0; X=0; Z=0; for(int i=0;i<6;i++){ posIniciales[i] = proxies[i]->getStateLeg(); legCoord[i] = QVec::vec3(posIniciales[i].x,posIniciales[i].y,posIniciales[i].z); } qDebug()<<"POSICIONES INICIALES: "<<posIniciales[0].x<<posIniciales[0].y<<posIniciales[0].z; /* Patas para el mov tripod */ //Patas 1,4,5 legsTripodOn[0]=0; legsTripodOn[1]=3; legsTripodOn[2]=4; //Patas 2,3,6 legsTripodOff[0]=1; legsTripodOff[1]=2; legsTripodOff[2]=5; /* Patas para el mov OneByOne */ //Pata 1 legsOneByOneOn[0]=0; //Patas 2,3,4,5,6 legsOneByOneOff[0]=1; legsOneByOneOff[1]=2; legsOneByOneOff[2]=3; legsOneByOneOff[3]=4; legsOneByOneOff[4]=5; /* Patas para el mov Quadruped */ //Patas 1,2 legsQuadrupedOn[0]=0; legsQuadrupedOn[1]=1; //Patas 3,4,5,6 legsQuadrupedOff[0]=2; legsQuadrupedOff[1]=3; legsQuadrupedOff[2]=4; legsQuadrupedOff[3]=5; /* Vectores de inicio para el Bezier */ lini=QVec::vec3(0,0,0); lfin=QVec::vec3(0,0,0); lmed=QVec::vec3(0,70,0); try { motores = jointmotor_proxy->getAllMotorParams(); } catch(const Ice::Exception &ex) { std::cout << ex << std::endl; } connect(comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(cambiarEstado(int))); connect(resetButton, SIGNAL(clicked()), this, SLOT(resetPos())); }