This is a massive over-simplification. Imagine a human driver encounters somebody standing in the road on an otherwise empty highway.
Experience will tell him how much to slow down, whether to swerve around the obstacle, edge past slowly or stop altogether. All the time he'll be making judgements based on the appearance of the person, the surroundings, etc.
If the person seems malicious he knows just how fast to drive to intimidate them into getting out of the way, without undue risk. He doesn't want to kill anyone, even if they're trying to rob him.
Now imagine encoding all of that into an algorithm. I'm not saying it's impossible, but it's a huge challenge.
Also bear in mind that autonomous vehicles will probably err very much on the side of caution when it comes to pedestrian safety.