AI will never replace humans because it's too predictable. Combat is not chess.
Technically, AI has already replaced humans in a vast range of applications, guidance of weapons being the most obvious.
Obviously, AI will never COMPLETELY replace humans, since human decision will inevitably remain part of the loop. The "push button war" remains an inevitability on some level or another since, sooner or later, any weapon known to man can and will be mated with artificial intelligence systems capable of wielding that firepower on automatic without human guidance. Manual operation will of course remain an option, and the people who give the orders will still be humans.
When you invent a machine that is smart enough to make even command decisions, you quickly discover that the machine itself is no longer a machine, it has become--in fact--an artificial
person. When that happens, you've just replaced human decision with slightly faster human decision, and the easiest way to keep up with the artificial humans is to upgrade yourself with either cybernetics and genetic modification, or to just build a smarter artificial person to keep up with your enemy (just imagine of Geordi had ever gotten Data's brain-computer interface to work properly).