Author Topic: Randomly created planet (or place) names  (Read 3708 times)

MrTAToad

  • Guest
If you need a routine to create randomly generated planet names or even place names, then this routine is for you!

Code: (glbasic) [Select]
WHILE TRUE
SEEDRND GETTIMERALL()
DEBUG createName$()+"\n"
SLEEP 1
WEND

END

FUNCTION createName$:
LOCAL name1$[]; DIMDATA name1$[],"Al","Bes","Both","Cal","Cer","Ch","Cor","Dan","Day","Ea","En","Enc","Er","Eur","Gam","Gan","Io","Jup","Kash","Ma","Mand","Mer","Mo","Na","Nept","Plu","Qua","Qo","Re","Rh","Ro","Rom","Ry","Sat","Sern","Sull","Tant","Te","Tran","Umb","Ur","Tund","Varl","Ven","Xi","Ya"
LOCAL name2$[]; DIMDATA name2$[],"a","an","ar","boo","brill","brin","do","ea","ee","el","ela","es","go","id","is","li","nos","on","or","ou","pi","ri","rr","rs","si","ti","to","ul","us","urn","ust","yme"
LOCAL name3$[]; DIMDATA name3$[],"an","aan","aari","bah","cant","cury","dal","de","dor","dra","dus","el","ine","ion","ious","iter","lag","lia","lore","loth","mir","mus","ndi","oar","on","opa","pin","rth","sha","sto","une","us","vin","wui","yyyk"
LOCAL temp$

IF RND(100)>=50
temp$=ProcessVowel$(name1$[RND(BOUNDS(name1$[],0)-1)],name2$[RND(BOUNDS(name2$[],0)-1)])
IF RND(100)>=74
temp$=ProcessVowel$(temp$,name3$[RND(BOUNDS(name3$[],0)-1)])
ENDIF
ELSE
temp$=ProcessVowel$(name1$[RND(BOUNDS(name1$[],0)-1)],name3$[RND(BOUNDS(name3$[],0)-1)])
ENDIF

RETURN temp$
ENDFUNCTION

FUNCTION ProcessVowel$:name1$,name2$
LOCAL one1$,one2$

one1$=LCASE$(RIGHT$(name1$,1))
one2$=LCASE$(LEFT$(name2$,1))

IF (one1$="a" OR one1$="e" OR one1$="i" OR one1$="o" OR one1$="u") AND (one2$="a" OR one2$="e" OR one2$="i" OR one2$="o" OR one2$="u")
LOCAL r%

r%=RND(100)
IF r%<5
RETURN name1$+"'"+name2$
ELSEIF r%<10
RETURN name1$+"-"+name2$
ENDIF
ENDIF

RETURN name1$+name2$
ENDFUNCTION

Offline Wampus

  • Prof. Inline
  • *****
  • Posts: 1004
    • View Profile
Re: Randomly created planet (or place) names
« Reply #1 on: 2012-Mar-08 »
Oh, awesome. Everyone needs a random name generator in their lives (if not their games) =D

MrTAToad

  • Guest
Re: Randomly created planet (or place) names
« Reply #2 on: 2012-Mar-08 »
Certainly do!

A database for names can be download from http://www.opensourcecf.com/1/2009/05/10000-Random-Names-Database.cfm
« Last Edit: 2012-Mar-08 by MrTAToad »

Offline fuzzy70

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 828
  • Look left, Look right, LOOK OUT!!
    • View Profile
Re: Randomly created planet (or place) names
« Reply #3 on: 2012-Mar-08 »
Think I have one from a "Game Programming Gems" book, based on the Elite one if I remember right  =D

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4310
    • View Profile
    • Portfolio
Re: Randomly created planet (or place) names
« Reply #4 on: 2012-Mar-08 »
love for all random generators! :-*

Offline fuzzy70

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 828
  • Look left, Look right, LOOK OUT!!
    • View Profile
Re: Randomly created planet (or place) names
« Reply #5 on: 2012-Mar-08 »
I do as well. The article in the book I mentioned was fascinating from the point of view on how they managed to create a near endless list of names on a machine that had 16kb of ram at the time & still have memory left for the game itself  =D

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4158
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Randomly created planet (or place) names
« Reply #6 on: 2012-Mar-08 »
Is that based on the routine that Braben and Bell used for Elite? I read a piece on that years ago - apparently it was a really small piece of code and generated an infinite variety of names (including some naughty ones). Elite does still contain some those, but the bigger swears were altered or  pushed into the deepest darkest areas of the universes that nobody could reach in a lifetime.

Anyway, nice one :)
I came. I saw. I played.

MrTAToad

  • Guest
Re: Randomly created planet (or place) names
« Reply #7 on: 2012-Mar-09 »
Thanks!