Now, I'm a friendly person and like getting to know people. I like meeting new people, but I like meeting new people with the condition that we'll meet again. It ultimately depends on whether or not I'm in a good mood. If I'm in a really good mood, I'll smile and say hello to people and ask how they're doing and be friendly and approachable. Most of the time, though, I'm in an okay mood. When I'm in an okay mood, I don't engage myself into conversations unless I need to.
The best way for me to make sure nobody talks to me while I'm out and about is to wear headphones in my ears at all times. This creates the illusion that you can't hear what people are saying to you. The other thing I do when I don't want to be bothered by people is to look down and walk fast. This creates the illusion that you've got somewhere very important to go and are busy!
Now sometimes this doesn't work for me, and I'm forced to interact with people. The headphones looking down walk fast combination is usually really good in public, but when you're with people you know or people who are just obnoxious, they just try to nudge right on through that and force you to communicate with them. Terribly bothersome if you don't want to be bothered by anyone. There are four ways I go about this: short answers, straight-forward remark, acting sick, and being weird.
Short answers are what everyone seems to do. This is what I do for people who I know and strangers. I tend to do this the most.
Straight-forward remark is simply saying you don't want to talk to them right now and would appreciate it if they leave you alone thank you very much. This is what I do for people who I know fairly well and people I'm related to.
Acting sick is easy. Just pretend you're sick. Cough, sniff your nose, rub your head, mope around. People don't want to initiate conversation with sick people who have the power to walk around in public because they don't want to get sick from you, and if you start showing signs of being sick around a stranger, then they'll likely back away. Saying that you're sick is something that's good too, because then they'll probably walk away right then and there. If they're decent, they'll wish you a speedy recovery. This is kind of tiresome and requires the most energy. I do this the least.
Being weird is something I reserve for those annoying people that insist on talking to me that I've never seen before. Most of the time it involves making some noises, using frank-observation-based statements, a strange laugh every now and then at things that aren't typically funny, making a weird face or two, and is actually not very time-consuming and a bit of fun. It turns the tables a bit, because they expect a decent conversation or you to be a little uncomfortable. Doing this makes them uncomfortable and they'll probably go away on their own. I don't do this a lot, only when I'm feeling adventurous. But I've done it enough for it to be a little noteworthy.