Explanation:
 
If there is not either an empty square or a flag directly behind Torque, then he cannot escape from the enemy by moving backward, so he jumps to a routine that decides whether to self-destruct or stay still and try to repair some damage.