Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Is markov currently broken?

I wanted to install markov but it seems like it doesnt recognize namesets at all. The help is not working either (I did check what the help output would be on git, but it wasn't too useful for fixing the issue)
What name generators are you using, guys? I have list of about 100 names I want to use as a base that markov would have been perfect for. Is there a viable replacement?
I use Markov.  If you can't get the handout thing working you could replace the script's set in the script itself.
1561231667
Kraynic
Pro
Sheet Author
It does take some setup time, but I looked up some name lists and made rollable tables, and then made a macro that spits out a bunch of names from rolls on the tables.
Mark B.: I have separate male and female names but I think I'll just rewrite the script to have 2 lists and when I use the command it generates 2 names, 1 from each. I just hoped there was like a fix or something for it. Kraynic: Thing is I put all the deities name on the lists and I don't neccessarily want NPCs with a god's name, but obviously I want the gods' names to have influence in naming. So I don't neccessarily want the names in the list to be used, I just want names like them.
1561238601

Edited 1561322437
Alright guys, I don't know any javascript, but I can read code so I spaghetti hacked together a version that only uses the !markov command and upon using the command generates both a male and a female name, here's the code: var markov = { defaultNamesMale: [ "Your","Male","Names","Here" ], defaultNamesFemale: [ "Your","Female","Names","Here" ], chain_cache: {}, namesets: {}, &nbsp; &nbsp; /** * Helper function to transform a string into an array with a given separator * * @param fullString - the string to convert * @param separator - what separates each word or element (e.g. "," to use the comma as a deliminator) * @return {Array} */ listToArray: function(fullString, separator) { 'use strict'; var fullArray = []; if (fullString !== undefined) { if (fullString.indexOf(separator) === -1) { fullArray.push(fullString); } else { fullArray = fullString.split(separator); } } return fullArray; }, /** * Called from the page ready event */ init: function() { 'use strict'; // Display banner and log activity to the API console log('Markov default namesets loaded.'); markov.namesets = { &nbsp; &nbsp; female: markov.defaultNamesFemale, &nbsp; &nbsp; default: markov.defaultNamesMale}; on("chat:message", markov.handleChatMessage); }, /** * Look to see if the chat message is a markov request, and if so generate a new name * * @param msg */ handleChatMessage: function(msg) { 'use strict'; // This an api directive? if (msg.type === "api") { // convert each word to an element into the words array. var words = markov.listToArray(msg.content, " "); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //var playerName = msg. // Is this the !markov request? if (words[0] === '!markov') { &nbsp; &nbsp; var output = ''; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; var target = playerIsGM(msg.playerid)? 'gm' : '"' + msg.who + '"'; &nbsp; &nbsp; output += '/w "' + target + '" '; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; var listToUse = ["default"]; &nbsp; &nbsp; var names = listToUse.map(function(list) { &nbsp; &nbsp; &nbsp; &nbsp; return markov.generateName(list).replace(/\s/g, ''); &nbsp; &nbsp; }).join(' '); &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; listToUse = ["female"]; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; var names2 = listToUse.map(function(list) { &nbsp; &nbsp; &nbsp; &nbsp; return markov.generateName(list).replace(/\s/g, ''); &nbsp; &nbsp; }).join(' '); &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; sendChat("", output + " male: " + names + " female: " + names2); } } }, &nbsp; &nbsp;&nbsp; /** * Create a new name using Markov's logic * * @param languageName - will either be 'default', or the name of the handout that contains the nameset * @return string - the new name, or a message indicating failure. */ generateName: function(languageName) { 'use strict'; if (!markov.namesets[languageName]) { return 'Unknown Language (name-set) or handout notes are not valid: ' + languageName; } // Use markov's logic to generate a name using the names in languageName as a seed var chain = markov.markov_chain(languageName); if (chain) { return markov.markov_name(chain); } return ''; }, /** * <a href="https://en.wikipedia.org/wiki/Markov_chain" rel="nofollow">https://en.wikipedia.org/wiki/Markov_chain</a> * * @param type * @return {*} */ markov_chain: function(type) { 'use strict'; var chain = markov.chain_cache[type]; if (chain) { return chain; } else { var list = markov.namesets[type]; if (list) { chain = markov.construct_chain(list); if (chain) { markov.chain_cache[type] = chain; return chain; } } } return false; }, /** * <a href="https://en.wikipedia.org/wiki/Markov_chain" rel="nofollow">https://en.wikipedia.org/wiki/Markov_chain</a> * * @param list * @return {*} */ construct_chain: function(list) { 'use strict'; var chain = {}; for (var i = 0; i &lt; list.length; i++) { var names = list[i].split(/\s+/); chain = markov.incr_chain(chain, 'parts', names.length); for (var j = 0; j &lt; names.length; j++) { var name = names[j]; chain= markov.incr_chain(chain, 'name_len', name.length); var c = name.substr(0, 1); chain = markov.incr_chain(chain, 'initial', c); var string = name.substr(1); var last_c = c; while (string.length &gt; 0) { c = string.substr(0, 1); chain = markov.incr_chain(chain, last_c, c); string = string.substr(1); last_c = c; } } } return markov.scale_chain(chain); }, /** * <a href="https://en.wikipedia.org/wiki/Markov_chain" rel="nofollow">https://en.wikipedia.org/wiki/Markov_chain</a> * * @param chain * @param key * @param token * @return {*} */ incr_chain: function(chain, key, token) &nbsp; { &nbsp; 'use strict'; if (chain[key]) { if (chain[key][token]) { chain[key][token]++; } else { chain[key][token] = 1; } } else { chain[key]= {}; chain[key][token] = 1; } return chain; }, /** * <a href="https://en.wikipedia.org/wiki/Markov_chain" rel="nofollow">https://en.wikipedia.org/wiki/Markov_chain</a> * * @param chain * @return {*} */ scale_chain: function(chain) { 'use strict'; var table_len = {}; for (var key in chain) { table_len[key] = 0; for (var token in chain[key]) { var count= chain[key][token]; var weighted = Math.floor(Math.pow(count, 1.3)); chain[key][token] = weighted; table_len[key] += weighted; } } chain.table_len = table_len; return chain; }, /** * <a href="https://en.wikipedia.org/wiki/Markov_chain" rel="nofollow">https://en.wikipedia.org/wiki/Markov_chain</a> * * @param chain * @return {string} */ markov_name: function(chain) { 'use strict'; var parts = markov.select_link(chain, 'parts'); var names = []; for (var i = 0; i &lt; parts; i++) { var name_len = markov.select_link(chain, 'name_len'); var c= markov.select_link(chain, 'initial'); var name = c; var last_c= c; while (name.length &lt; name_len) { c = markov.select_link(chain, last_c); name += c; last_c = c; } names.push(name); } return names.join(' '); }, /** * <a href="https://en.wikipedia.org/wiki/Markov_chain" rel="nofollow">https://en.wikipedia.org/wiki/Markov_chain</a> * * @param chain * @param key * @return {*} */ select_link: function(chain, key) { 'use strict'; var len = chain.table_len[key]; var idx = Math.floor(Math.random() * len); var t = 0; for (var token in chain[key]) { t += chain[key][token]; if (idx &lt; t) { return token; } } return '-'; } }; /** &nbsp;* Fire off init when the page loads. &nbsp;*/ on("ready", function() { 'use strict'; markov.init(); });
1561238679

Edited 1561239251
Of course all credit goes to the original creator, I just copy pasted stuff around to get what I need Edit: it only sends to gm cause that's how I want to use it, but you can change around the output in handleChatMessage if you want it to send somehow differently Edit2: Thread can be closed
1561301096
The Aaron
Roll20 Production Team
API Scripter
You should edit that post with the code, select all the code, then hit the pencil in the top left corner and choose the Code format.&nbsp; That will make it easier for people to read and copy it.