Introducing my next project: Tile World!

Tile World is going to be an improved version of my Fractal Terrain Generation program, rebuilt to use lists instead of matrices (to allow for a larger world), an improved terrain generator, a better view angle, and (hopefully) cool terrain features like trees and rivers! I am still figuring out how to draw it correctly, but the generation code is below. A download file is on the Github. I look forward to any feedback/optimizations any of you have!


Code:
ClrHome
Input "SEED ([i] FOR RANDOM): ",S
Input "DETAIL (1-10): ",D
startTmr->T
ClrHome
int(max(1,min(10,D->D
If imag(S:int(.01randT->S
Output(1,1,"SEED: "+eval(S
Output(9,1,"INITIALIZING... "
775->dim(|LX:775->dim(|LZ
5(1-rand(775)2->|LY
0->|N
For(X,1,25
   For([recursiven],1,31
      |N+1->|N
      X->|LX(|N:[recursiven]->|LZ(|N
      Output(9,17,eval(int(100|N/775))+"%
End:End

Output(9,1,"GENERATING HEIGHT... "
3->|N
For([recursiven],1,D
   |LY+|N(1-rand(775)2->|LY
   |N/1.3->|N
   If [recursiven]>=.6D:max(0,|LY->|LY
   Output(9,22,eval(int(60[recursiven]/D))+"%
End

Output(10,1,"SMOOTHING..."
|LY->|LYA
0->|N
For(X,1,24
   For([recursiven],1,31
      0
      If X>1:|LYA(25(X-1)+[recursiven]
      If [recursiven]>1:Ans+|LYA(31X+[recursiven]-1
      If X<24:Ans+|LYA(31(X+1)+[recursiven]
      If [recursiven]<31:Ans+|LYA(31X+[recursiven]+1
      .5(|LY(31X+[recursiven])+(Ans/((V>1)+([recursiven]>1)+(V<24)+([recursiven]<31)->|LY(31X+[recursiven]
      |N+1->|N
      Output(9,14,eval(int(60+40|N/744))+"%
End:End

checkTmr(T->T
Disp Ans
Lists can only be 999 elements long, so even though you could make a larger world than with a matrix you can only get up to a 32x31 (992 elements) world. Unless you're planning to use multiple decimal places or fractional parts for different values.
Big. Update.
We now have relatively fast drawing...
And painstakingly slow calculating.
The Github has been updated

The current time for a Seed of 42, a Height Scale of 2, and a Smoothness of 5 is around 514 seconds.

Known bug: The percentage sometimes shows up weird

prgmTILEWRLD

Code:
ClrHome
Input "Seed ([i] For Random): ",S
Disp "Height Scale
Input "(1=Flat,4=Tall): ",H
Input "Smoothness (1-5): ",F
startTmr->T
ClrHome
If imag(S:int(.01randT->S
5-int(max(1,min(4,H->H

int(max(1,min(5,F->F
Output(1,1,"Seed: "+eval(S
Output(9,1,"Initializing... "
775->dim(|LX:775->dim(|LZ
2(1-rand(775)2->|LY
0->|N
For(X,1,31
   For([recursiven],1,25
      |N+1->|N
      X->|LX(|N:[recursiven]->|LZ(|N
      Output(9,17,eval(int(100|N/775))+"%
End:End

Output(9,1,"Generating Height... "
1.5->|N
For([recursiven],1,4
   |LY+|N(1-rand(775)2->|LY
   |N/1.2->|N
   Output(9,22,eval(int(12.5[recursiven]))+"%
End
max(0,min(7,|LY->|LY
|LY/H->|LY

Output(10,1,"Smoothing..."
0->|N
For(A,1,F
   |LY->|LYA
   For(X,1,30
      For([recursiven],1,25
         0
         If X>1:|LYA(25(X-1)+[recursiven]
         If [recursiven]>1:Ans+|LYA(25X+[recursiven]-1
         If X<30:Ans+|LYA(25(X+1)+[recursiven]
         If [recursiven]<25:Ans+|LYA(25X+[recursiven]+1
         .5(1.5|LY(25X+[recursiven])+(Ans/((V>1)+([recursiven]>1)+(V<31)+([recursiven]<25)->|LY(25X+[recursiven]
         |N+1->|N
         Output(9,22,eval(int(50+|N/(A15)))+"%
End:End:End
DelVar |LYA

ClrDraw
{14,16,15,21->|LC
{.2,4,5,7->|LE
~9->Xmin:21->Xmax
2->Ymin:21->Ymax
(|LX-|LZ)cos(30->|LXP
|LY+(|LX+|LZ)sin(20->|LYP

For(V,30,1,~1)
   For([recursiven],25,1,~1)
      If V<30:Then
         LtBlue->theta
         max(|LY(25V+[recursiven]),|LY(25(V+1)+[recursiven]->C
         For(H,1,dim(|LC))
            If C>|LE(H:|LC(H->theta
         End
         Line(|LXP(25V+[recursiven]),|LYP(25V+[recursiven]),|LXP(25(V+1)+[recursiven]),|LYP(25(V+1)+[recursiven]),theta
      End
      If [recursiven]<25:Then
         LtBlue->theta
         max(|LY(25V+[recursiven]),|LY(25V+[recursiven]+1->C
         For(H,1,dim(|LC))
            If C>|LE(H:|LC(H->theta
         End
         Line(|LXP(25V+[recursiven]),|LYP(25V+[recursiven]),|LXP(25V+[recursiven]+1),|LYP(25V+[recursiven]+1),theta
      End
End:End

checkTmr(T->T
Disp Ans


Edit: I added ClrDraw because I forgot to check my code before uploading it like a fricken idiot XD
Really cool - have you thought about including some screenshots for people to see?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement