So I recently implemented a recursive function in my algo and found some interesting behavior. After implementing the recursive function my algo would complete its calculations with no problem, but the engine would hang on each turn even after the algo submitted it turns.
I want to emphasize that the issue was not a recursive time-out or out of memory bounds. The function completed without issue (very quickly as well) and when I did not call that function the problem went away. I can also confirm that control was given back to the engine.jar (.exe in my case, since I converted it using launch4j).
This began as expected but the engine would gradually hang more and more as each turn finished. This is why I originally believed the issue to be a recursive time-out, but this was not the case when I looked further.
I am wondering why the function would appear to have completed when it clearly has not. The only culprit I could think of was if the engine creates separate threads when running the algos, resulting in it printing my messages, when really the function hasn’t finished. However, this cannot be the case because I set it to output the results of that function, which came back as expected in the time expected and the engine still hung after getting the results.
Furthermore, when I re-wrote the function using an iterative approach, there were no problems at all.
I am wondering if other people have successfully used a recursive function in their algo, any ideas they might have for the problem (for science - since iterative works fine ), or if anyone from C1 has an explanation.