# # Simple Toy Name Generator # # This is more or less a useless toy. # It generates random names using the transition probabilites # calculated from real world names. # # Most names generated are strange, as it doesn't know any rules # for name building. only using a simple statistical process. # # Michael Schlenker <schlenk at physnet.uni-oldenburg.de # 11/Feb/2003 # using the ne/eq operators, so 8.4 is required package require Tcl 8.4 package require Tk # list of valid characters set chars [list " " 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] # matrix used # this is created from the US Census data for female firstnames from 1990 # http://www.census.gov/genealogy/names/ # # The first line is the transition from the space character # to any other character (it does not happen, so all fields are zero. # The next 26 lines list threshold rand() must fall below to select that character. # It is calculated from the summed up character transition frequencies. # set M { {0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0} {0.423197492163 0.423438630335 0.432119604533 0.450204967446 0.468772606704 0.476730166385 0.477694719074 0.484928864239 0.49385097661 0.512900892211 0.514106583072 0.520858451893 0.578008198698 0.604051121293 0.763202314926 0.764890282132 0.766578249337 0.768507354714 0.888835302628 0.912707981673 0.944779358572 0.963588136002 0.972751386544 0.979503255365 0.980467808054 0.997347480106 1.0} {0.00611620795107 0.0948012232416 0.152905198777 0.152905198777 0.155963302752 0.544342507645 0.544342507645 0.544342507645 0.547400611621 0.65749235474 0.65749235474 0.65749235474 0.688073394495 0.688073394495 0.688073394495 0.737003058104 0.737003058104 0.737003058104 0.932721712538 0.932721712538 0.932721712538 0.954128440367 0.954128440367 0.954128440367 0.954128440367 1.0 1.0} {0.00557880055788 0.232914923291 0.232914923291 0.23709902371 0.23709902371 0.400278940028 0.400278940028 0.400278940028 0.60529986053 0.744769874477 0.744769874477 0.786610878661 0.836820083682 0.836820083682 0.836820083682 0.92189679219 0.92189679219 0.941422594142 0.970711297071 0.970711297071 0.976290097629 0.979079497908 0.979079497908 0.979079497908 0.979079497908 1.0 1.0} {0.0419235511714 0.388409371147 0.388409371147 0.388409371147 0.395807644883 0.615289765721 0.615289765721 0.621454993835 0.621454993835 0.759556103576 0.759556103576 0.759556103576 0.760789149199 0.760789149199 0.764488286067 0.844636251541 0.844636251541 0.844636251541 0.937114673243 0.944512946979 0.944512946979 0.951911220715 0.951911220715 0.958076448829 0.958076448829 1.0 1.0} {0.307715133531 0.343620178042 0.352818991098 0.360534124629 0.378338278932 0.414243323442 0.418694362018 0.425222551929 0.425519287834 0.440059347181 0.440949554896 0.444510385757 0.60296735905 0.618397626113 0.732047477745 0.747181008902 0.752818991098 0.753115727003 0.845697329377 0.883976261128 0.954599406528 0.959347181009 0.972997032641 0.975074183976 0.977744807122 0.999109792285 1.0} {0.0 0.225352112676 0.225352112676 0.225352112676 0.225352112676 0.387323943662 0.471830985915 0.471830985915 0.471830985915 0.577464788732 0.577464788732 0.577464788732 0.704225352113 0.704225352113 0.704225352113 0.711267605634 0.711267605634 0.711267605634 0.964788732394 0.964788732394 0.971830985915 0.992957746479 0.992957746479 0.992957746479 0.992957746479 1.0 1.0} {0.106936416185 0.268786127168 0.268786127168 0.268786127168 0.28323699422 0.578034682081 0.578034682081 0.589595375723 0.621387283237 0.760115606936 0.760115606936 0.760115606936 0.812138728324 0.815028901734 0.838150289017 0.864161849711 0.864161849711 0.864161849711 0.933526011561 0.933526011561 0.933526011561 0.976878612717 0.976878612717 0.994219653179 0.994219653179 1.0 1.0} {0.0979899497487 0.505025125628 0.505025125628 0.505025125628 0.505025125628 0.733668341709 0.733668341709 0.733668341709 0.733668341709 0.834170854271 0.834170854271 0.834170854271 0.853015075377 0.853015075377 0.868090452261 0.914572864322 0.914572864322 0.914572864322 0.951005025126 0.952261306533 0.957286432161 0.976130653266 0.976130653266 0.977386934673 0.977386934673 1.0 1.0} {0.0774468085106 0.211914893617 0.215744680851 0.268936170213 0.299574468085 0.461276595745 0.466808510638 0.476595744681 0.476595744681 0.476595744681 0.477446808511 0.501276595745 0.577872340426 0.593617021277 0.766808510638 0.78 0.781276595745 0.784680851064 0.813191489362 0.92085106383 0.976170212766 0.977872340426 0.988510638298 0.988510638298 0.989787234043 0.990638297872 1.0} {0.0 0.344051446945 0.344051446945 0.344051446945 0.344051446945 0.578778135048 0.578778135048 0.578778135048 0.578778135048 0.604501607717 0.604501607717 0.604501607717 0.604501607717 0.604501607717 0.604501607717 0.861736334405 0.861736334405 0.861736334405 0.861736334405 0.861736334405 0.861736334405 1.0 1.0 1.0 1.0 1.0 1.0} {0.0271604938272 0.40987654321 0.40987654321 0.40987654321 0.40987654321 0.577777777778 0.577777777778 0.577777777778 0.582716049383 0.77037037037 0.77037037037 0.78024691358 0.787654320988 0.787654320988 0.787654320988 0.898765432099 0.898765432099 0.901234567901 0.962962962963 0.962962962963 0.962962962963 0.965432098765 0.965432098765 0.965432098765 0.965432098765 1.0 1.0} {0.0735721200387 0.261858664085 0.268635043562 0.270087124879 0.293320425944 0.493707647628 0.496611810261 0.497579864472 0.498547918683 0.680542110358 0.680542110358 0.681994191675 0.805905130687 0.816553727009 0.818489835431 0.886737657309 0.888673765731 0.888673765731 0.889641819942 0.896902226525 0.900290416263 0.920619554695 0.931752178122 0.932236205227 0.932236205227 0.999515972894 1.0} {0.021935483871 0.468387096774 0.490322580645 0.491612903226 0.491612903226 0.65935483871 0.65935483871 0.66064516129 0.66064516129 0.870967741935 0.870967741935 0.870967741935 0.870967741935 0.903225806452 0.904516129032 0.952258064516 0.96 0.96 0.961290322581 0.961290322581 0.961290322581 0.967741935484 0.967741935484 0.967741935484 0.967741935484 1.0 1.0} {0.164377682403 0.364806866953 0.364806866953 0.384120171674 0.469957081545 0.657081545064 0.657510729614 0.68669527897 0.689270386266 0.802575107296 0.806008583691 0.807725321888 0.807725321888 0.808583690987 0.918454935622 0.942060085837 0.942060085837 0.942489270386 0.944206008584 0.949356223176 0.971244635193 0.974678111588 0.974678111588 0.975107296137 0.975107296137 0.997854077253 1.0} {0.0709939148073 0.0831643002028 0.106490872211 0.118661257606 0.141987829615 0.159229208925 0.163286004057 0.166328600406 0.180527383367 0.197768762677 0.197768762677 0.209939148073 0.322515212982 0.365111561866 0.59939148073 0.605476673428 0.613590263692 0.613590263692 0.831643002028 0.907707910751 0.931034482759 0.954361054767 0.967545638945 0.970588235294 0.977687626775 0.991886409736 1.0} {0.0 0.312925170068 0.312925170068 0.319727891156 0.319727891156 0.503401360544 0.503401360544 0.503401360544 0.741496598639 0.836734693878 0.836734693878 0.836734693878 0.857142857143 0.857142857143 0.857142857143 0.897959183673 0.904761904762 0.904761904762 0.979591836735 0.979591836735 0.993197278912 1.0 1.0 1.0 1.0 1.0 1.0} {0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0232558139535 0.0232558139535 0.0232558139535 0.0232558139535 0.0232558139535 0.0232558139535 0.0232558139535 0.0232558139535 0.0232558139535 0.0232558139535 0.0232558139535 0.0232558139535 1.0 1.0 1.0 1.0 1.0 1.0} {0.026770775237 0.187395426659 0.191857222532 0.205242610151 0.222532069158 0.350808700502 0.350808700502 0.380925822644 0.385387618516 0.63580591188 0.636921360848 0.639152258784 0.707752370329 0.729503625209 0.75683212493 0.834913552705 0.835471277189 0.837702175125 0.880089235917 0.889570552147 0.922476296709 0.938650306748 0.941996653653 0.941996653653 0.942554378137 1.0 1.0} {0.0765724703737 0.236098450319 0.237010027347 0.248860528715 0.248860528715 0.350045578851 0.350045578851 0.350045578851 0.606198723792 0.690063810392 0.690063810392 0.69097538742 0.700091157703 0.704649042844 0.704649042844 0.735642661805 0.740200546946 0.740200546946 0.740200546946 0.813126709207 0.939835916135 0.980856882407 0.981768459435 0.981768459435 0.981768459435 1.0 1.0} {0.0369761709121 0.294165981923 0.294165981923 0.295809367297 0.295809367297 0.446179129006 0.446179129006 0.446179129006 0.578471651602 0.695973705834 0.695973705834 0.695973705834 0.705834018077 0.705834018077 0.714050944947 0.76417419885 0.76417419885 0.76417419885 0.815940838127 0.821692686935 0.963845521775 0.97041906327 0.97041906327 0.974527526705 0.974527526705 0.997534921939 1.0} {0.0401891252955 0.0945626477541 0.111111111111 0.151300236407 0.231678486998 0.340425531915 0.347517730496 0.368794326241 0.368794326241 0.427895981087 0.427895981087 0.456264775414 0.58865248227 0.60756501182 0.721040189125 0.730496453901 0.737588652482 0.737588652482 0.855791962175 0.936170212766 0.959810874704 0.959810874704 0.964539007092 0.964539007092 0.964539007092 0.973995271868 1.0} {0.00381679389313 0.251908396947 0.251908396947 0.251908396947 0.251908396947 0.591603053435 0.591603053435 0.591603053435 0.591603053435 0.900763358779 0.900763358779 0.904580152672 0.904580152672 0.904580152672 0.904580152672 0.992366412214 0.992366412214 0.992366412214 0.996183206107 0.996183206107 0.996183206107 0.996183206107 0.996183206107 0.996183206107 0.996183206107 1.0 1.0} {0.04 0.31 0.31 0.31 0.31 0.46 0.46 0.46 0.48 0.75 0.75 0.75 0.75 0.75 0.92 0.93 0.93 0.93 0.94 0.94 0.94 0.94 0.94 0.94 0.94 1.0 1.0} {0.103448275862 0.413793103448 0.413793103448 0.413793103448 0.413793103448 0.448275862069 0.448275862069 0.448275862069 0.448275862069 0.862068965517 0.862068965517 0.862068965517 0.862068965517 0.862068965517 0.862068965517 0.896551724138 0.896551724138 0.896551724138 0.896551724138 0.896551724138 0.931034482759 0.965517241379 0.965517241379 0.965517241379 0.965517241379 1.0 1.0} {0.439592430859 0.509461426492 0.518195050946 0.534206695779 0.544395924309 0.598253275109 0.598253275109 0.598253275109 0.598253275109 0.604075691412 0.606986899563 0.606986899563 0.688500727802 0.700145560408 0.880640465793 0.908296943231 0.908296943231 0.908296943231 0.933042212518 0.966521106259 0.972343522562 0.994177583697 1.0 1.0 1.0 1.0 1.0} {0.0957446808511 0.31914893617 0.340425531915 0.340425531915 0.340425531915 0.563829787234 0.563829787234 0.563829787234 0.563829787234 0.702127659574 0.702127659574 0.702127659574 0.712765957447 0.734042553191 0.734042553191 0.840425531915 0.840425531915 0.840425531915 0.840425531915 0.840425531915 0.840425531915 0.914893617021 0.914893617021 0.914893617021 0.914893617021 0.946808510638 1.0} } # Very simple GUI # proc names_gui {} { wm title . "Random Name Generator" entry .out -textvariable ::output -font {helvetica 20 bold} button .do -command create_names -text "Create Random Name" pack .out pack .do } # Create next letter for name # proc names_next_letter {letter} { # get the character index set i [lsearch $::chars $letter] # get a random number set rand [expr {rand()}] # get the line in the matrix set line [lindex $::M $i] set result "" # find random next character set idx 0 foreach item $line { if {$rand < $item} { set result [lindex $::chars $idx] break } incr idx } return $result } # Start name creation # proc create_names {} { # select random starting character set name [lindex $::chars [expr 1+int(([llength $::chars]-1)*rand())]] # allow no single character names, always add at least one char while {[set letter [names_next_letter $name]] eq " "} { } append name $letter # add chars until we hit space while {$letter ne " "} { set letter [names_next_letter $letter] append name $letter } # move first character to uppercase set ::output [string totitle $name] } # fire up the gui names_gui
CJL - While the majority of names do appear reasonably sensible (and often suitably Tolkien-esque), there are a fair number of unpronouncables cropping up, e.g. Nandrllssherillina, Rta, Drgla, and finally the truly horrendous Vegudderruganinnnenalyncoriticon! (has anybody had worse?) (still, a good name is never more than a couple of clicks away)schlenk - Entirly correct. One could improve the system by using smarter (and larger) transition tables (based on multiple characters instead of just the last character), or by creating names via syllables instead of characters. So if something horrible crops up, it could be the name of something truly alien. ;-) - RS: In Czechia or Croatia, names like Brno and Krk are perfectly alright, as seen on maps :)JAG - In answer to CJL's question of "has anybody had worse?", here's my entry... Karyuneerocanendoverawielileicorauleyneneshadilyattocasurinaindore - of course, to get that jewel, I ran the generator proc 100,000 times in a row and kept the longest name. Actually, the name is not that bad... In fact, I predict that in the next few years, it'll rank quite high on the list of "in" names... ;^)Larry Smith In RPG's such names would be used for Magicians living in worlds* where knowing the True Name of something grants great power over the named object.*Lars H: Couldn't help adding to Larry's remark the footnote that the most common example of such a world is (unsurprisingly) a scripting language interpreter. interp hide, anyone? ;-) - To RS, the above example looks just like another Welsh train station, e.g. Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiiliogogogoch :-)Njay: I used to use the procs below to generate random names for IRC bots :). Playing with set2 and set3 you can control the "kind" of names you generate (use more sets ending in "i" and you get Italian-sounding names, introduce "w" and you start getting African-sounding names, etc). Example names: Vumvum Macrala Nubanjo Lano Tacraze Banpho Vumgue Nioban Celaze Nebu Lacrajo ...
package require Tk proc GetRandomItem {list} { lindex $list [expr { int(rand() * [llength $list]) }] } proc GetRandomName {} { set set2 {ma ne bu po ta ti nu no mo jo li ze ce la} set set3 {nio gue ban vum cra pho} switch -exact -- [GetRandomItem {type1 type2 type3 type4}] { type1 { set name [GetRandomItem $set3][GetRandomItem $set3] } type2 { set name [GetRandomItem $set2][GetRandomItem $set2][GetRandomItem $set2] } type3 { set name [GetRandomItem $set2][GetRandomItem $set3][GetRandomItem $set2] } type4 { set name [GetRandomItem $set2][GetRandomItem $set2] } } string totitle $name } if 1 { # GUI, just stolen from the script above by Michael Schlenker :) proc names_gui {} { wm title . "Random Name Generator II" entry .out -textvariable ::output -font {helvetica 20 bold} button .do -command {set ::output [GetRandomName]} -text "Create Random Name" pack .out pack .do } names_gui } if 0 { # Alternative GUI with a listbox, so you can see more names in one go. # Selecting one of the random names copies it to the clipboard proc fill_names {} { .lb delete 0 end for {set i 1} {$i<=[.lb cget -height]} {incr i} { .lb insert end "[GetRandomName]" } } proc do_select {} { set i [.lb curselection] if {$i ne ""} { set x [.lb get $i] clipboard clear clipboard append $x } } proc names_gui2 {} { wm title . "Random Name Generator II" listbox .lb -selectmode single -height 20 button .do -text "Create Random Names" -command {fill_names} pack .lb pack .do bind .lb <<ListboxSelect>> {do_select} } names_gui2 }
HJG 2009-09-20 added alternative GUI with listbox
Njay 2009-11-26: I just found this other older wiki page with a random name generator: Random name generator