Is it possible to make a text based game and filter bad stuff?

I was thinking of a text based game where the users type in various "things." But I know it will quickly degenerate into filth. Is there any way to stop something like this?

• – MichaelHouse Jul 25 '12 at 2:51
• Challenge accepted, I can be just as filthy with words censored as without. In fact, probably more-so. – salmonmoose Jul 25 '12 at 4:25

Users determined to use inappropriate words can be very creative in getting around even quite sophisticated automatic systems. Imagine you want to block the word, "pear". Can your filter deal with deliberate misspellings like "pair"? And what about false positives, like "appear"? What if the user's real name is actually "Pearson"? But offenders start using the player's name in place of "bad words"?

There are, however, several techniques that can help. The idea is not to prevent offensive behaviour, but rather to take the fun out of it.

• Filter words that are obviously bad. So, you would filter "pear" but not "pair". You're dealing with casual offenders, you're setting the tone, but you'll still allow "pearson" to play.
• As suggested in another answer, show the original words to the person who typed them, but the clean version to others. The genius of this technique is that users may not realise that their words are being filtered, so may not think to invent workarounds.
• Automatically (and politely) remind offenders to stop. Explain why some people find their behaviour inappropriate
• If it isn't an essential aspect of the game, allow users to turn off the chat facility so they don't have to read conversations that they consider offensive
• Allow users to ignore certain players
• Allow peer review. An additional advantage is this can also discourage other "bad" behaviour such as racism or trolling which is not based on word matching. Stack exchange is a great example of how this can work in practice.
• Some games have force users to pick from stock phrases. This is generally perceived as boring, but can be appropriate in some situations.

None of these suggestions will outright prevent bad words, but they can go a long way to helping you keep your game clean.

It's effective in these kinds of systems to show the original words to the user who made the input, but the scrubbed version to everyone else.

• Don't think it would take them long to realize this though :P – Nick Jul 25 '12 at 7:54
• I'm thinking that the more profanity a user uses, the less likely that person is to notice myself. – xuincherguixe Jul 25 '12 at 19:41
• Georgek is correct. The best way to get someone to not abuse the system, is to trick them into thinking they got away with it in the first place. Even if they eventually find out they were fooled and find ways around it, it will NOT be easy for them to experiment. At the very least, you slowed them down and prevented it from being a huge problem. – Carter81 Sep 29 '13 at 3:53

One simple option is to have a text file that contains a list of all words and phrases that you want to block. Scrub the input prior accepting it by checking it against the list of words in that file.

File contains:

Apple
Pear
Banana


Then scrub the input like so (pseudocode):

if(!blockedWords.Contains(input))
// accept input and do whatever you need to
else
print 'Hey, be nice!'


If input is "Apple", the blockedWords array read in from the text file will contain it and throw up the message.

• One thing to consider is that people get creative on these environments, like type a-p-p-l-e or something – Luke B. Jul 25 '12 at 1:59
• @LukeB. Yes. That's what I thought too. Almost impossible. – johnny Jul 25 '12 at 3:00
• @johnny Games for kids usually limit what you can say to a number of phrases instead of free chat. I guess Toon Town and Wizard 101 use this method. – Luke B. Jul 25 '12 at 3:39