Ejemplo n.º 1
0
	void Agent::SetPosition(const Clarity::Vector2& p)
	{
		position = p;
		sprite->SetPosition(ToGF1Vector(p));
		sensorBounds.SetCentre(this->position);
		sensorBounds.SetCentre(position);
		BuildFeelers();
		BuildBounds();
	}
Ejemplo n.º 2
0
bool DBrush::GetBounds(vec3_t min, vec3_t max)
{
    BuildBounds();

    if(!bBoundsBuilt)
        return FALSE;

    VectorCopy(bbox_min, min);
    VectorCopy(bbox_max, max);

    return TRUE;
}
Ejemplo n.º 3
0
	void Agent::Update(float t)
	{
		if (this->hasFailed == false)
		{
			// Our NN inputs are the intersection depths normalised and then fliped.
			// Eg if the intersection depth is the feeler length, then we normalise it
			// and subtract it from one. This way we get a gauge of how far the feeler is
			// into the wall.
			std::vector<float> inputs;
			for (unsigned int i = 0; i < FEELER_COUNT; i++)
			{
				// Normalise the depth value.
				float depth = intersectionDepths[i] / FEELER_LENGTH;

				// Subtract the normalised depth from 1 to end up with how close a wall is.
				// If a feeler has sensed no wall it will be FEELER_LENGTH for intersection depth.
				// So dividing depth / FEELER_LENGTH will result in 1.
				// If we then subtract the normalised depth from 1 -> 1 - 1 == 0.
				// Using this as our input for our NNet, it will guarentee that input to not fire.
				inputs.push_back(1 - depth);
			}

			neuralNet->SetInput(inputs);
			neuralNet->Update();

			// Retrieve outputs. These will be normalised 0 - 1 values.
			float leftForce = neuralNet->GetOutput(NN_OUTPUT_LEFT_FORCE);
			float rightForce = neuralNet->GetOutput(NN_OUTPUT_RIGHT_FORCE);

			// Convert the outputs to a proportion of how much to turn.
			float leftTheta = MAX_ROTATION_PER_SECOND * leftForce;
			float rightTheta = MAX_ROTATION_PER_SECOND * rightForce;

			headingAngle += (leftTheta - rightTheta) * t;
			float speed = (fabs(leftForce + rightForce)) / 2;
			speed *= SPEED;

			speed = Clamp(speed, -SPEED, SPEED);

			Clarity::Vector2 heading;
			heading.x = -sin(Clarity::RADIANS_PER_DEGREE *headingAngle);
			heading.y = cos(Clarity::RADIANS_PER_DEGREE *headingAngle);
			heading *= speed * t;
			distanceDelta = heading.Magnitude();
			this->position += heading;
			
			// Setup the agents sensors.
			sensorBounds.SetCentre(position);
			BuildFeelers();
			BuildBounds();
		}
	}
Ejemplo n.º 4
0
__inline VOID
SortSL (
    LPSL lpsl
    )
{
    WORD   coff      = lpsl->cLnOff;
    LPUL   rgoff     = lpsl->offset;
    LPW    rgln      = (LPW) &lpsl->offset [ coff ];
    WORD   cbnds     = 0;
    LPBNDS rgbnds    = NULL;

    rgbnds = BuildBounds (coff, rgoff, &cbnds);
    if (rgbnds != NULL) {
        SortOffFromBounds (cbnds, rgbnds, coff, rgoff);
        SortLnFromBounds  (cbnds, rgbnds, coff, rgln );

        MHFree (rgbnds);
    }
}
Ejemplo n.º 5
0
	void Agent::Initilise(float headingIn)
	{
		headingAngle = headingIn;

		BuildBounds();
	}