Code archives/Algorithms/Elite Planet Name Generator
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
This small code creates random but predictable planet names using the algorithm from the game "Elite" from 1984 (as an example, the start planet "Lave" is Nr. 7!). Here the first 20 planet names from Elite (Galaxy #1) using its seed (use elite$ variable = False to create completely different names): Tibedied Qube Leleer Biarge Xequerin Tiraor Rabedira Lave Zaatxe Diusreza Teaatis Riinus Esbiza Ontimaxe Cebetela Ceedra Rizala Atriso Teanrebi Azaqu Retila For further investigation I suggest the Oolite Planet List | |||||
AppTitle "Elite Planet Name Generator" Global seed%[2],elite$=True Global syllables$="..lexegezacebisousesarmaindirea.eratenberalavetiedorquanteisrion" If (elite) Then seed[0]=$5A4A seed[1]=$0248 seed[2]=$B753 Else seed[0]=Rand($ffff) seed[1]=Rand($ffff) seed[2]=Rand($ffff) EndIf For i=0 To 20 Local output$=CreateName() If output="Lave" Or output="Zaonce" Or output="Isinor" Then Color 0,255,0 Print output+" ["+i+"]" Else Color 255,255,255 Print output EndIf Next WaitKey End Function Tweakseed() Local temp%=(seed[0]+seed[1]+seed[2]) Mod $10000 seed[0]=seed[1] seed[1]=seed[2] seed[2]=temp End Function Function CreateName$() Local longnameflag=seed[0] And $40 Local planetname$="" Local c%,n%,d% For n=0 To 3 d=((seed[2] Shr 8) And $1f) Shl 1 Tweakseed() If n<3 Or longnameflag Then planetname=planetname+Mid(syllables,1+d,2) planetname=Replace(planetname,".","") EndIf Next planetname=Upper(Mid(planetname,1,1))+Mid(planetname,2,Len(planetname)-1) Return planetname End Function |
Comments
| ||
God that is exciting. I never knew they did it that way. I added a cursory SeedRnd MilliSecs() to it (just to see what would happen). |
| ||
Lave is in the right place seeing as the planet list goes from 0.. so position 8 is actually 7 :) |
| ||
Just to entertain the audience, here is a complete Planet generator using the Elite algorithm, including - original Elite planet names - galaxy map image - position in XYZ space - government type - economy - tech level - population - inhabits description - planet radius - productivity - and the local stock market Have fun to play around with it. The only thing I failed is the famous "goatsoup" description of the local special feature of the planet. This is far too complex to me. But for the moment have fun to play around with: Update 1. Now you can switch very easy through all galaxies/planets using the arrow keys. Update 2. Fixed a bug and added market quantities. Changing market prices can be achieved to call fluct=CRAND() If anybody feels like adding the goatsoup to it, here is my data field and a link to a python version of the Elite source: |
| ||
Ooh, and all done in tiny-ickle code. |
| ||
I'm gonna take a guess that EdZup has already done all the above ;) Nice ot see the actual algrithms and precisely how they are used. It can be really useful in working on ones' own generators |
| ||
> I'm gonna take a guess that EdZup has already done all the above ;) I think EdZup must be very very old to know what Elite is and remember Lave's exact position. How's going being a retiree? ;-) Did you burn out the Trumbles near a sun or lost your ship and used your escape capsule? I'm still stuck at the goat soup. Any ideas how to convert this to blitzbasic (I'm not good in Python): The result for Lave (1,7) should be Lave is most famous for its vast rain forests and the Laveian tree grub. and for Reorte(1,39) This planet is mildly fabled for its inhabitants' eccentric love for tourists but plagued by deadly earthquakes. I still bow to the genius of David Braben and Ian Bell and will lighten a virtual candle in my retro shrine now. |
| ||
I'm working through it, I don't know python, but the code there seems pretty straightforward. It's taking me a while getting the data parsed correctly, with recoginising the hex tokens compared to the standard text, but the sorting function seems to be okay so far. |
| ||
Const HEX_VALUE$="0123456789ABCDEF" Type Self Field num = -1 ;Planetary number Field x = 0 Field y = 0 Field economy = 0 Field govtype = 0 Field techlev = 0 Field population = 0 Field productivity = 0 Field radius = 0 ;Not used by game at all Field name$ Field goatsoupseed1[0] Field goatsoupseed2[0] Field goatsoupseed3[0] Field goatsoupseed4[0] Field gs%;A goat soup number End Type Function Generate_Random(Instance.Self) x = ((Instance\gs Shr 24 And 255) Shr 1) And 255 a = x + (Instance\gs Shr 8 And 255) If ((Instance\gs Shr 24 And 255) > 127) Then a = a + 1 Instance\gs = Instance\gs + (a Shr 24 And 255);And 255 Instance\gs = Instance\gs + x Shr 8 And 255 a = a Shl 8; a = any carry Left from above x = Instance\gs Shr 16 And 255 a = (a + x + Instance\gs And 255) And 255 Instance\gs = a Shr 16 And 255 Instance\gs = Instance\gs+x And 255 Return a End Function Function ConvertHex%(HexString$) HexString=Right(HexString,Len(HexString)-1) Local IterDigit%=1 Local nReturn%=0 Local Digit% For IterDigit=1 To Len(HexString) Digit=GetHexDigit(Mid(HexString,IterDigit,1),Len(HexString)-(IterDigit-1)) nReturn=nReturn+Digit Next Return nReturn End Function Function GetHexDigit%(DigitString$,Pos%) Local IterChar% For IterChar= 0 To 15 If (Mid(HEX_VALUE,IterChar+1,1)=Upper(Left(DigitString,1))) Then Return IterChar Shl 4*(Pos-1) Next ;Fail? Return 0 End Function |
| ||
Malice, is it complete? How do you parse the data fields? |
| ||
No,. it's not complete yet. I'm kinda hitting a brick wall, but thought I'd post what I'd gotten so far. Which is the random generator as per python, and a converter to convert the hex strings of "\xA9" etc. to more useable decimal equivalents. The idea being, that ultimately, I intend to not have to read strings to identify the tokens. These 'tokens' allow for related words to be 'remembered' and re-used, for example, if the planet is 'Lave' then the token can be used as the adjective 'Lavian', or, referring to other references to allow for phrases as in the example of "/x94 forests" where, as you see along from "/x94" that the options for text here are types of forest such as 'tropical', 'dense' etc. The format of reading the strings then the data seems a little unnecessary with modern computers, so ideally, the hex token strings might be best replaced with pure byte values, though the text lists are good enough as Data. It's taking me some time to correct it all but should get back to you soon. I can't yet find why the values start at 131. Presumably the previous values must be used for somerthing, since it would seem wasteful (and wasted space was certainly not on the Elite agenda!) the values after A4 are used for other text fields, some of which are evident in the earlier code (i.e. political data or such) but otherwise I'm just not sure how to deal with the values reproduced. My headache really comes in with the memory management of large integers. The Python function and the original versions of course did not use 32-bit bytes, so there was a splitting of values into separate 8-Bit bytes. Instead, I substituted gs[4] for a single 32-bit Integer and used Bit-shifting to separate the individual bytes. In the same way, goatsoupseed is another array of 4 8-bit values, but I have split this into separate ints, but not a single 32-bit one just in case as I'm not yet sure where that comes into play, or 'how' its used as a seed value. |
Code Archives Forum