Jump to content
  • Advertisement
Sign in to follow this  
_jinx_

Recursion and a little more..

This topic is 4843 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

For the past hour I have been studying Recursion, as I began to practice I started thinking of a method that would look like this:
[SOURCE]

int main()
{
for (i = 1; i <= Divs; i++)
    {
        function(one, two, three, level);
        cout << ruler << "\n";
    }
}
void function(int a, int b, int c, int stage)
{
    if (stage == 0)
        return;
    //some funky code what ever..
    anotherFunction( a, b, c, d );	
    function(ar, low, mid, level - 1);
    function(ar, mid, high, level - 1);
}

void anotherFunction( int uno, int dos, int tres, int var)
{
    if (var == 0)
        return;
    //some funky code what ever..
    anotherFunction( a, b, c, d );	
    function(ar, low, mid, level - 1);
    function(ar, mid, high, level - 1);
}

[/SOURCE]
[/source] This is sorta out there and I don't even have an idea of what I would to this for, just curious if this has a name to it so I can look into it. I read that recursion is often used in AI, is this true? If this is just another branch of recursion that could be understood too. Thanks to anyone who helps! PS: some of the code may be a little off, but it's just the idea of how the funtion inside of a function calls its parent.

Share this post


Link to post
Share on other sites
Advertisement
It is recursion and it looks a lot like a recursive divide-and-conquer approach. Maybe you like this. It is a recursive implementation of merge sort much along the lines in your example. It might help you sort this topic out.

Greetz,

Illco

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!