コード例 #1
0
void moveToBasket(int motorpower)
{
	rotate(right, motorpower, east);
	drive(motorpower, 8, yes);
	moveBucket(down);
	wait10Msec(100);
	moveBucket(up);
	drive(-(motorpower), 8, yes);
	rotate(left, motorpower, north);
	arm(down);
}
コード例 #2
0
task main()
{
	while (true)
	{
		if(nNxtButtonPressed == kEnterButton)
		{
			lift();
		}
		else if(nNxtButtonPressed == kLeftButton)
		{
			moveBucket(true, false);
		}
		else if(nNxtButtonPressed == kRightButton)
		{
			moveBucket(false, false);
		}
		else
		{
			moveBucket(false, true);
		}
	}


}
コード例 #3
0
ファイル: EratBig.cpp プロジェクト: Bacteriaphage/primesieve
/// Add an empty bucket to the front of lists_[segment].
void EratBig::pushBucket(uint_t segment)
{
  // if the stock_ is empty allocate new buckets
  if (!stock_)
  {
    const int N = config::BYTES_PER_ALLOC / sizeof(Bucket);
    Bucket* buckets = new Bucket[N];
    for (int i = 0; i < N-1; i++)
      buckets[i].setNext(&buckets[i + 1]);
    buckets[N-1].setNext(NULL);
    pointers_.push_back(buckets);
    stock_ = buckets;
  }
  Bucket* emptyBucket = stock_;
  stock_ = stock_->next();
  moveBucket(*emptyBucket, lists_[segment]);
}
コード例 #4
0
ファイル: EratBig.cpp プロジェクト: Bacteriaphage/primesieve
/// Cross-off the multiples of big sieving primes
/// from the sieve array.
///
void EratBig::crossOff(byte_t* sieve)
{
  // process the buckets in lists_[0] which hold the sieving primes
  // that have multiple(s) in the current segment
  while (lists_[0]->hasNext() || !lists_[0]->empty())
  {
    Bucket* bucket = lists_[0];
    lists_[0] = NULL;
    pushBucket(0);
    do {
      crossOff(sieve, bucket->begin(), bucket->end());
      Bucket* processed = bucket;
      bucket = bucket->next();
      processed->reset();
      moveBucket(*processed, stock_);
    } while (bucket);
  }

  // move the list corresponding to the next segment
  // i.e. lists_[1] to lists_[0] ...
  std::rotate(lists_.begin(), lists_.begin() + 1, lists_.end());
}
コード例 #5
0
ファイル: Design.cpp プロジェクト: cathyatseneca/gam671-astar
// update updates the position and orientation of each object according to the 
// actions initiated by the user
//
void Design::update() {


    int delta;
	int dt=0;
	int ds=0;
    delta = now - lastUpdate;
    lastUpdate = now;
	Vector hpos;
    if (now - lastFireTime_ > 100) {
		if(pressed(GREEDY_KEY)){
			searchroutine_=GREEDY;
			lastFireTime_=now;
		}
		else if(pressed(UNIFORM_KEY)){
			searchroutine_=UNIFORM;
			lastFireTime_=now;
		}
		else if(pressed(ASTAR_KEY)){
			searchroutine_=ASTAR;
			lastFireTime_=now;
		}
		else if(pressed(IDASTAR_KEY)){
			searchroutine_=IDASTAR;
			lastFireTime_=now;
		}
		else if(pressed(NEXTBOX)){
			selectloc_=(selectloc_+1)%map_.numvert();
			hpos=highlighter_->position();
			highlighter_->translate(-hpos.x,-hpos.y,-hpos.z);
			highlighter_->translate(map_.vx(selectloc_),map_.vy(selectloc_),map_.vz(selectloc_));
			lastFireTime_=now;
		}
		else if(pressed(PREVBOX)){
			selectloc_=(selectloc_==0)?map_.numvert()-1:selectloc_-1;
			hpos=highlighter_->position();
			highlighter_->translate(-hpos.x,-hpos.y,-hpos.z);
			highlighter_->translate(map_.vx(selectloc_),map_.vy(selectloc_),map_.vz(selectloc_));
			lastFireTime_=now;
		}
		else if(pressed(STARTANIM)){
			if(!ismoving_){
				if(selectloc_!=whichbox_){
					bool searchsuccess=false;        //stores return value of path finding function
					switch (searchroutine_){
						case GREEDY: searchsuccess=greedy(selectloc_); break;
						case UNIFORM: searchsuccess=uniformCost(selectloc_); break;
						case ASTAR: searchsuccess=aStar(selectloc_); break;
						case IDASTAR: searchsuccess=iDAStar(selectloc_); break;
					}/*switch*/
					if(searchsuccess){
						ismoving_=true;
						currloc_=0;
					}
				}
			}//!ismoving_
		}
	}
	if(ismoving_){
		  //move bucket along
		  bool done=false;
		  float leftover=(float)delta/UNITS_PER_SEC;  //amount of time leftover moving bucket along the edge
		  //in this time frame.
		  int dest=path_[currloc_+1];
	  	  while(!done && moveBucket(path_[currloc_],path_[currloc_+1],leftover)){

			//function returns true if destination was reached
			//in this time frame.  so if it was reached,
			//continue to next node or if end of path stop the movment
			currloc_++;
			if(currloc_==numnodes_-1){
				whichbox_=path_[numnodes_-1];
				done=true;
				currloc_=0;
				ismoving_=false;
			}
		  }
	   }


	
 
    lastUpdate = now;
 
}