The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.2 (Linux)
File Line Function
/showthread.php 906 errorHandler->error




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stack overflow in Colobot
#1
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:

Code:
public void object::smartGrab(point p)
{
    goto(p);
    grab();
}
Then do stack of overloading functions.
Code:
public void object::smartGrab(object o)
{
    smartGrab(o.position);
}
public void object::smartGrab(int cat)
{
    smartGrab(radar(cat));
}
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?  Confused


Messages In This Thread
Stack overflow in Colobot - by Smok - 12-09-2016, 09:16 PM
RE: Stack overflow in Colobot - by krzys_h - 12-09-2016, 11:40 PM
RE: Stack overflow in Colobot - by Smok - 12-10-2016, 10:59 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)