Apocalypse level

Hi everyone, I am interested in everyones ideas for a NO FLAG apocalypse run. I have reached a max of 53.4 seconds (died do to small search space for safe area). Basically my algorithm searches a gridspace around my hero, and moves to the closest “safe” area (area is considered safe if there is no cannonball hitting there soon or out of range of cannonball) My biggest problem, is when i try to increase the search area, I have a 0(N^2*M) running time, N^2 for grid size, M for # of cannonballs on field, which causes a huge increase in the program runtime if I increase the grid search space and the program goes into an “infinite loop”. Anyone have any ideas for code optimization? I am interested in hearing everyones thoughts