Cough
Of course he can't, any more than a human pilot can always pick the best option, and that's why there will be accidents.
The question is merely of whether there will be less accidents than if there is a human pilot.
Of course, one of the nice things about computers is that they only tend to make the same mistake once and then the software is changed so they don't make it again.