![]() |
Random name generator using Markov Chains
This script, given a database of example names, will produce new random names using what it learned by parsing the example names. Some assembly required.
<tech> The next character in the string is a random function of the previous character(s). For instance, if the script finds that the letter "f" often follows the letter "e" and that "q" almost never follows "e", it will replicate this by more often choosing "f" than "q" when faced with an "e". This is a first order chain. A second order chain will do the same, except choose the next character based on the two previous characters, such that "y" could often follow "to". </tech> Fun fact: Markov chains have been used for spam filtering. They have also been used to elude spam filters. In order to produce original names, you will need to input a fairly large database of example names. By customizing the database, you will be able to choose what kind of names you want to generate. If you want English-sounding names, you input English names, if you want alien-sounding names, you input alien names. There are some things you need to consider however. If the database is too large, the infamous loop limit will eat you if the performance demon doesn't. If it's too small, you'll often find yourself looking at unoriginal names or blatant copies of names already in the database. You'll be able to choose what order the chains should be. This also gives you some options. A first order chain will often produce gibberish, while a fourth order chain will often produce unoriginal results. I've found that a third order chain will often produce non-gibberish with only occasional copies. Fun fact: Markov chains are being used in Google's PageRank formula. These names were generated in order-3 with a database of a thousand medium length names: Quote:
Quote:
I suggest a decently large database with a fair share of longer names and second or third order chains. PHP Code:
Fun fact: Markov chains have been used to create chatbots. Some more examples using larger databases than Graal can handle follows. More than five thousand names, second order chains. More original but also some gibberish. Quote:
Quote:
|
This is actually interesting..
I might use it for naming my npcs on symp :o And Drakilor, I love it when you do something creative with your code gallery posts :D! *stories, fun facts etc.* Keep it up man |
Very nice!
++rep (when 24 hours go by) As Chompy said, you're creative :) |
++ rep love the little fun facts plus this is awesome!
|
2 Attachment(s)
I'm attaching two text files that you can use to feed the learning algorithm with. I should have done that on the OP.
Also, adding an NPC on a level which logs what everyone says might yield humorous results. |
| All times are GMT +2. The time now is 07:28 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.