in Education by
I am studying Artificial Intelligence as a module in my Computer Games Programming course and one of my tasks is coding an effective Obstacle Avoidance steering behavior. I've been using Matt Buckland's Programming Game AI by Example to help me, but the framework I'm using differs quite substantially. Instead of using a detection box I have to use feelers so it's closer to the Wall Avoidance function than Obstacle Avoidance. I have a point in box function, instead of a line intersection function, that takes in a Vector2D (The feelers) and a Rect2D (The obstacles). The code iterates through obstacle size and detects if there is a collision at that point. After the collision is detected a steering force is calculated to push the agent away from the obstacle The problem I have is that I don't know if I'm using the right variables in the PointInBox parameters and I'm unable to calculate the steering force because I don't know how to use the Rect2D structure effectively. I've tried attaching different values to the Rect2D variable "obstacles" but I need to get the closest obstacle and normalize it around the Rect2D (I don't really know how to put into words what my issue is I'm bordering beginner/intermediate when it comes to coding). Vector2D w019435fSteeringBehaviours::ObstacleAvoidance(Rect2D obstacles) { CreateFeelers(); double DistToThisIP = 0.0; double DistToClosestIP = MaxDouble; ObstacleManager* Obstacle; int ClosestObstacle = -1; Vector2D SteeringForce, Point, ClosestPoint; for (unsigned int flr = 0; flr < feelers.size(); ++flr) { for (unsigned int o = 0; o < Obstacle->GetObstacles().size(); ++o) { if(PointInBox(feelers[flr], obstacles)) { if (DistToThisIP < DistToClosestIP) { DistToClosestIP = DistToThisIP; ClosestObstacle = o; ClosestPoint = Point; } } } if (ClosestObstacle >= 0) { Vector2D Projection = feelers[flr] - ClosestPoint; SteeringForce = obstacles.normal * Projection.Length(); } } return SteeringForce; } the closest obstacle is crucial I think and has to be a member of obstacles that is then normalized and multiplied by the projection length. But I'm unable to attach any members to obstacles. Any help would be greatly appreciated, thanks. Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
I even don't get how a single Rect2D should be sufficient to describe obstacles. Maybe this is where all your problems start? After a closer look, there are many issues with this code. The pointer to the ObstacleManager is uninitialized. You can refer the following links for a better understanding of the variables: https://docs.opencv.org/trunk/dc/d84/group__core__basic.html http://web.cs.ucla.edu/~miryung/Publications/uw08-dissertation-mkim.pdf

Related questions

0 votes
    I installed Anaconda3 4.4.0 (32 bit) on my Windows 7 Professional machine and imported NumPy and Pandas on Jupyter ... I make it work? Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    Suppose I have a Tensorflow tensor. How do I get the dimensions (shape) of the tensor as integer values? I ... 'Dimension' instead. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I am currently working on an AI Agent that will be able to identify both the start state and the goal ... be greatly appreciated. Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    How to load a model from an HDF5 file in Keras? What I tried: model = Sequential() model.add(Dense(64, ... list index out of range Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    Trying to implement OCR in the bank environment but the challenge is, we don't have access to an internet connection ... in our bank. Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    I have a map stored as a multidimensional array ($map[row][col]) and I'd wish to create a path from ... path inside these values? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    I am using autoencoders to do anomaly detection. So, I have finished training my model and now I want to ... y _true and y_pred Select the correct answer from above options...
asked Jan 29, 2022 in Education by JackTerrance
0 votes
    It is a principal question, regarding the theory of neural networks: Why do we have to normalize the input for ... is not normalized? Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    Is there any method to find out the number of layers and the number of neurons per layer? As input I solely have ... I can't try this. Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    The classifiers in machine learning packages like liblinear and nltk offer a method show_most_informative_features(), which ... lot! Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I'm working through my AI textbook I got and I've come to the last homework problem for my section: "Implement the ... in C# or Java? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I am learning programming (Python and algorithms) and was trying to work on a project that I find interesting. ... is impossible). Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    I have worked all the tutorials and searched for "load csv tensorflow" but just can't get the logic of it all. ... and test the net. Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    I'm trying to implement stochastic gradient descent in MATLAB however I am not seeing any convergence. Mini-batch ... cost of 420. Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    The problem is that I cannot make a script that makes the enemy rotate so that "up" is pointing against the ... something simple... Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
...