Paulie Posted July 12, 2008 Share Posted July 12, 2008 (edited) This function will take a pattern and generate a random string based on the pattern Pattern Syntax: c = consonant v = vowel © = letter "c" (v) = letter "v" (x,y) = x OR y Sorry, but this function can NOT generate alphanumeric strings! expandcollapse popup;NameGenerator $TestPattern = "cvxvc" MsgBox(0,"","A 5-Letter word with an 'x' in the center:"&@CRLF& GenerateName($TestPattern)) $TestPattern= "Paulie (Rocks,Sucks) - He just (c)an't help it... Here is a random (c)onsonant: 'c' and here is a random (v)owel: 'v'" MsgBox(0,"A Sentance!",GenerateName($TestPattern)) Func GenerateName($Pattern) Dim $Consonants[21] = ["B","C","D","F","G","H","J","K","L","M","N","P","Q","R","S","T","V","W","X","Y","Z"] Dim $Vowels[5] = ["A","E","I","O","U"] If StringInStr($Pattern, "(") Or StringInStr($Pattern, ")") Then If CharCount($Pattern, "(") > 9 OR CharCount($Pattern,")") > 9 then SetError(2,"Too Many Groups",-1) If CharCount($Pattern, "(") <> CharCount($Pattern,")") Then SetError(3,"Parenthesis",-1) $Groups = StringRegExp($Pattern, "\("&".*?"&"\)",3) $PlaceHolder= $Pattern For $i = 0 to Ubound($Groups)-1 $PlaceHolder = StringReplace($PlaceHolder, $Groups[$i], $i,1) Next $chars = StringSplit($PlaceHolder,"") $Limit = $chars[0] Local $Randomchr[$Limit+1] For $i = 1 to $Limit If $chars[$i] = "c" then $Randomchr[$i] = $Consonants[Random(0,20,1)] ElseIf $chars[$i] = "v" Then $Randomchr[$i] = $Vowels[Random(0,4,1)] Else $RandomChr[$i] = $chars[$i] EndIf Next local $Newstring ="" For $i = 1 to $Limit $Newstring&=$RandomChr[$i] Next Local $Replacer[Ubound($Groups)] For $i = 0 to Ubound($Groups)-1 If StringInStr($Groups[$i],",") then $Choices = StringSplit(StringTrimLeft(StringTrimRight($Groups[$i],1),1), ",") $chr = $Choices[Random(1,$Choices[0],1)] Else $Chr = StringTrimLeft(StringTrimRight($Groups[$i],1),1) EndIf $Replacer[$i] = $chr $NewString= StringReplace($Newstring, String($i), $Replacer[$i]) Next $Final = $NewString Else $Chars = StringSplit($Pattern,"") $Limit = $Chars[0] If $Limit>0 then Local $Randomchr[$Limit+1] For $i = 1 to $Limit If $Chars[$i] = "c" then $Randomchr[$i] = $Consonants[Random(0,20,1)] ElseIf $Chars[$i] = "v" Then $Randomchr[$i] = $Vowels[Random(0,4,1)] Else $RandomChr[$i] = $chars[$i] EndIf Next local $Final ="" For $i = 1 to $Limit $Final&=$RandomChr[$i] Next EndIf EndIf Return StringUpper(StringLeft($Final,1))&StringLower(StringTrimLeft($Final,1)) EndFunc Func CharCount($String, $Chr, $CaseSense=0) Local $Count = 0 $Characters = StringSplit($String, "") For $i = 1 to $Characters[0] If $CaseSense then If $Characters[$i] == $Chr then $Count+=1 Else If $Characters[$i] = $Chr then $Count+=1 EndIf Next Return $Count EndFunc Edited July 16, 2008 by Paulie Link to comment Share on other sites More sharing options...
Andreik Posted July 12, 2008 Share Posted July 12, 2008 I tested with this pattern $TestPattern = "cvvcv" and your function returned very funny name like Zuina,Xaaso,Yaili,Piequ. I like this script. Nice work. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
dreamone Posted July 12, 2008 Share Posted July 12, 2008 I testly run it, but I don't know how it can be improved! muttley Link to comment Share on other sites More sharing options...
Xand3r Posted July 12, 2008 Share Posted July 12, 2008 (edited) very cool script and it could become the BEST if you could integrate something like regular expressions in it muttley(line in stringregexp) that way u could even have apha numerical strings P.S: i got a Houdini with(cvvcvcv) Edited July 12, 2008 by TheMadman Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
Alek Posted July 12, 2008 Share Posted July 12, 2008 Love it muttley simpler charcount function Func CharCount($String, $Chr, $CaseSense=0) StringReplace($String, $Chr, "", 0, $CaseSense) Return @extended EndFunc [font="Impact"]Never fear, I is here.[/font] Link to comment Share on other sites More sharing options...
DexterMorgan Posted July 12, 2008 Share Posted July 12, 2008 Really good job paulie muttley code Link to comment Share on other sites More sharing options...
Paulie Posted July 13, 2008 Author Share Posted July 13, 2008 I'm trying to use this to come up with a cool username that isn't taken everywhere (like "Paulie" is) Can't come up with a good pattern though... "cv(r,v)(en)vc" has some good results though... Link to comment Share on other sites More sharing options...
James Posted July 13, 2008 Share Posted July 13, 2008 I'm trying to use this to come up with a cool username that isn't taken everywhere (like "Paulie" is)Can't come up with a good pattern though... "cv(r,v)(en)vc" has some good results though...I tried that to muttley Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
DexterMorgan Posted July 13, 2008 Share Posted July 13, 2008 Konstig is very unique muttley code Link to comment Share on other sites More sharing options...
James Posted July 13, 2008 Share Posted July 13, 2008 Queer to muttley Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
AlmarM Posted July 13, 2008 Share Posted July 13, 2008 Haha, I had "Woef" with: cv(e,n)c Nice muttley -AlmarM- Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
DexterMorgan Posted July 13, 2008 Share Posted July 13, 2008 Queer to muttleylol.. I still like the way it sounds... code Link to comment Share on other sites More sharing options...
Paulie Posted July 15, 2008 Author Share Posted July 15, 2008 Finally used this to come up with a name! I think it has a cool ring to it too... The name is "Revonik" nobody take it! muttley Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted July 16, 2008 Share Posted July 16, 2008 I like it. It's more or less a word generator, than a name generator muttley QevenolMavenovMorenedSovenerWurenizSarenucZovenupNorenatMovenarLovenarJirenox Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
Paulie Posted July 16, 2008 Author Share Posted July 16, 2008 I like it. It's more or less a word generator, than a name generator muttleyI realized you were right (Topic title changed) Link to comment Share on other sites More sharing options...
NELyon Posted July 16, 2008 Share Posted July 16, 2008 (edited) You've given me something fun to mess with muttley #Include <Array.au3> Global $sPattern = "cv(r,v)(en)vc", $azArray[1] = ["Names"], $blah, $blah2 For $i = 1 to 1000 $blah = GenerateName($sPattern) $blah2 = _ArraySearch($azArray, $blah) If @error Then _ArrayAdd($azArray, $blah) EndIf Next _ArrayDisplay($azArray) Gives you (Almost) 1000 different names (Almost because it removes some duplicates). EDIT: Do you mind if I convert this into a Web-Based Autoit script? Edited July 16, 2008 by KentonBomb Link to comment Share on other sites More sharing options...
James Posted July 16, 2008 Share Posted July 16, 2008 @Paulie, nice choice of name muttley Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Paulie Posted July 16, 2008 Author Share Posted July 16, 2008 EDIT: Do you mind if I convert this into a Web-Based Autoit script?Lol are you kidding? I'd be honored muttley Link to comment Share on other sites More sharing options...
NELyon Posted July 16, 2008 Share Posted July 16, 2008 (edited) I have it successfully running as a web-based script, albeit it wasn't too difficult the way you wrote it. Just had to "Echo" The names on the page with a bit of formatting. My server is being slow and nit-picky at the moment, so I'll just post a cut-down version. It goes by the "cv(r,v)(en)vc" pattern, which I loved enough to print out a page with 400 words based on that pattern and highlighted the ones I liked.expandcollapse popup##WebApp <html> <head> <title>Web-Based Name Generator</title> </head> <body> A few random names: <?au3 Global $sPattern = "cv(r,v)(en)vc", $azArray[1] = ["1000"], $blah $sHtml = "<b>{NAME}</b> " For $i = 1 to 5 Echo(StringReplace($sHtml, "{NAME}", GenerateName($sPattern))) Next Func GenerateName($Pattern) Dim $Consonants[21] = ["B","C","D","F","G","H","J","K","L","M","N","P","Q","R","S","T","V","W","X","Y","Z"] Dim $Vowels[5] = ["A","E","I","O","U"] If StringInStr($Pattern, "(") Or StringInStr($Pattern, ")") Then If CharCount($Pattern, "(") > 9 OR CharCount($Pattern,")") > 9 then SetError(2,"Too Many Groups",-1) If CharCount($Pattern, "(") <> CharCount($Pattern,")") Then SetError(3,"Parenthesis",-1) $Groups = StringRegExp($Pattern, "\("&".*?"&"\)",3) $PlaceHolder= $Pattern For $i = 0 to Ubound($Groups)-1 $PlaceHolder = StringReplace($PlaceHolder, $Groups[$i], $i,1) Next $chars = StringSplit($PlaceHolder,"") $Limit = $chars[0] Local $Randomchr[$Limit+1] For $i = 1 to $Limit If $chars[$i] = "c" then $Randomchr[$i] = $Consonants[Random(0,20,1)] ElseIf $chars[$i] = "v" Then $Randomchr[$i] = $Vowels[Random(0,4,1)] Else $RandomChr[$i] = $chars[$i] EndIf Next local $Newstring ="" For $i = 1 to $Limit $Newstring&=$RandomChr[$i] Next Local $Replacer[Ubound($Groups)] For $i = 0 to Ubound($Groups)-1 If StringInStr($Groups[$i],",") then $Choices = StringSplit(StringTrimLeft(StringTrimRight($Groups[$i],1),1), ",") $chr = $Choices[Random(1,$Choices[0],1)] Else $Chr = StringTrimLeft(StringTrimRight($Groups[$i],1),1) EndIf $Replacer[$i] = $chr $NewString= StringReplace($Newstring, String($i), $Replacer[$i]) Next $Final = $NewString Else $Chars = StringSplit($Pattern,"") $Limit = $Chars[0] If $Limit>0 then Local $Randomchr[$Limit+1] For $i = 1 to $Limit If $Chars[$i] = "c" then $Randomchr[$i] = $Consonants[Random(0,20,1)] ElseIf $Chars[$i] = "v" Then $Randomchr[$i] = $Vowels[Random(0,4,1)] Else $RandomChr[$i] = $chars[$i] EndIf Next local $Final ="" For $i = 1 to $Limit $Final&=$RandomChr[$i] Next EndIf EndIf Return StringUpper(StringLeft($Final,1))&StringLower(StringTrimLeft($Final,1)) EndFunc Func CharCount($String, $Chr, $CaseSense=0) StringReplace($String, $Chr, "", 0, $CaseSense) Return @extended EndFunc ?> Refresh for new names. </body> </html>Cut-down link: http://kentonbomb.homelinux.net/codes/web-namegen.auwDownload: http://kentonbomb.homelinux.net/codes/web-namegen.au3 Edited July 16, 2008 by KentonBomb Link to comment Share on other sites More sharing options...
Chris86 Posted February 8, 2009 Share Posted February 8, 2009 Is something wrong with the script? after i saved the file it's on 0 bytes xD my other scripts are on 30-50 bytes, I got the new 3.0.0 version, Plz help Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now