Donate SIGN UP

MATLAB programing

Avatar Image
newtron | 17:00 Mon 23rd May 2005 | Technology
4 Answers
I like to make  interesting little animations in MATLAB for fun.  I am working on making a line grow in random directions without running into itself.  It starts at a point in the center of the screen and at each time step, it can grow forward one step, or make a 90 degree turn one step.  Obviously, the hard part is to get it to not run into itself.  I have played around with a couple of algorithms, including looking into the future possible moves 1 time step ahead and just trial and error, where when it comes to a dead end, it backs up until it can move again.  The first algorithm got very complicated very fast, so I abandonded it.  The trial and error algotithm works OK but it still tends to end up trapping itself with no escape.  I hope this makes sense.  Does anybody have any other suggestions about possible algorithms?  I must say that I am a novice at MATLAB, but am always trying to learn more.  Thanks.
Gravatar

Answers

1 to 4 of 4rss feed

Best Answer

No best answer has yet been selected by newtron. Once a best answer has been selected, it will be shown here.

For more on marking an answer as the "Best Answer", please visit our FAQ.
If working within a finite area, then it will inevitably collide with itself eventually. Even with an infinite area, the only sure way would be for it to carry on in a straight line. Which kind of defeats the object I guess. Maybe I'm missing the point.... apologies if so. Could you clarify some more?
Question Author

It is within a finite area, and yes it will inevitably collide with itself eventually, but I would like to maximize the time before this happens.  I'm just trying to make some trippy animations for the fun of it.  Other than that, there is no point.  As it is, the line generally makes a block-like pattern and turns into itself and usually the time at which it traps itself is several time steps before it actually hits a deadend.  I need it to be able to look at the general shape made by its previous path and be able to tell if the next move will lead to a trap.   

Heading into the world of AI algorithms here I think. On the other hand, if you know what sort of moves would lead to a quick dead end, then you could hard code them into the program. For a true way of doing it though I think you're looking at some sort of AI, which I wouldn't know where to start with LOL. Google is your friend.
Question Author
Thanks for the suggestions OBonio.

1 to 4 of 4rss feed

Do you know the answer?

MATLAB programing

Answer Question >>

Related Questions

Sorry, we can't find any related questions. Try using the search bar at the top of the page to search for some keywords, or choose a topic and submit your own question.