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

Stardew Valley

563 readers
47 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 1 month ago
MODERATORS
 

Thank you @Cenotaph@mander.xyz !

you are viewing a single comment's thread
view the rest of the comments
[–] SatyrSack@feddit.org 4 points 2 weeks ago* (last edited 2 weeks 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:
      # 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[:index] + 'k' + output_name[index:]
          inserted += 1
        case 'l':
          output_name = output_name[:index] + 'n' + output_name[index:]
          inserted += 1

  # small percent chance of doubling the string if it's short, a la kaka or ka-ka
  if len(output_name) <= 3 and random() < 0.1:
    output_name += output_name if random() < 0.5 else '-' + output_name

  # if name is short and has an e at the end, add an m, p, or b
  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())

[–] sag@lemm.ee 3 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

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

[–] SatyrSack@feddit.org 1 points 2 weeks ago

Feel free. I claim no ownership