this post was submitted on 06 Nov 2024
39 points (100.0% liked)

Stardew Valley

477 readers
339 users here now

Welcome to Stardew Valley Lemmy and Mbin Community.

This community is for the game Stardew Valley, which is developed and published by ConcernedApe. Feel free to post Arts, Question or Your farm. Also make sure you read our rules before posting.

Rules:


Official Links

Purchase Links

Tools and Resources

founded 2 weeks ago
MODERATORS
 

Thank you @[email protected] !

top 8 comments
sorted by: hot top controversial new old
[–] [email protected] 3 points 17 hours ago* (last edited 4 hours ago) (1 children)

For fun, I just ported it to Python

source

from random import random
from math import floor

strings_start = [
  "B",
  "Br",
  "C",
  "Ch",
  "F",
  "Fr",
  "G",
  "Gr",
  "K",
  "J",
  "L",
  "M",
  "N",
  "P",
  "Pr",
  "R",
  "S",
  "Sh",
  "Sn",
  "St",
  "T",
  "Tr",
  "W",
  "Z"
]
strings_connective = [
  "c",
  "l",
  "ll",
  "m",
  "n",
  "p",
  "r",
  "s",
  "t",
  "rt",
  "tch",
  "ts"
]
strings_end = [
  "a",
  "ers",
  "ie",
  "ley",
  "o"
]
strings_vowel = [
  "a",
  "e",
  "i",
  "o",
  "u"
]
strings_expletive = [
  'bitch',
  'cock',
  'cum',
  'fuck',
  'goock',
  'gook',
  'kike',
  'nigg',
  'pusie',
  'puss',
  'rape',
  'sex',
  'shit',
  'taboo',
  'trann',
  'willy'
]
dictionary_vowel_1 = {
  "a": [
    "bell",
    "bella",
    "bo",
    "boo",
    "nie",
    "s"
  ],
  "e": [
    "",
    "ll",
    "llo",
    "o"
  ],
  "i": [
    "a",
    "bo",
    "ba",
    "ca",
    "ck",
    "co",
    "e",
    "la",
    "lo",
    "mi"
    "na",
    "no",
    "ni",
    "o",
    "que",
    "ta",
    "to",
    "zor",
  ],
  "o": [
    "da",
    "dy",
    "la",
    "lo",
    "mo",
    "nie",
    "ny",
    "o",
    "ra",
    "s",
    "ver",
    "ze"
  ],
  "u": [
    "",
    "mo",
    "rt",
    "s"
  ]
}
dictionary_vowel_2 = {
  "a": [
    "-bell",
    "bo",
    "boo",
    "ck",
    "ishe",
    "lbert",
    "nny",
    "rk",
    "sh",
    "sko",
    "sper",
    "trina"
  ],
  "e": [
    "cardo",
    "ffe",
    "lla",
    "llo",
    "ppa",
    "ppo",
    "rnard",
    "tch",
    "x"
  ],
  "i": [
    "ana",
    "card",
    "cky",
    "lbert",
    "lbo",
    "llard",
    "lly",
    "msy",
    "nana",
    "nano",
    "ne",
    "nnie",
    "nono",
    "nsy",
    "rda",
    "rdo",
    "sh",
    "skers",
  ],
  "o": [
    "-mo",
    "cco",
    "do",
    "la",
    "llo",
    "ma",
    "na",
    "nie",
    "ng",
    "ngus",
    "ny",
    "ra",
    "ver",
    "z",
    "ze",
    "zzy"
  ],
  "u": [
    "bba",
    "bbie",
    "cky",
    "ffy",
    "mby",
    "mbo",
    "mbus",
    "ngus",
    "rt",
    "ssie",
    "s"
  ]
}

def random_num(num_1, num_2 = None):
  return floor(random() * num_1) if num_2 == None else floor(random() * (num_2 - num_1)) + num_1

def random_name():
  num = random_num(3, 6)

  # Get start of string
  output_name = strings_start[random_num(len(strings_start) - 1)]
  
  # Add some chars from array 2 or array 3
  for index in range(num):
    if index % 2 == 0:
      output_name += strings_vowel[random_num(len(strings_vowel))]
    else:
      output_name += strings_connective[random_num(len(strings_connective))]

    # Stop if greater than the number
    if len(output_name) >= num:
      break
  
  last_letter = output_name[-1]

  # if last letter is not a vowel and 50% chance, add some letters
  if random() < 0.5 and (last_letter not in strings_vowel):
    output_name += strings_end[random_num(len(strings_end))]

  # otherwise if the last letter is a vowel
  elif last_letter in strings_vowel:
    # if 80 percent chance
    if random() < 0.8:
      last_letter = output_name[-1]

      # if it's short add something from voweldict2
      if len(output_name) <= 3:
        value_max = len(dictionary_vowel_2[last_letter]) - 1
        suffix = dictionary_vowel_2[last_letter][random_num(value_max)]
      # if it's long add something from voweldict1
      else:
        value_max = len(dictionary_vowel_1[last_letter]) - 1
        suffix = dictionary_vowel_1[last_letter][random_num(value_max)]

      output_name += suffix
  # otherwise add a vowel
  else:
    output_name += strings_vowel[random_num(len(strings_vowel))]

  # from end of the output_name, every character
  inserted = 0
  for index in reversed(range(1, len(output_name))):
    index -= inserted
    
    # if the target letter and the letter two indices back are both vowels
    if output_name[index] in strings_vowel and output_name[index - 2] in strings_vowel:
      # find the letter in between and add a letter to it
      # so "noco" turns into "nocko" etc
      char_target = output_name[index - 1]
      match char_target:
        case 'c' | 'r':
          output_name = output_name[0:index] + 'k' + output_name[index]
          inserted += 1
        case 'l':
          output_name = output_name[0:index] + 'n' + output_name[index]
          inserted += 1

  # small percent chance of doubling the string if its shourt. a la ka-ka
  if len(output_name) <= 3 and random() < 0.1:
    output_name += output_name if random() < 0.5 else '-' + output_name

  # maybe add an m, p, or b, if there's an e at the end
  if len(output_name) <= 2 and output_name[-1] == 'e':
    output_name += 'm' if random() < 0.3 else 'p' if random() < 0.5 else 'b'
  
  # if generated name contains an expletive, try again
  for expletive in strings_expletive:
    if expletive in output_name.lower():
      output_name = random_name()
      break

  return output_name
  
if __name__ == '__main__':
  print(random_name())

[–] [email protected] 2 points 12 hours ago* (last edited 12 hours ago) (1 children)

Cool, I am gonna put in on my Codeberg. It's now our code. XD

[–] [email protected] 1 points 12 hours ago

Feel free. I claim no ownership

[–] [email protected] 10 points 1 day ago* (last edited 17 hours ago)

Interestingly, it replaces any result containing an expletive with either "Bobo" or "Wumbus"

source

const startStrings = [
  "B",
  "Br",
  "J",
  "F",
  "S",
  "M",
  "C",
  "Ch",
  "L",
  "P",
  "K",
  "W",
  "G",
  "Z",
  "Tr",
  "T",
  "Gr",
  "Fr",
  "Pr",
  "N",
  "Sn",
  "R",
  "Sh",
  "St"
]
const connectiveStrings = [
  "ll",
  "tch",
  "l",
  "m",
  "n",
  "p",
  "r",
  "s",
  "t",
  "c",
  "rt",
  "ts"
]

const vowelStrings = [
  "a",
  "e",
  "i",
  "o",
  "u"
]

const endStrings = [
  "ie",
  "o",
  "a",
  "ers",
  "ley"
]
const vowelDictionary1 = {
  a: [
    "nie",
    "bell",
    "bo",
    "boo",
    "bella",
    "s"
  ],
  e: [
    "ll",
    "llo",
    "",
    "o"
  ],
  i: [
    "ck",
    "e",
    "bo",
    "ba",
    "lo",
    "la",
    "to",
    "ta",
    "no",
    "na",
    "ni",
    "a",
    "o",
    "zor",
    "que",
    "ca",
    "co",
    "mi"
  ],
  o: [
    "nie",
    "ze",
    "dy",
    "da",
    "o",
    "ver",
    "la",
    "lo",
    "s",
    "ny",
    "mo",
    "ra"
  ],
  u: [
    "rt",
    "mo",
    "",
    "s"
  ]
}

const vowelDictionary2 = {
  a: [
    "nny",
    "sper",
    "trina",
    "bo",
    "-bell",
    "boo",
    "lbert",
    "sko",
    "sh",
    "ck",
    "ishe",
    "rk"
  ],
  e: [
    "lla",
    "llo",
    "rnard",
    "cardo",
    "ffe",
    "ppo",
    "ppa",
    "tch",
    "x"
  ],
  i: [
    "llard",
    "lly",
    "lbo",
    "cky",
    "card",
    "ne",
    "nnie",
    "lbert",
    "nono",
    "nano",
    "nana",
    "ana",
    "nsy",
    "msy",
    "skers",
    "rdo",
    "rda",
    "sh"
  ],
  o: [
    "nie",
    "zzy",
    "do",
    "na",
    "la",
    "la",
    "ver",
    "ng",
    "ngus",
    "ny",
    "-mo",
    "llo",
    "ze",
    "ra",
    "ma",
    "cco",
    "z"
  ],
  u: [
    "ssie",
    "bbie",
    "ffy",
    "bba",
    "rt",
    "s",
    "mby",
    "mbo",
    "mbus",
    "ngus",
    "cky"
  ]
}

const randomNumberBetween = (bottom, top) => {
  const diff = top - bottom
  const rando = Math.floor(Math.random() * (diff))
  return rando + bottom
}

const randomNumberNext = (num) => randomNumberBetween(0, num)

const randoNext = (num1, num2) => {
  if (num2 === undefined) return randomNumberNext(num1)
  else return randomNumberBetween(num1, num2)
}


function namer(){
  let source = ""
  let str1 = ""
  const num = randoNext(3, 6)

  // Get start of string
  source = str1 + startStrings[randoNext(startStrings.length - 1)]

  // Add some chars from array 2 or array 3
  for (let index = 1; index < num - 1; index++) {
    source = index % 2 != 0 ? 
      source + vowelStrings[randoNext(vowelStrings.length)] : 
      source + connectiveStrings[randoNext(connectiveStrings.length)]

    // Stop if greater than the number
    if (source.length >= num) break;
  }

  let char = ''
  let currentLastLetter = source[source.length - 1]

  // if last letter is not a vowel and 50% chance, add some letters
  if (Math.random() < 0.5 && !(vowelStrings.includes(currentLastLetter))) {
    source += endStrings[randoNext(endStrings.length)]
  }

  // otherwise if the last letter is a vowel
  else if (vowelStrings.includes(currentLastLetter)) {
    // if 80 percent chance
    if (Math.random() < 0.8) {
      let newCurrentLastLetter = source[source.length - 1]
      char = newCurrentLastLetter

      // if its short add something from voweldict2
      if (source.length <= 3) {

        const maxValue = vowelDictionary2[char].length - 1
        const index2 = randoNext(maxValue)
        const str3 = vowelDictionary2[newCurrentLastLetter][index2]

        source = source + str3
      }
      // if its long add something from voweldict1
      else {
        const maxValue = vowelDictionary1[char].length - 1
        const index2 = randoNext(maxValue)
        const str3 = vowelDictionary1[newCurrentLastLetter][index2]

        source = source + str3
      }
    }
  }
  // otherwise add a vowel
  else {
    source += vowelStrings[randoNext(vowelStrings.length)]
  }

  // from end of the source, every character
  for (let index = source.length - 1; index > 2; index--) {

    // get the character
    char = source[index];
    
    // if its a vowel
    if (vowelStrings.includes(char)) {

      // get the two to last letter
      char = source[index - 2]
      
      // if its also a vowel
      if (vowelStrings.includes(char)) {
        
        // find the letter in between and add a letter to it

        // so "noco" turns into "nocko" etc

        char = source[index - 1]
        switch (char) {
          case 'c':
            source = source.substring(0, index) + 'k' + source.substring(index);
            --index;
            continue;
          case 'l':
            source = source.substring(0, index) + 'n' + source.substring(index);
            --index;
            continue;
          case 'r':
            source = source.substring(0, index) + 'k' + source.substring(index);
            --index;
            continue;
          default:
            continue;
        }
      }
    }
  }

  // small percent chance of doubling the string if its shourt. a la ka-ka
  if (source.length <= 3 && Math.random() < 0.1) {
    source = Math.random() < 0.5 ? source + source : source + '-' + source;
  }

  // maybe add an m, p, or b, if there's an e at the end
  if (source.length <= 2 && source[source.length - 1] === 'e') {
    source+= Math.random() < 0.3 ? 'm' : ( Math.random() < 0.5 ? 'p' : 'b')
  }

  // blacklist words
  [
    'sex',
    'taboo',
    'fuck',
    'rape',
    'cock',
    'willy',
    'cum',
    'goock',
    'trann',
    'gook',
    'bitch',
    'shit',
    'pusie',
    'kike',
    'nigg',
    'puss'
  ].forEach(expletive => {
    if (source.includes(expletive)) {
      source = Math.random() > 0.5 ? 'Bobo' : 'Wumbus'
    }
  })

  return source
}

[–] [email protected] 2 points 1 day ago

Oh man I know some people who are going to be very pleased about this.

[–] [email protected] 4 points 1 day ago (1 children)

I am gonna put this to Sidebar.

[–] [email protected] 4 points 1 day ago (1 children)

I suggest to also add this link for some fan-made fonts to the tools in the sidebar

https://fontswan.com/stardew-valley-font/

[–] [email protected] 4 points 1 day ago

LMAO, I was also thinking that. Even downloaded every SDV Font I can find.