Elite Planet Name Generator

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

 

Krischan

Betreff: Elite Planet Name Generator

BeitragSo, Sep 19, 2010 20:48
Antworten mit Zitat
Benutzer-Profile anzeigen
Die Älteren unter uns erinnern sich vielleicht noch an das Spiel "Elite" aus dem Jahr 1984. Ich habe nach demselben Algorithmus einen Namensgenerator für Blitzbasic gebaut, der ALLE bekannten Planetennamen erzeugt (z.B. der Startplanet Lave auf Nr. 7).

Hier als Beispiel die ersten 20 Planeten: Tibedied Qube Leleer Biarge Xequerin Tiraor Rabedira Lave Zaatxe Diusreza Teaatis Riinus Esbiza Ontimaxe Cebetela Ceedra Rizala Atriso Teanrebi Azaqu Retila

Setzt man die Variable elite$ auf False kommen übrigens völlig andere Namen heraus.

Für weitere Nachforschungen/Vergleiche empfehle ich die Oolite Planet List

BlitzBasic: [AUSKLAPPEN]
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
 

Krischan

BeitragMo, Sep 20, 2010 20:48
Antworten mit Zitat
Benutzer-Profile anzeigen
Wo wir gerade dabei sind - ich habe gleich einen kompletten Planetengenerator draus gebaut, und zwar sollte der genau so arbeiten wie im original Elite Spiel. Alternativ kann eine eigene, komplett zufällige Galaxie generiert werden.

Dieser Generator berechnet nun

- den original Elite Planetennamen
- eine Galaxieübersicht
- die Position XYZ
- Regierungstyp
- Wirtschaftstyp
- Tech Level
- Bevölkerung
- Einwohnerbeschreibung
- Planetenradius
- Produktivität
- und den kompletten lokalen Warenmarkt

user posted image

Viel Spass beim Herumspielen.

Update. Nun kann man bequem mit den Pfeiltasten durch alle Galaxien/Planeten durchzappen.

BlitzBasic: [AUSKLAPPEN]
Const border%    = 5        ; galaxy map border
Const width% = 400 ; galaxy map width
Const height% = 400 ; galaxy map height
Const highrad% = 5 ; planet highlight radius
Local galaxy% = 1 ; set galaxy (1...8)
Local planet% = 7 ; set planet (0...255)
Global elite$ = True ; use original Elite seed or not
Global rseed% = 42 ; random seed for non-Elite galaxy

Global seed%[2],units$[2]
Global nxt%=12345
Global syllables$="..lexegezacebisousesarmaindirea.eratenberalavetiedorquanteisrion"
Global fluct%

units[0]="t":units[1]="kg":units[2]="g"

Local i%,font%
Local p.planet
Local c.commodity

Type planet

Field galaxy%
Field planet%
Field name$
Field x#,y#,z#
Field gov%
Field eco%
Field tech%
Field pop#
Field radius%
Field prod%
Field inhabit$
Field comm$[16]
Field price#[16]
Field unit%[16]

End Type

Type commodity

Field baseprice%
Field gradient%
Field basequant%
Field mask%
Field unit%
Field name$

End Type

; read commodity data
Restore commodities
For i=0 To 16

c.commodity = New commodity
Read c\baseprice,c\gradient,c\basequant,c\mask,c\unit,c\name

Next

Graphics 800,440,32,2

; initialize
Local map%=GenerateMap(galaxy)
p=CreatePlanet(galaxy,planet)
font=LoadFont("Blitz",13) : SetFont font

While Not KeyHit(1)

Cls

; store current galaxy/planet
Local oldgalaxy%=galaxy
Local oldplanet%=planet

; arrows = change galaxy/planet
galaxy=galaxy+KeyHit(200)-KeyHit(208)
planet=planet+KeyHit(205)-KeyHit(203)

; limit galaxy/planet
If galaxy<1 Then galaxy=8 Else If galaxy>8 Then galaxy=1
If planet<0 Then planet=255 Else If planet>255 Then planet=0

; galaxy or planet has changed? recalculate current galaxy/planet
If galaxy<>oldgalaxy Or planet<>oldplanet Then
map%=GenerateMap(galaxy)
p=CreatePlanet(galaxy,planet)
EndIf

; draw map
DrawImage map,(2*border),(2*border)

; output data
PlanetData(p,435,(2*border))
MarketData(p,435,(2*border)+156)

; show current planet on map
HighlightPlanet(p.planet,highrad,(2*border)+border,(2*border)+border)

Flip

AppTitle "Elite Planet Generator - Galaxy #"+galaxy

Wend

End

End

Function Normalize#(value#=128.0,value_min#=0.0,value_max#=255.0,norm_min#=0.0,norm_max#=1.0)

Return ((value#-value_min#)/(value_max#-value_min#))*(norm_max#-norm_min#)+norm_min#

End Function

; show current planet position on map
Function HighlightPlanet(p.planet,size%=5,offx%=0,offy%=0)

Color 0,255,0
Oval offx+(Normalize(p\x,0,255,0,width-1))-size,offy+(Normalize(p\z,0,255,0,height-1))-size,(size*2)+1,(size*2)+1,0

End Function

; set elite or random galaxy (always with same rseed seed)
Function Initseed()

SeedRnd rseed

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

End Function

; output planet data
Function PlanetData(p.planet,offx%=0,offy%=0)

Local i%

Color 255,255,255

Text offx,offy+ 0,"Galaxy:Planet: "+p\galaxy+":"+p\planet
Text offx,offy+ 15,"Planet.......: "+p\name
Text offx,offy+ 30,"Position XYZ.: "+ExactInt(p\x)+","+ExactInt(p\y)+","+ExactInt(p\z)
Text offx,offy+ 45,"Government...: "+Government(p\gov)
Text offx,offy+ 60,"Economy......: "+Economy(p\eco)
Text offx,offy+ 75,"Tech Level...: "+p\tech
Text offx,offy+ 90,"Population...: "+p\pop+" Billion"
Text offx,offy+105,"Inhabits.....: "+p\inhabit
Text offx,offy+120,"Planet Radius: "+p\radius+"km"
Text offx,offy+135,"Productivity.: "+p\prod

End Function

; output current planet market data
Function MarketData(p.planet,offx%=0,offy%=0)

Local i%

Color 255,255,255

For i=0 To 16

Text offx,offy+(i*15),p\comm[i]+" : "+AddSpaces(p\price[i],3)+"/"+units[p\unit[i]]

Next

End Function

; add spaces in front of a string
Function AddSpaces$(value$,num%)

Local p%=Instr(value,".")-1
Local add$,i%

For i=1 To num-p

add=add+" "

Next

Return add+value

End Function

; better INT()
Function ExactInt%(x#)

If x>=0 Then Return Floor(x) Else Return Ceil(x)

End Function

; shuffle seed
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

; set current galaxy
Function SetGalaxy(num%=1)

Local L1%=(seed[0] Shr 8)
Local R1%=(seed[0] And $ff)

Local L2%=(seed[1] Shr 8)
Local R2%=(seed[1] And $ff)

Local L3%=(seed[2] Shr 8)
Local R3%=(seed[2] And $ff)

seed[0]=ExactInt(L1/2^(9-num)+(L1 Mod 2^(9-num)*(2^(num-1))))*256+ExactInt(R1/2^(9-num)+(R1 Mod 2^(9-num)*(2^(num-1))))
seed[1]=ExactInt(L2/2^(9-num)+(L2 Mod 2^(9-num)*(2^(num-1))))*256+ExactInt(R2/2^(9-num)+(R2 Mod 2^(9-num)*(2^(num-1))))
seed[2]=ExactInt(L3/2^(9-num)+(L3 Mod 2^(9-num)*(2^(num-1))))*256+ExactInt(R3/2^(9-num)+(R3 Mod 2^(9-num)*(2^(num-1))))

End Function

; set current planet
Function SetPlanet(num%=0)

Local i%

For i=0 To num-1

Tweakseed()
Tweakseed()
Tweakseed()
Tweakseed()

Next

End Function

; generate galaxy map image
Function GenerateMap(galaxy%)

Local i%,rgb%
Local image%=CreateImage(width+(2*border),height+(2*border))
Local buffer%=ImageBuffer(image)

Initseed()

SetBuffer buffer
LockBuffer buffer

SetGalaxy(galaxy)

For i=0 To 255

Local p.planet = New planet

p\x=(seed[1]/256)
p\z=(seed[0]/256)
p\y=128-(p\z/2)

Tweakseed()
Tweakseed()
Tweakseed()
Tweakseed()

rgb=255*$10000+255*$100+255
WritePixelFast (Normalize(p\x,0,255,0,width-1))+border,(Normalize(p\z,0,255,0,height-1))+border,rgb

Next

UnlockBuffer buffer

Color 64,64,64
Rect 0,0,width+(2*border),height+(2*border),0

SetBuffer BackBuffer()

Return image

End Function

; get planet data
Function CreatePlanet.planet(galaxy%,planet%)

Local m%,c.commodity,product%,changing%,q%,quantity%

Initseed()

fluct=CRAND()

SetGalaxy(galaxy)
SetPlanet(planet)

Local p.planet = New planet

p\galaxy=galaxy
p\planet=planet

Local longnameflag=seed[0] And $40
Local n%,d%,tmp%
Local i1$,i2$,i3$,i4$
Local v1%,v2%,v3%,v4%

; position
p\x=(seed[1]/256)
p\z=(seed[0]/256)
p\y=128-(p\z/2)

DebugLog p\x

; government
p\gov=((seed[1] Mod 256)/8) Mod 8

; economy
tmp=(seed[0]/256) Mod 8
If p\gov<2 Then p\eco=(tmp/4)*4+2+(tmp Mod 2) Else p\eco=tmp

; tech level
p\tech=(1-(p\eco/4))*4+(1-((p\eco/2) Mod 2))*2+1-(p\eco Mod 2)+((seed[1]/256) Mod 4)+(p\gov Mod 2)+(p\gov/2)+1

; population in billions
p\pop=(p\tech*4+p\gov+p\eco+1)/10.0

; productivity
p\prod=((1-(p\eco/4))*4+(1-((p\eco/2) Mod 2))*2+1-(p\eco Mod 2)+3)*(p\gov+4)*p\pop*80

; planet radius
p\radius=(((seed[2]/256) Mod 16)+11)*256+(seed[1]/256)

; inhabits name
tmp=((((seed[0]/256) Mod 2)+((seed[1]/256) Mod 2)) Mod 2)+(((((seed[0]/512) Mod 2)+((seed[1]/512) Mod 2)) Mod 2)*2)+(((((seed[0]/1024) Mod 2)+((seed[1]/1024) Mod 2)) Mod 2)*4)
v1=(ExactInt((seed[2]/256)/4) Mod 8)+1
v2=(ExactInt((seed[2]/256)/32))+1
v3=tmp+1
v4=((tmp+(seed[2]/256) Mod 4) Mod 8)+1
i1=IN1(MIN(v1,4))
i2=IN2(MIN(v2,7)) : If i2<>"" Then i2=" "+i2
i3=IN3(MIN(v3,7)) : If i3<>"" Then i3=" "+i3
i4=IN4(v4) : If i4<>"" Then i4=" "+i4
If (seed[2] Mod 256)<127 Then p\inhabit="Human Colonists" Else p\inhabit=Trim(i1+i2+i3+i4)

; planet name
For n=0 To 3

d=(((seed[2] Shr 8) And $1f) Shl 1)

Tweakseed()

If n<3 Or longnameflag Then p\name=Replace(p\name+Mid(syllables,1+d,2),".","")

Next
p\name=Upper(Mid(p\name,1,1))+Mid(p\name,2,Len(p\name)-1)

m=0

For c.commodity = Each commodity

product=p\eco*c\gradient
changing=fluct And c\mask
q=c\basequant+changing-product
q=q And $FF
If q And $80 Then q=0
quantity=q And $3f
q=c\baseprice+changing+product
q=q And $ff
p\comm[m]=c\name
p\price[m]=(q*4)/10.0
p\unit[m]=c\unit
m=m+1

Next

Return p

End Function

; return the smaller value out of two
Function MIN%(num1%,num2%)

If num1<num2 Then Return num1 Else Return num2

End Function

; first inhabitant part
Function IN1$(num%)

Select num

Case 1: Return "Large"
Case 2: Return "Fierce"
Case 3: Return "Small"

End Select

End Function

; second inhabitant part
Function IN2$(num%)

Select num

Case 1: Return "Green"
Case 2: Return "Red"
Case 3: Return "Yellow"
Case 4: Return "Blue"
Case 5: Return "Black"
Case 6: Return "Harmless"

End Select

End Function

; third inhabitant part
Function IN3$(num%)

Select num

Case 1: Return "Slimy"
Case 2: Return "Bug-Eyed"
Case 3: Return "Horned"
Case 4: Return "Bony"
Case 5: Return "Fat"
Case 6: Return "Furry"

End Select

End Function

; fourth inhabitant part
Function IN4$(num%)

Select num

Case 1: Return "Rodents"
Case 2: Return "Frogs"
Case 3: Return "Lizards"
Case 4: Return "Lobsters"
Case 5: Return "Birds"
Case 6: Return "Humanoids"
Case 7: Return "Felines"
Case 8: Return "Insects"

End Select

End Function

; government list
Function Government$(num%)

Select num

Case 0: Return "Anarchy"
Case 1: Return "Feudal"
Case 2: Return "Multi-Government"
Case 3: Return "Dictatorship"
Case 4: Return "Communist"
Case 5: Return "Confederacy"
Case 6: Return "Democracy"
Case 7: Return "Corporate State"

End Select

End Function

; economy list
Function Economy$(num%)

Select num

Case 0: Return "Rich Industrial"
Case 1: Return "Average Industrial"
Case 2: Return "Poor Industrial"
Case 3: Return "Mainly Industrial"
Case 4: Return "Mainly Agricultural"
Case 5: Return "Rich Agricultural"
Case 6: Return "Average Agricultural"
Case 7: Return "Poor Agricultural"

End Select

End Function

; BBC Micro Rand compatibility
Function CRAND%()

nxt=(213013*nxt+2531011)

Return (nxt Shr 16) And $7fff

End Function

.commodities
Data $13,-$02,$06,$01,0,"Food "
Data $14,-$01,$0A,$03,0,"Textiles "
Data $41,-$03,$02,$07,0,"Radioactives"
Data $28,-$05,$E2,$1F,0,"Slaves "
Data $53,-$05,$FB,$0F,0,"Liquor/Wines"
Data $C4,+$08,$36,$03,0,"Luxuries "
Data $EB,+$1D,$08,$78,0,"Narcotics "
Data $9A,+$0E,$38,$03,0,"Computers "
Data $75,+$06,$28,$07,0,"Machinery "
Data $4E,+$01,$11,$1F,0,"Alloys "
Data $7C,+$0d,$1D,$07,0,"Firearms "
Data $B0,-$09,$DC,$3F,0,"Furs "
Data $20,-$01,$35,$03,0,"Minerals "
Data $61,-$01,$42,$07,1,"Gold "
Data $AB,-$02,$37,$1F,1,"Platinum "
Data $2D,-$01,$FA,$0F,2,"Gem-Stones "
Data $35,+$0F,$C0,$07,0,"Alien Items "

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group