We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Obstacle Avoidance steering behavior question
Page Index Toggle Pages: 1
Obstacle Avoidance steering behavior question (Read 1051 times)
Obstacle Avoidance steering behavior question
Nov 22nd, 2009, 4:00pm
 
Hello,
I have an experiment with steering behavior code from Danial Shiffman.
What I have tried was adding an obstacle object to the scene for flocking boids to avoid it but it still not working. I was confuse about a code.
Can somebody help me?

here is link to file.
[download202.mediafire.com/etzuzy94gepg/ilxgmn5ianz/sketch_nov22e.zip]
   
thanks! Roll Eyes
Re: Obstacle Avoidance steering behavior question
Reply #1 - Nov 24th, 2009, 7:51pm
 
In your code, you declare "dia" to be a random number between 10 and 30, but since that's a global declaration (outside of all functions and classes), it will only be randomized once, on setup.  You probably want to remove "dia" and just use:
diameter = random(10,30);
in your object constructor.

final int OBSTACLE_DISTANCE = 15;
isn't used at all in your code, and there isn't a need in Processing to declare ints as "final" (unlike Java).

Your boids don't respond to the obstacles because neither has any code instructing them how to do so.  There are a variety of ways to make obstacles, but you could start by giving boids a behavior that says "if there's an obstacle within a certain distance, perform a steering behavior [shift my angle left or right] to avoid it."  To do that you''ll need a loop that checks all the obstacles, by location and size, in relation to the boid.

If you reply to this post, this thread will move to the top of the queue without starting a new one.  You can also change the title of the message that shows in the forum, if your question changes.  And since your file host seems to make me wait 60 seconds before showing the download link, I would personally suggest http://pasteit4me.com for no-frills public pasting.
Re: Obstacle Avoidance steering behavior question
Reply #2 - Nov 25th, 2009, 12:37am
 
Thank you for suggestion. I will try to work on it.
Thanks!
Page Index Toggle Pages: 1