Practical tips debugging deep recursion?

前端 未结 8 1946
长情又很酷
长情又很酷 2021-02-13 06:33

I\'m working on a board game algorithm where a large tree is traversed using recursion, however, it\'s not behaving as expected. How do I handle this and what are you experience

8条回答
  •  攒了一身酷
    2021-02-13 07:20

    Maybe you could convert the recursion into an iteration with an explicit stack for the parameters. Testing is easier in this way because you can directly log values, access the stack and don't have to pass data/variables in each self-evaluation or prevent them from falling out of scope.

提交回复
热议问题