Jump to content
DasMoony

DMO - Random Name Script

Recommended Posts

Loosing some words about first:

A few weeks ago I tried to create an advanced name generator in c# and after looking through the script requests I thought I may port the basic part to RGSS3. So did I. Well, actually I had to rewrite the complete basic part since recursive programming isn't really to think about in RGSS3. And now..this is my result. Enjoy and have fun.

 

Note: This script does not name anything it simply returns a name. The naming you still have to do by yourself.

 

Features:

â— Returns a word by a V-C-V-C... or C-V-C-V... Pattern

â— Allows double vowels

â— You can set up a 'forbidden' list if you wish

â— High compatibility

â— Also random length if you wish (by a determined range)

â— Plug & Play

 

Screenshot

Uhh... it generates names, so there is no screenshot. Examples?

Here my last 5:

â— Yuinu

â— Pezey

â— Ameco

â— Anita

â— Reliha

 

How to use

You can find detailed instructions in the script. Just follow them and you'll get happy^^

You can generate a name by using DMO::STAT::NAMEGEN.generate or dmo_namegen in script calls.

And again: This script does not name your stuff. It gives you a name. If you want for example name your hero you have to do something like $game_actors[1].name = dmo_namegen.

 

Script

 

#==============================================================================
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# â–  DMO - RANDOM NAME SCRIPT
#   â— Version:  1.0
#   â— Author:   DasMoony
#   â— Date:	 January 11th, 2012
#   â— Credits:  DasMoony
#   â— LastEdit: January 11th, 2012
#
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# â–  Features (or 5 reasons why to use this one):
#   â— Returns a word by a V-C-V-C... or C-V-C-V... Pattern
#   â— Allows double vowels
#   â— You can set up a 'forbidden' list if you wish
#   â— High compatibility
#   â— Also random length if you wish (by a determined range)
#   â— Plug & Play
#
#==============================================================================
# â–  Description
#   A little Script that returns a random word.
#
#==============================================================================
# â–  Credits and Terms of use
#   â— Credits:
#	 DasMoony
#   â— This script is made for free use in commercial and non-commercial
#	 projects but credits are required
#   â— Do not post direct links to the download file, instead link the page that
#	 contains it
#   â— You're not allowed without the authors permission to distribute this
#	 script. Of course you're allowed to distribute the script within your
#	 project.
#   â— If you're allowed to distribute the script you can't require any rights
#	 about the script
#   â— If this script is used in commercial projects, I demand a free copy of
#	 it. Contact me for the details.
#
#==============================================================================
# â–  Instructions
#   â— Plug the script in
#	 Put this script to the Materials-Section.
#   â— Configurations
#	 You can configure some stuff if you scroll down to the Options (Or search
#	 for OPTIONS)
#	   â— MIN_RANGE
#		 it's the minimal range of random name length
#	   â— MAX_RANGE
#		 it's the maximal range of random name length
#	   â— ALLOW_VV
#		 allow to vowels after each other?
#	   â— FORBIDDEN_WORDS
#		 Here you can enter some unwished results of the generator
#   â— Advanced Configurations
#	 You can easily modify the table to pick literals from, but manipulating
#	 with that can end in unexcepted results. Also each addition counts as a
#	 single character.
#   â— Call Generation
#	 â— DMO::STAT::NAMEGEN.generate or namegen in script calls
#	   returns a random namestring with length from MIN_RANGE to MAX_RANGE
#	 â— DMO::STAT::NAMEGEN.generate(x) or namegen(x) in script calls
#	   returns a random namestring with length from x to MAX_RANGE
#	 â— DMO::STAT::NAMEGEN.generate(x,y) or namgen(x,y) in script calls
#	   returns a random namestring with length from x to y
#
#==============================================================================
# â–  FAQ
#   â— No questions yet
#
#==============================================================================
# â–  Support
#   â— Currently this script is supported on rpgmakervxace.net
#
#==============================================================================
# â–  Technical Aspects (this section is thought for other scripters)
#   â— Complete own module (DMO)
#   â— New methods
#	 â— Game_Interpreter:
#	   â— dmo_namegen
#
#==============================================================================
# â–  Contact Information
#   â— Email:
#	 sid.dasmoony@gmail.com
#
#==============================================================================
#==============================================================================

module DMO
#==============================================================================
# â–  OPTIONS - Here you can change some settings.
#==============================================================================
 module OPTIONS
   module NAMEGEN
  #MIN_RANGE/MAX_RANGE random length range
  MIN_RANGE   = 4
  MAX_RANGE   = 6

  #ALLOW_VV allow vowels after each other?
  ALLOW_VV  = true

  #FORBIDDEN_WORDS filter for unwished results
  FORBIDDEN_WORDS = []
   end
 end
#==============================================================================
# â–  End of OPTIONS.
#   It's recommended not to change anything behind this point. If you're still
#   do, it's your pretty own risk.
#==============================================================================
 module STAT   #static module
   module NAMEGEN
  #LITERALS the literals to pick from
  #Needs at least 26 entries!
  LITERALS  = [
		  ['A','v'],['B','c'],['C','c'],['D','c'],['E','v'],['F','c'],
		  ['G','c'],['H','c'],['I','v'],['J','c'],['K','c'],['L','c'],
		  ['M','c'],['N','c'],['O','v'],['P','c'],['Q','c'],['R','c'],
		  ['S','c'],['T','c'],['U','v'],['V','c'],['W','c'],['X','c'],
		  ['Y','c'],['Z','c']
		  #Additional entries (for special combinations, higher chance, etc.
		  #These will never be at the begin of the result. If you add a
		  #combination it won't coun't towards the length.
		  #['entry','c(onsonant)/v(owel)']
		  ]

  #------------------------------------------------------------------------
  # â— generate
  #	 returns a random namestring
  #	 (min : min of range)
  #	 (max : max of range)
  #
  #	 note: if min > max for both will be used min
  #------------------------------------------------------------------------
  def self.generate(min = OPTIONS::NAMEGEN::MIN_RANGE, max = OPTIONS::NAMEGEN::MAX_RANGE)
    max = min if min > max
    while true
	  length = min + Random.rand(max - min)
	  ret   = ""
	  dbl_v = false
	  lit = LITERALS[Random.rand(26)]
	  for i in 0..length
	    ret += lit[0]
	    if lit[1] == 'c'
		  while(lit[1] == 'c')
		    lit = LITERALS[Random.rand(LITERALS.size)]
		  end
	    else
		  if dbl_v || !OPTIONS::NAMEGEN::ALLOW_VV
		    while(lit[1] == 'v')
			  lit = LITERALS[Random.rand(LITERALS.size)]
		    end
		  else
		    lit = LITERALS[Random.rand(LITERALS.size)]
		    dbl_v = true
		  end
	    end
	  end
	  ret = ret.downcase
	  ret[0] = ret[0].upcase
	  return ret unless OPTIONS::NAMEGEN::FORBIDDEN_WORDS.include?(ret)
    end
  end
   end
 end
end
#==============================================================================
# â–  Game_Interpreter
#==============================================================================
class Game_Interpreter
 #------------------------------------------------------------------------
 # â— dmo_namegen
 #	 returns a random namestring
 #	 (min : min of range)
 #	 (max : max of range)
 #
 #	 note: if min > max for both will be used min
 #------------------------------------------------------------------------
 def dmo_namegen(min = nil,max = nil)
   return DMO::STAT::NAMEGEN.generate unless min
   return DMO::STAT::NAMEGEN.generate(min) unless max
   return DMO::STAT::NAMEGEN.generate(min,max)
 end
end

 

 

Credits & Terms of use

â— Credits: DasMoony

â— This script is made for free use in commercial and non-commercial projects but credits are required

â— Do not post direct links to the download file, instead link the page that contains it

â— You're not allowed without the authors permission to distribute this script. Of course you're allowed to distribute the script within your project.

â— If you're allowed to distribute the script you can't require any rights about the script

â— If this script is used in commercial projects, I demand a free copy of

it. Contact me for the details. For this, look at contact informations or send me a pm on the forum

 

About Support, Redistribution, etc.

This is what this thread is for :) At the moment this script is exclusive shared at rpgmakervxace.net and that's my full intention until I set up a script section on my own homepage. So, if you see it somewhereelse please inform me. Thanks in advance for this.

Share this post


Link to post
Share on other sites

No, it's not limited to one charater. But it's important to know then that the length determines the quantity of picked literals. So 'Qu' will count as one literal regarding the word length and not as two. (By a length of 5 could came out something like 'Aquion').

Hope this could help :)

 

*edit*

Oh, before I forget to mention it - 'Q' is a character at my location which stands never alone and it's always 'Qu'. If you want to have always 'Qu' and never a 'q' somewhere else you can also replace the 'Q' by 'Qu'.

*endedit*

Edited by DasMoony

Share this post


Link to post
Share on other sites

Just

So did I. Well, actually I had to rewrite the complete basic part since recursive programming isn't really to think about in RGSS3. And now..this is my result. Enjoy and have fun.

 

Just curious... why do you believe that a name generator requires the use of recursion? You can certainly use recursion in ruby, though there is no tail call optimization so you may well blow the stack if you call your function recursively too many times. I'm interested in what you meant by that statement.

Share this post


Link to post
Share on other sites

The original one I made in c# uses a recursive methods to check the rules for the literals. It works fine and in my private little helper tools I haven't to worry about performance usually so I approached the original namegen by recursive methods to have some useful excercise with recursive methods (I rarely need them... I wonder why we had to learn them back at school :huh: ) and trying to have a clean code. so I don't believe really recursion is required in a name generator it was just a place where I saw the possibility to use it.

And yep, I hit the 'stack level to deep'-error pretty fast with the same approach in this RGSS3-Script...Have still to learn some stuff about rgss3 and ruby and it may take a while since the ruby syntax looks somewhat of different then to the languages I know. Have to be careful not to confuse them - happens all the time :rolleyes:

Share this post


Link to post
Share on other sites

Ok. C# has the same "problem" though (no tail call recursion), so it's curious as to why you hit it so quickly in ruby. But yeah, recursion is rarely used in non-functional languages, and it is never actually required. There are of course problems that lend themselves to recursion like walking the nodes of a tree (i.e., directory traversal, etc.).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted