Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: Spht on May 30, 2008, 04:17 PM

Title: Battle.net's word censor algorithm
Post by: Spht on May 30, 2008, 04:17 PM
This will censor a word producing the same results as battle.net's censorship

Public Function censorword(ByVal text As String) As String
    Dim m As String
    Dim ml As Integer
    Dim i As Integer
    Dim c As Integer
    Dim x As Integer
    Dim n As Integer
    Dim p As Integer
    Dim l As Integer
    Dim s As String
   
    m = "a@b#c$d%e&f!g!h!i@j#k$l%m&n!o!p!q@r#s$t%u&v!w!x!y@z#"
    ml = CInt(Len(m))
   
    For i = 1 To Len(text)
        c = Asc(Mid(text, i, 1))
        n = ((c - Asc("a")) * 2) + 1
        If n > 0 And n < ml Then '// if it's a letter from a to z
            p = 1
            Do Until x <> l
                If (n + p) > ml Then
                    n = 1
                    p = 1
                End If
                x = Asc(Mid(m, n + p, 1))
                p = p + 2
            Loop
            s = s & Chr(x)
            l = x
        Else
            s = text
            Exit For
        End If
    Next i
   
    censorword = s
End Function


Battle.net's censor works fairly simply.  there's a letter map which describes which symbol covers each word.  if the current symbol is the same as last, it uses the next unique symbol in the map

Note this is just what i reversed based on the pattern that the known 28 censored words follow.  also, in running battle.net the results are very likely hardcoded

Ex: censorword("skywing") = "$%@!@!@"
Title: Re: Battle.net's word censor algorithm
Post by: Barabajagal on May 30, 2008, 05:02 PM
Could'a just added that to this (http://forum.valhallalegends.com/index.php?topic=17141.0) topic...