Hi. I was trying my new way to write programs i colobot, but it made me pretty fast face stackoverflow. I decided to write program like this:
Then do stack of overloading functions.
And then i use my smartGrab(TitaniumOre); in my collectTitanium function, and then i use my collectTitanium in smartBuild function if there is no titanium, and then i use my smartBuild function in makeBot function if there is no BotFactory, and so on.
I found this way of programming super comfy, but it made me hit stackoverflow realy fast (like on 10th nested function). Is my way of programming bad or CBot have very small stack size? How i should deal with this problem?
Code:
public void object::smartGrab(point p)
{
goto(p);
grab();
}
Code:
public void object::smartGrab(object o)
{
smartGrab(o.position);
}
public void object::smartGrab(int cat)
{
smartGrab(radar(cat));
}
I found this way of programming super comfy, but it made me hit stackoverflow realy fast (like on 10th nested function). Is my way of programming bad or CBot have very small stack size? How i should deal with this problem?