RTREE_TEMPLATE
void RTREE_QUAL::PickSeeds(PartitionVars* a_parVars) {
    int seed0, seed1;
    ELEMTYPEREAL worst, waste;
    ELEMTYPEREAL area[MAXNODES + 1];

    for (int index = 0; index < a_parVars->m_total; ++index) {
        area[index] = CalcRectVolume(&a_parVars->m_branchBuf[index].m_rect);
    }

    worst = -a_parVars->m_coverSplitArea - 1;
    for (int indexA = 0; indexA < a_parVars->m_total - 1; ++indexA) {
        for (int indexB = indexA + 1; indexB < a_parVars->m_total; ++indexB) {
            Rect oneRect = CombineRect(&a_parVars->m_branchBuf[indexA].m_rect, &a_parVars->m_branchBuf[indexB].m_rect);
            waste = CalcRectVolume(&oneRect) - area[indexA] - area[indexB];
            if (waste > worst) {
                worst = waste;
                seed0 = indexA;
                seed1 = indexB;
            }
        }
    }

    Classify(seed0, 0, a_parVars);
    Classify(seed1, 1, a_parVars);
}
RTREE_TEMPLATE
void RTREE_QUAL::ChoosePartition(PartitionVars* a_parVars, int a_minFill) {
    ASSERT(a_parVars);

    ELEMTYPEREAL biggestDiff;
    int group, chosen, betterGroup;

    InitParVars(a_parVars, a_parVars->m_branchCount, a_minFill);
    PickSeeds(a_parVars);

    while (((a_parVars->m_count[0] + a_parVars->m_count[1]) < a_parVars->m_total)
            && (a_parVars->m_count[0] < (a_parVars->m_total - a_parVars->m_minFill))
            && (a_parVars->m_count[1] < (a_parVars->m_total - a_parVars->m_minFill))) {
        biggestDiff = (ELEMTYPEREAL) - 1;
        for (int index = 0; index < a_parVars->m_total; ++index) {
            if (PartitionVars::NOT_TAKEN == a_parVars->m_partition[index]) {
                Rect* curRect = &a_parVars->m_branchBuf[index].m_rect;
                Rect rect0 = CombineRect(curRect, &a_parVars->m_cover[0]);
                Rect rect1 = CombineRect(curRect, &a_parVars->m_cover[1]);
                ELEMTYPEREAL growth0 = CalcRectVolume(&rect0) - a_parVars->m_area[0];
                ELEMTYPEREAL growth1 = CalcRectVolume(&rect1) - a_parVars->m_area[1];
                ELEMTYPEREAL diff = growth1 - growth0;
                if (diff >= 0) {
                    group = 0;
                } else {
                    group = 1;
                    diff = -diff;
                }

                if (diff > biggestDiff) {
                    biggestDiff = diff;
                    chosen = index;
                    betterGroup = group;
                } else if ((diff == biggestDiff) && (a_parVars->m_count[group] < a_parVars->m_count[betterGroup])) {
                    chosen = index;
                    betterGroup = group;
                }
            }
        }
        Classify(chosen, betterGroup, a_parVars);
    }

    // If one group too full, put remaining rects in the other
    if ((a_parVars->m_count[0] + a_parVars->m_count[1]) < a_parVars->m_total) {
        if (a_parVars->m_count[0] >= a_parVars->m_total - a_parVars->m_minFill) {
            group = 1;
        } else {
            group = 0;
        }
        for (int index = 0; index < a_parVars->m_total; ++index) {
            if (PartitionVars::NOT_TAKEN == a_parVars->m_partition[index]) {
                Classify(index, group, a_parVars);
            }
        }
    }

    ASSERT((a_parVars->m_count[0] + a_parVars->m_count[1]) == a_parVars->m_total);
    ASSERT((a_parVars->m_count[0] >= a_parVars->m_minFill) &&
            (a_parVars->m_count[1] >= a_parVars->m_minFill));
}
Beispiel #3
0
//----------------------------------------------------------------------------
void BspTree2::GetPartition (const BspPolygon2& polygon, const Vector2d& v0,
    const Vector2d& v1, BspPolygon2& pos, BspPolygon2& neg,
    BspPolygon2& coSame, BspPolygon2& coDiff) const
{
    // Construct splitting line from first coincident edge.
    Vector2d end0 = polygon.mVArray[mCoincident[0].I0];
    Vector2d end1 = polygon.mVArray[mCoincident[0].I1];

    Vector2d intr;

    switch (Classify(end0, end1, v0, v1, intr))
    {
    case TRANSVERSE_POSITIVE:
        GetPosPartition(polygon, intr, v1, pos, neg, coSame, coDiff);
        GetNegPartition(polygon, v0, intr, pos, neg, coSame, coDiff);
        break;
    case TRANSVERSE_NEGATIVE:
        GetPosPartition(polygon, v0, intr, pos, neg, coSame, coDiff);
        GetNegPartition(polygon, intr, v1, pos, neg, coSame, coDiff);
        break;
    case ALL_POSITIVE:
        GetPosPartition(polygon, v0, v1, pos, neg, coSame, coDiff);
        break;
    case ALL_NEGATIVE:
        GetNegPartition(polygon, v0, v1, pos, neg, coSame, coDiff);
        break;
    default:  // COINCIDENT
        GetCoPartition(polygon, v0, v1, pos, neg, coSame, coDiff);
        break;
    }
}
Permonkey::Permonkey(float x, float y, Point lTile, TileMap tileMap, unordered_map<string, vector<string>> objList) : character("img/permacaco_anim_ss.png", 4, -1, 4), tileMap(tileMap),
step("music/passo_et_verde.wav") {
    box = Rect(x-character.GetWidth()/2,y-character.GetHeight(), character.GetWidth(), character.GetHeight());
	rotation = 0;
	roomID = 0;
	crt = 0;
	objective.x = 994;
	objective.y = 470;
	tile = lTile;
	actionCharacter = RESTING;
	choice = NO_CHOICE;
	timer.Restart();
	rest.Restart();

	hunger = rand()%21;
	money = rand()%900+101;
	found = true;
	satisfaction = 50;

	preference = "Pirate";
	roomChoice = "";
	actualGoal = 0;

	Classify(objList);

	gone = false;
	

	objectSelect = -1;
	
	
}
Permonkey::Permonkey(ifstream &file, TileMap tileMap, unordered_map<string, vector<string>> objList) : 
character("img/permacaco_anim_ss.png", 4, -1, 4), tileMap(tileMap) {
	file.read(reinterpret_cast<char*> (&box), sizeof(Rect));
	file.read(reinterpret_cast<char*> (&rotation), sizeof(float));
	file.read(reinterpret_cast<char*> (&roomID), sizeof(int));
	file.read(reinterpret_cast<char*> (&crt), sizeof(int));
	file.read(reinterpret_cast<char*> (&objective), sizeof(Point));
	file.read(reinterpret_cast<char*> (&tile), sizeof(Point));
	file.read(reinterpret_cast<char*> (&actionCharacter), sizeof(ActionCharacter));
	file.read(reinterpret_cast<char*> (&choice), sizeof(Choice));
	file.read(reinterpret_cast<char*> (&hunger), sizeof(int));
	file.read(reinterpret_cast<char*> (&money), sizeof(int));
	file.read(reinterpret_cast<char*> (&found), sizeof(bool));
	file.read(reinterpret_cast<char*> (&satisfaction), sizeof(int));
	file.read(reinterpret_cast<char*> (&actualGoal), sizeof(int));
	file.read(reinterpret_cast<char*> (&objectSelect), sizeof(int));
	int size;
	file.read(reinterpret_cast<char*> (&size), sizeof(int));
	preference.resize(size);
	for (int p = 0; p < preference.size(); p++){
		file.read(reinterpret_cast<char*> (&preference[p]), sizeof(char));
	}
	file.read(reinterpret_cast<char*> (&size), sizeof(int));
	roomChoice.resize(size);
	for (int p = 0; p < roomChoice.size(); p++){
		file.read(reinterpret_cast<char*> (&roomChoice[p]), sizeof(char));
	}
	file.read(reinterpret_cast<char*> (&timer), sizeof(Timer));
	file.read(reinterpret_cast<char*> (&rest), sizeof(Timer));
	Classify(objList);
}
bool IntrLine2Segment2<Real>::Find ()
{
    Vector2<Real> kDiff;
    Real afParameter[2];
    m_iIntersectionType = Classify(afParameter,&kDiff,0);

    if (m_iIntersectionType == IT_POINT)
    {
        // Test whether the line-line intersection is on the segment.
        if (Math<Real>::FAbs(afParameter[1]) <= m_pkSegment->Extent)
        {
            m_iQuantity = 1;
            m_kPoint = m_pkLine->Origin + afParameter[0]*m_pkLine->Direction;
        }
        else
        {
            m_iQuantity = 0;
            m_iIntersectionType = IT_EMPTY;
        }
    }
    else if (m_iIntersectionType == IT_SEGMENT)
    {
        m_iQuantity = INT_MAX;
    }
    else
    {
        m_iQuantity = 0;
    }

    return m_iIntersectionType != IT_EMPTY;
}
Beispiel #7
0
bool IntrLine2Ray2<Real>::Find ()
{
    Vector2<Real> diff;
    Real parameter[2];
    mIntersectionType = Classify(parameter, &diff, 0);

    if (mIntersectionType == IT_POINT)
    {
        // Test whether the line-line intersection is on the ray.
        if (parameter[1] >= (Real)0)
        {
            mQuantity = 1;
            mPoint = mLine->Origin + parameter[0]*mLine->Direction;
        }
        else
        {
            mQuantity = 0;
            mIntersectionType = IT_EMPTY;
        }
    }
    else if (mIntersectionType == IT_RAY)
    {
        mQuantity = INT_MAX;
    }
    else
    {
        mQuantity = 0;
    }

    return mIntersectionType != IT_EMPTY;
}
Beispiel #8
0
// Classify polygon with respect to this plane
int RebPlane::Classify(const RebPolygon &Poly) {
   int NumFront=0, NumBack=0, NumPlanar=0;
   int nClass;

   // cast away const
   RebPolygon *pPoly = ((RebPolygon*)&Poly);

   int NumPoints = pPoly->GetNumPoints();

   // loop through all points
   for (int i=0; i < NumPoints; i++) {
      nClass = Classify( pPoly->m_pPoints[i] );
      
      if (nClass == RebFRONT)     NumFront++;
      else if (nClass == RebBACK) NumBack++;
      else {
         NumFront++;
         NumBack++;
         NumPlanar++;
         }
      } // for
   
   // all points are planar
   if (NumPlanar == NumPoints)
      return RebPLANAR;
   // all points are in front of plane
   else if (NumFront == NumPoints)
      return RebFRONT;
   // all points are on backside of plane
   else if (NumBack == NumPoints)
      return RebBACK;
   // poly is intersecting the plane
   else
      return RebCLIPPED;
   } // Classify
Beispiel #9
0
//----------------------------------------------------------------------------
int BspTree2::PointLocation (const BspPolygon2& polygon,
    const Vector2d& vertex) const
{
    // Construct splitting line from first coincident edge.
    Vector2d end0 = polygon.mVArray[mCoincident[0].I0];
    Vector2d end1 = polygon.mVArray[mCoincident[0].I1];

    switch (Classify(end0, end1, vertex))
    {
    case ALL_POSITIVE:
        if (mPosChild)
        {
            return mPosChild->PointLocation(polygon, vertex);
        }
        else
        {
            return 1;
        }
    case ALL_NEGATIVE:
        if (mNegChild)
        {
            return mNegChild->PointLocation(polygon, vertex);
        }
        else
        {
            return -1;
        }
    default:  // COINCIDENT
        return CoPointLocation(polygon, vertex);
    }
}
bool IntrSegment2Segment2<Real>::Find ()
{
    Vector2<Real> diff;
    Real parameter[2];
    mIntersectionType = Classify(parameter, &diff, 0);

    if (mIntersectionType == IT_POINT)
    {
        // Test whether the line-line intersection is on the segments.
        if (Math<Real>::FAbs(parameter[0]) <= mSegment0->Extent
        &&  Math<Real>::FAbs(parameter[1]) <= mSegment1->Extent)
        {
            mQuantity = 1;
            mPoint = mSegment0->Center + parameter[0]*mSegment0->Direction;
        }
        else
        {
            mQuantity = 0;
            mIntersectionType = IT_EMPTY;
        }
    }
    else if (mIntersectionType == IT_SEGMENT)
    {
        mQuantity = INT_MAX;
    }
    else
    {
        mQuantity = 0;
    }

    return mIntersectionType != IT_EMPTY;
}
ICopyFilterOption::EResult
CRemovePathsBySubString::ShallRemove (const CFullGraphNode* node) const
{
    // short-cut

    if (filterPaths.empty())
        return ICopyFilterOption::KEEP_NODE;

    // path to classify

    const CDictionaryBasedTempPath& path = node->GetPath();

    // most paths can be filtered quickly using the classification cache

    PathClassification classification = QuickClassification (path.GetBasePath());

    // take a closer look if necessary

    if ((classification != REMOVE) && !path.IsFullyCachedPath())
        classification = Classify (path.GetPath());

    // return the result

    return classification == REMOVE
        ? removeSubTrees ? ICopyFilterOption::REMOVE_SUBTREE
                         : ICopyFilterOption::REMOVE_NODE
        : ICopyFilterOption::KEEP_NODE;
}
bool IntrRay2Segment2<Real>::Find ()
{
    Vector2<Real> diff;
    Real parameter[2];
    mIntersectionType = Classify(parameter, &diff, 0);

    if (mIntersectionType == IT_POINT)
    {
        // Test whether the line-line intersection is on the ray and on the
        // segment.
        if (parameter[0] >= (Real)0
        &&  Math<Real>::FAbs(parameter[1]) <= mSegment->Extent)
        {
            mQuantity = 1;
            mPoint = mRay->Origin + parameter[0]*mRay->Direction;
        }
        else
        {
            mQuantity = 0;
            mIntersectionType = IT_EMPTY;
        }
    }
    else if (mIntersectionType == IT_SEGMENT)
    {
        mQuantity = INT_MAX;
    }
    else
    {
        mQuantity = 0;
    }

    return mIntersectionType != IT_EMPTY;
}
bool IntrLine2Segment2<Real>::Test ()
{
    Vector2<Real> diff;
    Real parameter[2];
    mIntersectionType = Classify(parameter, &diff, 0);

    if (mIntersectionType == IT_POINT)
    {
        // Test whether the line-line intersection is on the segment.
        if (Math<Real>::FAbs(parameter[1]) <= mSegment->Extent)
        {
            mQuantity = 1;
        }
        else
        {
            mQuantity = 0;
            mIntersectionType = IT_EMPTY;
        }
    }
    else if (mIntersectionType == IT_SEGMENT)
    {
        mQuantity = INT_MAX;
    }
    else
    {
        mQuantity = 0;
    }

    return mIntersectionType != IT_EMPTY;
}
int Classify(Image* img) {
	int sum = 0;
	for (int i = 0 ; i < featureSize ; i++) {
		sum += Classify(img, i);
	}
	return sum >= 0 ? 1 : -1;
}
Beispiel #15
0
//LRC - work out gibs from blood colour, instead.
BOOL CBaseMonster :: HasAlienGibs( void )
{
	int myClass = Classify();

	// these types of monster don't use gibs
	if ( myClass == CLASS_NONE || myClass == CLASS_MACHINE ||
		 myClass == CLASS_PLAYER_BIOWEAPON && myClass == CLASS_ALIEN_BIOWEAPON)
	{
		return FALSE;
	}
	else
	{
		return (this->m_bloodColor == BLOOD_COLOR_GREEN);
	}

//	int myClass = Classify();
//
//	if ( myClass == CLASS_ALIEN_MILITARY ||
//		 myClass == CLASS_ALIEN_MONSTER	||
//		 myClass == CLASS_ALIEN_PASSIVE  ||
//		 myClass == CLASS_INSECT  ||
//		 myClass == CLASS_ALIEN_PREDATOR  ||
//		 myClass == CLASS_ALIEN_PREY )
//
//		 return TRUE;
//
//	return FALSE;
}
Beispiel #16
0
void Train(perceptron_t *p, int *inputs, int classification)
{
	int error = classification - Classify(p, inputs);
	for (int i = 0; i < 2; i++)
	{
		p->weights[i] += p->learningRate * (float) error * *(inputs + i);
	}
}
Beispiel #17
0
int LearnCV(TMatrix input,  TVariables output, unsigned int minFeatures, unsigned int upToPower, unsigned int folds, TPoint *ray, unsigned int *power){
	bool oldOUT_ALPHA = OUT_ALPHA;
	OUT_ALPHA = false;
	unsigned int optDegree = 0;
	unsigned int optError = INT_MAX;
	unsigned int shortFolds = folds - 1;

	/* Get the optimal degree (outer cross-validation loop) */
	vector<TMatrix> spaceExtensions(upToPower);
	for (unsigned int i = 0; i < upToPower; i++){
		ExtendWithProducts(input, i + 1, &spaceExtensions[i]); // get the (i + 1)-th space extention
		Initialization(spaceExtensions[i], output, minFeatures); // initialize
		/* Prepare slider and start to cut data */
		unsigned sliderSize = (unsigned)ceil((double)n / folds); unsigned chSizeVal = n%folds - 1;
		TMatrix xSlider(sliderSize); TVariables ySlider(sliderSize);
		for (unsigned int j = 0; j < sliderSize; j++){
			xSlider[j] = TPoint(d);
			for (unsigned int k = 0; k < d; k++){xSlider[j][k] = x[k][j*shortFolds]; x[k].erase(x[k].begin() + j*shortFolds);}
			ySlider[j] = y[j*shortFolds]; y.erase(y.begin() + j*shortFolds);
			difference -= ySlider[j]; if (ySlider[j] > 0){numMore--;}else{numLess--;}			
		}
		n -= sliderSize;
		/* Cross-validation for the (i + 1)-th space extension (inner cross-validation loop) */
		unsigned int error = 0; TPoint p(0);
		double tmpXSliderVal; int tmpYSliderVal;
		for (unsigned int j = 0; j < folds; j++){
			/* Estimate the current cut */			
			Alpha(&p);
			TVariables res(0);
			Classify(xSlider, p, &res);
			for (unsigned int k = 0; k < sliderSize; k++){error += abs(res[k] - ySlider[k])/2;}
			/* Increment the pointer */
			if (j == shortFolds){break;}
			/* Replace the slider */
			if (j == chSizeVal){
				for (unsigned int l = 0; l < d; l++){x[l].push_back(xSlider[sliderSize - 1][l]);} y.push_back(ySlider[sliderSize - 1]);
				n++; difference += ySlider[sliderSize - 1]; if (ySlider[sliderSize - 1] > 0){numMore++;}else{numLess++;}
				sliderSize--; xSlider.erase(xSlider.begin() + sliderSize); ySlider.erase(ySlider.begin() + sliderSize);
//				for (unsigned int j = 0; j < d; j++){x[j].shrink_to_fit();} y.shrink_to_fit(); - IT IS TOO DANGEROUS
			}
			for (unsigned int k = 0; k < sliderSize; k++){
				for (unsigned int l = 0; l < d; l++){tmpXSliderVal = x[l][k*shortFolds + j]; x[l][k*shortFolds + j] = xSlider[k][l]; xSlider[k][l] = tmpXSliderVal;}
				difference += ySlider[k]; if (ySlider[k] > 0){numMore++;}else{numLess++;}
				tmpYSliderVal = y[k*shortFolds + j]; y[k*shortFolds + j] = ySlider[k]; ySlider[k] = tmpYSliderVal;
				difference -= ySlider[k]; if (ySlider[k] > 0){numMore--;}else{numLess--;}
			}
		}
		/* Check if we've got a better result */ 
		if (error < optError){optError = error; optDegree = i + 1; if (optError == 0){break;}}
	}

	OUT_ALPHA = oldOUT_ALPHA;
	/* Eventually get the classification ray */
	Initialization(spaceExtensions[optDegree - 1], output, minFeatures); // initialize
	power[0] = optDegree;
	return Alpha(ray);
}
Beispiel #18
0
void ResetBDAC(void)
	{
	int dummy ;
	QRSDet(0,1) ;	// Reset the qrs detector
	RRCount = 0 ;
	Classify(BeatBuffer,0,0,&dummy,&dummy,1) ;
	InitBeatFlag = 1 ;
   BeatQueCount = 0 ;	// Flush the beat que.
	}
Beispiel #19
0
void DouglasPeuckerMod::Encode(std::vector<IGCFixEnhanced> &fixes,
                                             const unsigned start, const unsigned end) {
  unsigned max_loc = 0;
  std::stack<std::pair<unsigned, unsigned>> stack;
  const unsigned fixes_size = end - start;
  DistQueue dists;

  double temp,
         max_dist,
         abs_max_dist_squared = 0.0,
         abs_max_dist,
         threshold_squared = pow(threshold, 2);

  /**
   * use normal douglas peucker distance (perpendicular to segment) for lon/lat
   * and use simple distance calculation for time
   */

  // simplify using Douglas-Peucker
  if (fixes_size > 2) {
    stack.push(std::pair<unsigned, unsigned>(start, end - 1));

    while (stack.size() > 0) {
      std::pair<unsigned, unsigned> current = stack.top();
      stack.pop();
      max_dist = 0;

      for (unsigned i = current.first + 1; i < current.second; i++) {
        temp = std::max(DistanceGeo(fixes[i].location,
                                    fixes[current.first].location,
                                    fixes[current.second].location),
                        DistanceTime(fixes[i].clock,
                                     fixes[current.first].clock,
                                     fixes[current.second].clock));

        if (temp > max_dist) {
          max_dist = temp;
          max_loc = i;
        }
      }

      if (max_dist > abs_max_dist_squared) {
        abs_max_dist_squared = max_dist;
      }

      if (max_dist > threshold_squared) {
        dists.push(std::pair<unsigned, double>(max_loc, sqrt(max_dist)));
        stack.push(std::pair<unsigned, unsigned>(current.first, max_loc));
        stack.push(std::pair<unsigned, unsigned>(max_loc, current.second));
      }
    }
  }

  abs_max_dist = sqrt(abs_max_dist_squared);

  Classify(fixes, dists, abs_max_dist, start, end);
}
void Train(int index) {
	w1[index] = 1;
	w2[index] = 0;
	for (int i = 0 ; i < negCount + posCount ; i++) {
		int choice = i; //No longer random
		Image* img = GetTrainAt(choice);
		int x = img->FeatureAt(index);
		int h = Classify(img, index);
		w1[index] -= epsilon * (h - img->Type()) * x;
		w2[index] -= epsilon * (h - img->Type());
	}
}
Beispiel #21
0
BOOL CBaseMonster::__MAKE_VHOOK(HasHumanGibs)()
{
	int myClass = Classify();

	if (myClass == CLASS_HUMAN_MILITARY
		|| myClass == CLASS_PLAYER_ALLY
		|| myClass == CLASS_HUMAN_PASSIVE
		|| myClass == CLASS_PLAYER)
		 return TRUE;

	return FALSE;
}
Beispiel #22
0
double Test(const CvSVM &svm, const cv::Mat &features, const cv::Mat &targets) {
  double error = 0;
  for(size_t rowIndex = 0; rowIndex < features.rows; ++rowIndex) {
    const int *target = targets.ptr<int>(rowIndex);
    int predictedTarget = Classify(svm, features.row(rowIndex));
    if(predictedTarget != target[0]) {
      error++;
    }
    // std::cout << predictedTarget << ' ' << target[0] << std::endl;
  }
  return error / features.rows;
  // std::cout << std::endl;
}
Beispiel #23
0
BOOL CBaseMonster::__MAKE_VHOOK(HasAlienGibs)()
{
	int myClass = Classify();
	if (myClass == CLASS_ALIEN_MILITARY
		|| myClass == CLASS_ALIEN_MONSTER
		|| myClass == CLASS_ALIEN_PASSIVE
		|| myClass == CLASS_INSECT
		|| myClass == CLASS_ALIEN_PREDATOR
		|| myClass == CLASS_ALIEN_PREY)
		 return TRUE;

	return FALSE;
}
Beispiel #24
0
bool CHL1BaseNPC::HasHumanGibs( void )
{
	Class_T myClass = Classify();

	if ( myClass == CLASS_HUMAN_MILITARY ||
		 myClass == CLASS_PLAYER_ALLY	||
		 myClass == CLASS_HUMAN_PASSIVE  ||
		 myClass == CLASS_PLAYER )

		 return true;

	return false;
}
Beispiel #25
0
bool Perceptron::Train(const std::vector<double>& input, const int& output)   // return whether theta has been changed
{
	//std::cout << Classify(input) << output << std::endl;
	if( Classify(input) != output ) {
		for( size_t i = 0; i < _insize; ++i ) {
			//std::cout << "theta " << i << " = " << _theta[i] << std::endl;
			//std::cout << "Delta theta " << i << " = " << input[i]*output << std::endl;
			_theta[i] += input[i]*output;
			//std::cout << "theta " << i << " = " << _theta[i] << std::endl;
		}
		return true;
	}
	return false;
}
Beispiel #26
0
bool CHL1BaseNPC::HasAlienGibs( void )
{
	Class_T myClass = Classify();

	if ( myClass == CLASS_ALIEN_MILITARY ||
		 myClass == CLASS_ALIEN_MONSTER	||
		 myClass == CLASS_INSECT  ||
		 myClass == CLASS_ALIEN_PREDATOR  ||
		 myClass == CLASS_ALIEN_PREY )

		 return true;

	return false;
}
//-----------------------------------------------------------------------------
// Purpose: LeapTouch - this is the headcrab's touch function when it is in the air.
// Input  : *pOther - 
//-----------------------------------------------------------------------------
void CNPC_Headcrab::LeapTouch( CBaseEntity *pOther )
{
	if ( pOther->Classify() == Classify() )
	{
		return;
	}

	// Don't hit if back on ground
	if ( !(GetFlags() & FL_ONGROUND) )
	{
		BiteSound();
		TouchDamage( pOther );
	}

	SetTouch( NULL );
}
PRUint32
nsHttpPipeline::CancelPipeline(nsresult originalReason)
{
    PRUint32 i, reqLen, respLen, total;
    nsAHttpTransaction *trans;

    reqLen = mRequestQ.Length();
    respLen = mResponseQ.Length();
    total = reqLen + respLen;

    // don't count the first response, if presnet
    if (respLen)
        total--;

    if (!total)
        return 0;

    // any pending requests can ignore this error and be restarted
    // unless it is during a CONNECT tunnel request
    for (i = 0; i < reqLen; ++i) {
        trans = Request(i);
        if (mConnection && mConnection->IsProxyConnectInProgress())
            trans->Close(originalReason);
        else
            trans->Close(NS_ERROR_NET_RESET);
        NS_RELEASE(trans);
    }
    mRequestQ.Clear();

    // any pending responses can be restarted except for the first one,
    // that we might want to finish on this pipeline or cancel individually.
    // Higher levels of callers ensure that we don't process non-idempotent
    // tranasction with the NS_HTTP_ALLOW_PIPELINING bit set
    for (i = 1; i < respLen; ++i) {
        trans = Response(i);
        trans->Close(NS_ERROR_NET_RESET);
        NS_RELEASE(trans);
    }

    if (respLen > 1)
        mResponseQ.TruncateLength(1);

    DontReuse();
    Classify(nsAHttpTransaction::CLASS_SOLO);

    return total;
}
Beispiel #29
0
// Classify
int imageNet::Classify( float* rgba, uint32_t width, uint32_t height, float* confidence )
{
	// verify parameters
	if( !rgba || width == 0 || height == 0 )
	{
		printf(LOG_TRT "imageNet::Classify( 0x%p, %u, %u ) -> invalid parameters\n", rgba, width, height);
		return -1;
	}
	
	// downsample and convert to band-sequential BGR
	if( !PreProcess(rgba, width, height) )
	{
		printf(LOG_TRT "imageNet::Classify() -- PreProcess() failed\n");
		return -1;
	}
	
	return Classify(confidence);
}
Beispiel #30
0
//-----------------------------------------------------------------------------
// Purpose: 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CNPCSimpleTalker::CanSayHello( void )
{
#ifndef HL1_DLL
	if ( Classify() == CLASS_PLAYER_ALLY_VITAL )
		return false;
#endif
	
	if ( GetSpeechFilter() && GetSpeechFilter()->NeverSayHello() )
		return false;

	if ( !GetExpresser()->CanSpeakConcept(TLK_HELLO) || GetExpresser()->SpokeConcept(TLK_HELLO) )
		return false;

	if ( !IsOkToSpeak() )
		return false;

	return true;
}