I have lately been getting more and more interested in terrain generation, which is how I stumbled upon this way of creating realistic-looking terrain. Using this webpage http://paulbourke.net/fractals/noise/ as a start to get the basic idea of how it works, I was able to create this code. It runs fairly quickly, but can probably be optimized, which is one of the things I have planned for it.
Other planned features:
    Optimizations for speed and size
    A progress bar
    Converting from a matrix to either a list or a string, to allow for higher-resolution terrain
    Option to skip to the highest resolution
    Different elevations are drawn in different colors
    A more user-friendly UI
    Ability to rotate the terrain
    A display in the top left of the graph screen that shows the current settings


I am completely open to suggestions and ideas!


Code:

ClrDraw:ClrHome
Input "RESOLUTION (1-4): ",A
int(min(4,max(1,A->A
Input "SEED (pi FOR RAND SEED): ",S
Input "SMOOTHNESS (0-2): ",R
1+min(2,max(0.1,R->R
Input "OVERALL HEIGHT (1,5): ",P
.1min(5,max(1,P->P
startTmr->T:T->rand
If not(S=pi
S->rand
~4->Xmin:33->Xmax
~6->Ymin:19->Ymax
15->L
{2,4,8,16->|LR
{10,14,18->|LC
|LR(A->B
seq(X,X,0,L,L/B)->|LX
dim(Ans->B
Ans->G
{Ans,Ans->dim([A]
For(Y,1,G
   For(X,1,G
      YL/G->[A](Y,X
End:End

For(I,A,1,~1
   {[A](1,1),[A](1,G),[A](G,1),[A](G,G->L1
   [A]+PrandM(G,G)->[A]
   L1(1->[A](1,1
   L1(2->[A](1,G
   L1(3->[A](G,1
   L1(4->[A](G,G
   For(V,1,G
      For(W,1,G
         If 0>([A](V,W)-VL/G
         VL/G->[A](V,W
   End:End
   ClrDraw
   0.5|LR(I->S
   Pt-On(0,0,White
   Lsin(15)/A->B
   Lsin(5)/A->C
   For(X,1,G,S
      For(Y,1,G,S
         If X!=G and Y and X+S<=G
         Line(YB+|LX(X),~XC+[A](Y,X),YB+|LX(X+S),~(X+S)C+[A](Y,X+S)
         If Y!=G and Y and Y+S<=G
         Line(YB+|LX(X),~XC+[A](Y,X),(Y+S)B+|LX(X),~XC+[A](Y+S,X)
   End:End
   P/R->P
End
checkTmr(T->T
Text(1,1,Ans



Edit: The current version of the code is below.


Code:
ClrDraw:ClrHome:Degree
Input "Resolution (1-4): ",A
int(min(4,max(1,A->A
Input "Seed ([i] For Rand Seed): ",S
Input "Smoothness (0-2): ",R
1+min(2,max(0.1,R->R
Input "Height Scaling (1,5): ",P
min(5,max(1,P->P
Input "Sea Level (0,1): ",M
min(1,max(0,M->M
Disp "Skip to last
Input "iteration? (0-1) ",J
ClrHome
startTmr->T
If imag(S:int(.01randT->S
S->rand
Output(1,1,"Seed: "+eval(S
Output(10,1,"Initializing..."
~4->Xmin:33->Xmax
~6->Ymin:19->Ymax
15->L
DelVar [A]
{2,4,8,16->|LR
{10,14,18->|LC
|LR(A->B
seq(X,X,0,L,L/B)->|LX
dim(Ans->B
Ans->G
{Ans,Ans->dim([A]

For(I,A,1,~1
   ClrHome
   Output(1,1,"Seed: "+eval(S
   Output(3,1,"Iteration "+eval(1+A-I
   .5|LR(I->S
   Output(10,1,"Tweaking Height... "
   {[A](1,1),[A](1,G),[A](G,1),[A](G,G->L1
   DelVar Q
   For(V,1,G,S
      For(W,1,G,S
         Q+1->Q
         [A](V,W)+Prand->[A](V,W
         Output(10,20,eval(int(100Q/int(1+(G-1)/S)^^2))+"%  "
      End
   End
   L1(1->[A](1,1
   L1(2->[A](1,G
   L1(3->[A](G,1
   L1(4->[A](G,G
   Output(10,1,"Flooding...            "
   DelVar Q
   For(V,1,G,S
      For(W,1,G,S
         Q+1->Q
         max(0,[A](V,W)-M->[A](V,W
         Output(10,13,eval(int(100Q/int(1+(G-1)/S)^^2))+"%  "
   End:End
   Output(10,1,"Making Midpoints...    "
   DelVar Q
   For(V,1,G
      For(W,S+1,G-S,S
         Q+1->Q
         If not([A](V,W
         .5([A](V,W-S)+[A](V,W+S)->[A](V,W
         Output(10,21,eval(int(100Q/(Gint((G-1)/S-1))))+"%"
   End:End
   
   If I=1 or not(J:Then
      ClrDraw
      Pt-On(0,0,White
      Lsin(15)/A->B
      Lsin(5)/A->C
      DelVar Q
      TextColor(Black
      For(X,1,G,S)
         For(Y,1,G,S)
            Q+1->Q
            YL/G
            If X!=G and Y and X+S<=G
            Line(YB+|LX(X),Ans-XC+[A](Y,X),YB+|LX(X+S),Ans-(X+S)C+[A](Y,X+S)
            YL/G
            If Y!=G and Y and Y+S<=G
            Line(YB+|LX(X),Ans-XC+[A](Y,X),(Y+S)B+|LX(X),(Y+S)L/G-XC+[A](Y+S,X)
            Text(0,0,"Rendering... "+eval(int(100Q/int(1+(G-1)/S)^^2))+"%
      End:End
      Wait 1
   End
   P/R->P
End
checkTmr(T->T
Text(150,1,"ELAPSED TIME: ",Ans


Edit 2: See the latest post for an updated version
Nice work! I’m looking forward to trying that code out. Perhaps I could learn a thing or two for my own terrain generator from that link!

EDIT: I tried it out, and it works great! (That is, after you told me to use Degree mode). I like how it's not cubes like mine, it's different Razz Reminds me of Kerm's 3d grapher.
Alright, I have done some work and updated the code.

Completed features:
    Option to skip to the final iteration
    Ability to use pi as a seed
    Progress markers to indicate what the program is doing


Planned features:
    Optimizations for speed and size
    Use a list or a string instead of a matrix, because that would let higher-resolution terrain be created (Matrices could only go up to a 16x16 for the purposes of this program.)
    Different elevations will be drawn in different colors, to look more like realistic terrain
    A more user-friendly UI when creating settings. (I might use a menu)
    Ability to rotate the terrain in 360 degrees about the center.
    The map gets really spiky when you go above three in the height setting, even when smoothness is at its max. I will decide to either cap it at three or figure out some way to remove the insane spikes.
    Add lowercase letters


I decided to not worry about having the settings be displayed, as I would assume the user would already know that because they entered them in. Very Happy

Known Bugs:
    The percentage bar for drawing doesn't stop at 100%. I have no idea how to fix this, so if someone could fix that for me, that would be amazing.




Code:
ClrDraw:ClrHome:Degree
Input "RESOLUTION (1-4): ",A
int(min(4,max(1,A->A
Input "SEED ([i] FOR RAND SEED): ",S
Input "SMOOTHNESS (0-2): ",R
1+min(2,max(0.1,R->R
Input "OVERALL HEIGHT (1,5): ",P
.1min(5,max(1,P->P
Disp "SKIP TO LAST
Input "ITERATION? (0-1) ",J
ClrHome
startTmr->T
If imag([i]:int(T/100->S
S->rand
Output(1,1,"SEED: "+eval(S
Output(10,1,"INITIALIZING..."
~4->Xmin:33->Xmax
~6->Ymin:19->Ymax
15->L
{2,4,8,16->|LR
{10,14,18->|LC
|LR(A->B
seq(X,X,0,L,L/B)->|LX
dim(Ans->B
Ans->G
{Ans,Ans->dim([A]
DelVar Q
For(Y,1,G
   For(X,1,G
      Q+1->Q
      YL/G->[A](Y,X
      Output(10,17,eval(round(100Q/G^^2,1))+"%
End:End

For(I,A,1,~1
   ClrHome
   Output(1,1,"ITERATION "+eval(1+A-I
   Output(10,1,"CHANGING HEIGHT... "
   {[A](1,1),[A](1,G),[A](G,1),[A](G,G->L1
   [A]+PrandM(G,G)->[A]
   L1(1->[A](1,1
   L1(2->[A](1,G
   L1(3->[A](G,1
   L1(4->[A](G,G
   Output(10,1,"REMOVING DIPS... "
   0->Q
   For(V,1,G
      For(W,1,G
         Q+1->Q
         If 0>([A](V,W)-VL/G
         VL/G->[A](V,W
         Output(10,18,eval(round(100Q/G^^2,1))+"%
   End:End
   If I=1 or not(J:Then
      ClrDraw
      0.5|LR(I->S
      Pt-On(0,0,White
      Lsin(15)/A->B
      Lsin(5)/A->C
      DelVar Q
      TextColor(Black
      For(X,1,G,S)
         For(Y,1,G,S)
            Q+1->Q
            If X!=G and Y and X+S<=G
            Line(YB+|LX(X),~XC+[A](Y,X),YB+|LX(X+S),~(X+S)C+[A](Y,X+S)
            If Y!=G and Y and Y+S<=G
            Line(YB+|LX(X),~XC+[A](Y,X),(Y+S)B+|LX(X),~XC+[A](Y+S,X)
            Text(1,1,"DRAWING... "+eval(round(100Q/((G-1)/S)^^2,1))+"%
      End:End
   End
   P/R->P
End
checkTmr(T->T
Text(1,1,Ans
Nice work, however your code generates a random seed no matter what now.

This line:

Code:
If imag([i]:int(T/100->S

should be:

Code:
If imag(S:int(T/100->S

Otherwise, you are checking if the imaginary i is imaginary, which will always be true.

I'll check out the rest of your program in a minute, and tell you what I think!

Your random seed generator looks good too, if you want you can also do int(randstartTmr) which would allow for a wider variety of seeds.

EDIT: Tried the new code out and it works great! Love the progress percentages! They sometimes go over 100 on the graph screen though Razz
Okay thanks! I can't believe I missed that....
In the meantime, I really have absolutely no idea how I would go about using a string in place of a matrix. If someone could point me to a website on how that would work, that would be great. I also am worried that using a string would seriously slow down the randomization step, and just make the whole program slow(er). If I can't find a suitable replacement, I might have to limit it to just 16x16...which would really suck. :/
I added the sea level code, which makes it look SO MUCH BETTER. I also did a few small optimizations. I did realize one really small, but really important problem though. I am supposed to take the average of the heights of the points from the last iteration and use it as a guide for the next iteration, but I haven't been doing that. This explains why the drawing looks so different between each iteration. I have looked into it, and actually spent quite some time trying to figure out what to do, but I haven't been able to get it to work. If anyone could do that for me, that would be amazing. I also decided to just stick with a matrix, as rendering anything more than a 16x16 would start to take way too long, and wouldn't look as nice.

Code:

1:ClrHome:Degree
Input "RESOLUTION (1-4): ",A
int(min(4,max(1,A->A
Input "SEED ([i] FOR RAND SEED): ",S
Input "SMOOTHNESS (0-2): ",R
1+min(2,max(0.1,R->R
Input "HEIGHT SCALING (1,5): ",P
.1min(5,max(1,P->P
Input "SEA LEVEL (0,1): ",M
min(1,max(0,M->M
Disp "SKIP TO LAST
Input "ITERATION? (0-1) ",J
ClrHome
startTmr->T
If imag(S:int(.01randT->S
S->rand
Output(1,1,"SEED: "+eval(S
Output(10,1,"INITIALIZING..."
~4->Xmin:33->Xmax
~6->Ymin:19->Ymax
15->L
DelVar [A]
{2,4,8,16->|LR
{10,14,18->|LC
|LR(A->B
seq(X,X,0,L,L/B)->|LX
dim(Ans->B
Ans->G
{Ans,Ans->dim([A]

For(I,A,1,~1
   ClrHome
   Output(1,1,"ITERATION "+eval(1+A-I
   .5|LR(I->S
   Output(10,1,"TWEAKING HEIGHT... "
   {[A](1,1),[A](1,G),[A](G,1),[A](G,G->L1
   [A]+PrandM(G,G)->[A]
   L1(1->[A](1,1
   L1(2->[A](1,G
   L1(3->[A](G,1
   L1(4->[A](G,G
   Output(10,1,"FLOODING...  "
   DelVar Q
   For(V,1,G,S
      For(W,1,G,S
         Q+1->Q
         max(0,[A](V,W)-M->[A](V,W
         Output(10,13,eval(round(100Q/((G-1)/S)^^2,1))+"%  "
   End:End
   
   If I=1 or not(J:Then
      ClrDraw
      Pt-On(0,0,White
      Lsin(15)/A->B
      Lsin(5)/A->C
      DelVar Q
      TextColor(Black
      For(X,1,G,S)
         For(Y,1,G,S)
            Q+1->Q
            YL/G
            If X!=G and Y and X+S<=G
            Line(YB+|LX(X),Ans-XC+[A](Y,X),YB+|LX(X+S),Ans-(X+S)C+[A](Y,X+S)
            YL/G
            If Y!=G and Y and Y+S<=G
            Line(YB+|LX(X),Ans-XC+[A](Y,X),(Y+S)B+|LX(X),(Y+S)L/G-XC+[A](Y+S,X)
            Text(0,0,"RENDERING... "+eval(round(100Q/((G-1)/S)^^2,1))+"%
      End:End
      Wait 1
   End
   P/R->P
End
checkTmr(T->T
Text(150,1,"ELAPSED TIME: ",Ans
Okay, I fixed a lot of things (no new major features, sorry), and made the code look better.

New features:
    Added lowercase letters.
    Edited the descriptions for different parts of the code.
    Made the math actually work correctly. (It was previously just randomizing each point individually, now it takes the previous height values into account)
    The seed is displayed.
    I fixed the percentage bug, big thanks to LogicalJoe for figuring out what to use for the equation.
    The sea level setting removes a lot of the spikes, making even the crazy "Height scale of 5" seem tame.


Planned features:
    Optimizations for speed and size
    Different elevations will be drawn in different colors, to look more like realistic terrain
    A more user-friendly UI when creating settings. (I might use a menu)
    Ability to rotate the terrain in 360 degrees about the center.


I will probably be working on the colors next, which shouldn't be hard.

prgmFRACTERR

Code:
ClrDraw:ClrHome:Degree
Input "Resolution (1-4): ",A
int(min(4,max(1,A->A
Input "Seed ([i] For Rand Seed): ",S
Input "Smoothness (0-2): ",R
1+min(2,max(0.1,R->R
Input "Height Scaling (1,5): ",P
min(5,max(1,P->P
Input "Sea Level (0,1): ",M
min(1,max(0,M->M
Disp "Skip to last
Input "iteration? (0-1) ",J
ClrHome
startTmr->T
If imag(S:int(.01randT->S
S->rand
Output(1,1,"Seed: "+eval(S
Output(10,1,"Initializing..."
~4->Xmin:33->Xmax
~6->Ymin:19->Ymax
15->L
DelVar [A]
{2,4,8,16->|LR
{10,14,18->|LC
|LR(A->B
seq(X,X,0,L,L/B)->|LX
dim(Ans->B
Ans->G
{Ans,Ans->dim([A]

For(I,A,1,~1
   ClrHome
   Output(1,1,"Seed: "+eval(S
   Output(3,1,"Iteration "+eval(1+A-I
   .5|LR(I->S
   Output(10,1,"Tweaking Height... "
   {[A](1,1),[A](1,G),[A](G,1),[A](G,G->L1
   DelVar Q
   For(V,1,G,S
      For(W,1,G,S
         Q+1->Q
         [A](V,W)+Prand->[A](V,W
         Output(10,20,eval(int(100Q/int(1+(G-1)/S)^^2))+"%  "
      End
   End
   L1(1->[A](1,1
   L1(2->[A](1,G
   L1(3->[A](G,1
   L1(4->[A](G,G
   Output(10,1,"Flooding...            "
   DelVar Q
   For(V,1,G,S
      For(W,1,G,S
         Q+1->Q
         max(0,[A](V,W)-M->[A](V,W
         Output(10,13,eval(int(100Q/int(1+(G-1)/S)^^2))+"%  "
   End:End
   Output(10,1,"Making Midpoints...    "
   DelVar Q
   For(V,1,G
      For(W,S+1,G-S,S
         Q+1->Q
         If not([A](V,W
         .5([A](V,W-S)+[A](V,W+S)->[A](V,W
         Output(10,21,eval(int(100Q/(Gint((G-1)/S-1))))+"%"
   End:End
   
   If I=1 or not(J:Then
      ClrDraw
      Pt-On(0,0,White
      Lsin(15)/A->B
      Lsin(5)/A->C
      DelVar Q
      TextColor(Black
      For(X,1,G,S)
         For(Y,1,G,S)
            Q+1->Q
            YL/G
            If X!=G and Y and X+S<=G
            Line(YB+|LX(X),Ans-XC+[A](Y,X),YB+|LX(X+S),Ans-(X+S)C+[A](Y,X+S)
            YL/G
            If Y!=G and Y and Y+S<=G
            Line(YB+|LX(X),Ans-XC+[A](Y,X),(Y+S)B+|LX(X),(Y+S)L/G-XC+[A](Y+S,X)
            Text(0,0,"Rendering... "+eval(int(100Q/int(1+(G-1)/S)^^2))+"%
      End:End
      Wait 1
   End
   P/R->P
End
checkTmr(T->T
Text(150,1,"ELAPSED TIME: ",Ans


Edit: I had left in the Goto 1 that I was using while testing the code. That has been removed.
Big updates!
I wish I could call this update the World of Color, but Minecraft already used that one...

WORLD OF RGB!
yeah that sounds good....

New Features!
    Color
    The terrain generation has been improved significantly
    The terrain is generated and rendered much faster
    Fewer settings, because some of the settings no longer had an effect on the new terrain generation math


Here is an example of the terrain:


Planned features:
    Optimizations
    A more user-friendly UI when creating settings. (I might use a menu)
    Ability to rotate the terrain in 360 degrees about the center.
    Possible small changes in the terrain generation
    Use of multiple matrices to handle terrain generated with more iterations.
    An improved color palate.


Please let me know if you think of anything else you want to be added!
prgmFRACTERR

Code:
ClrDraw:ClrHome:Degree
Input "plotsquareIterations (1-4): ",A
int(min(4,max(1,A->A
Input "plotsquareSeed ([i] For Random): ",S
Input "plotsquareSmoothness (0-2): ",R
1+min(2,max(0.1,R->R
Input "plotsquareHeight Scaling (1,5): ",P
.1min(5,max(1,P->P
Input "plotsquareSea Level (0,2): ",M
min(2,max(0,M->M
ClrHome
startTmr->T
If imag(S:int(.01randT->S
S->rand
Output(1,1,"Seed: "+eval(S
Output(10,1,"Initializing..."
~4->Xmin:33->Xmax
~6->Ymin:19->Ymax
15->L
DelVar [A]
{2,4,8,16->|LR
{14.05,15.2,16.4,21.6}->|LC
|LR(A->B
seq(X,X,0,L,L/B)->|LX
dim(Ans->B
Ans->G
{Ans,Ans->dim([A]
.1randabs(randM(G,G->[A]

ClrHome
Output(1,1,"Seed: "+eval(S
For(I,A,1,~1
   Output(3,1,"Iteration "+eval(1+A-I)+"/"+eval(A
   Output(10,1,"Tweaking Height... "
   .5|LR(I->S
   [A]+PrandM(G,G->[A]
   Output(10,1,"Flooding...          "
   DelVar Q
   For(V,1,G,S
      For(W,1,G,S
         Q+1->Q
         max(0,[A](V,W)-M->[A](V,W
         "
         Output(10,11,eval(int(100Q/int(1+(G-1)/S)^^2))+"%  "
   End:End
   P/R->P
End

Output(10,1,"Smoothening...       "
DelVar Q
[A]->[B]
For(V,1,G)
   For(W,1,G)
      Q+1->Q
      DelVar L1
      {[A](V,W->L1
      If V>1:augment(L1,{[B](V-1,W->L1
      If W>1:augment(L1,{[B](V,W-1->L1
      If V<G:augment(L1,{[B](V+1,W->L1
      If W<G:augment(L1,{[B](V,W+1->L1
      (sum(L1)-L1(1))/(dim(L1)-1
      .5(L1(1)+Ans)->[A](V,W)
      Output(10,16,eval(int(100Q/int(1+(G-1)/S)^^2))+"%  "
End:End
DelVar [B]
ClrDraw
Pt-On(0,0,White
Lsin(15)/A->B
Lsin(5)/A->C
DelVar Q
TextColor(Black
For(X,1,G,S)
   For(Y,1,G,S)
      Q+1->Q
      If X!=G and Y and X+S<=G:Then
         10->theta
         For(H,1,dim(|LC))
            If [A](Y,X)>10fPart(|LC(H)) or [A](Y,X+S)>10fPart(|LC(H
            iPart(|LC(H))->theta
         End
         YL/G
         Line(YB+|LX(X),Ans-XC+[A](Y,X),YB+|LX(X+S),Ans-(X+S)C+[A](Y,X+S),theta
      End
      If Y!=G and Y and Y+S<=G:Then
         10->theta
         For(H,1,dim(|LC))
            If [A](Y,X)>10fPart(|LC(H)) or [A](Y+S,X)>10fPart(|LC(H
            iPart(|LC(H))->theta
         End
         YL/G
         Line(YB+|LX(X),Ans-XC+[A](Y,X),(Y+S)B+|LX(X),(Y+S)L/G-XC+[A](Y+S,X),theta
      End
      Text(0,0,"Rendering... "+eval(int(100Q/int(1+(G-1)/S)^^2))+"%
   End
End
checkTmr(T->T
Text(150,1,"Elapsed Time: ",Ans
Nice work! I ran the program and it's pretty cool! Could you post some settings so we can benchmark your code's speed throughout development?
Yeah sure! Also, at one point it took 342 seconds to generate an iteration 4 terrain. That was due to the averaging part that averaged entire rows and columns, but it has been removed.

These settings will remain unchanged:
Seed of 42
Smoothness of 1
Height Scale of 3
Sea Level at .3

Times before using Recursive n:
1 Iteration: 6 seconds
2 Iterations: 14 seconds
3 Iterations: 48 seconds
4 Iterations: 177 seconds

Times after using Recursive n:
1 Iteration: 5 seconds
2 Iterations: 14 seconds
3 Iterations: 42 seconds
4 Iterations: 169 seconds

Don't forget that I have a built-in time-keeper that will track how long the program takes to run, start to finish. So no need to add your own. Very Happy
I have made some optimizations to the code, with the help of kg583 and mr womp womp. I also added to the color palette, which resulted in some of the processes taking LONGER than they used to. But I did check the times before I changed the colors, and the code was running slightly faster.
With these settings:
    Seed of 42
    Smoothness of 1
    Height Scale of 3
    Sea Level at .3

Here are the following times:
    1 Iteration: 5 seconds
    2 Iterations: 13 seconds
    3 Iterations: 59 seconds
    4 Iterations: 170 seconds


prgmFRACTERR

Code:
ClrDraw:ClrHome:Degree:BackgroundOn MedGray
Input "plotsquareIterations (1-4): ",A
int(min(4,max(1,A->A
Input "plotsquareSeed ([i] For Random): ",S
Input "plotsquareSmoothness (0-2): ",R
1+min(2,max(0.1,R->R
Input "plotsquareHeight Scaling (1,5): ",P
.1min(5,max(1,P->P
Input "plotsquareSea Level (0,2): ",M
min(2,max(0,M->M
ClrHome
startTmr->T
If imag(S:int(.01randT->S
S->rand
Output(1,1,"Seed: "+eval(S
Output(10,1,"Initializing..."
~4->Xmin:33->Xmax
~6->Ymin:19->Ymax
15->L
DelVar [A]
{2,4,8,16->|LR
{18.02,19.03,14.04,15.3,16.4,21.5}->|LC
|LR(A->B
seq(X,X,0,L,L/B)->|LX
dim(Ans->B
Ans->G
{Ans,Ans->dim([A]
.1randabs(randM(G,G->[A]

ClrHome
Output(1,1,"Seed: "+eval(S
For(I,A,1,~1
   Output(3,1,"Iteration "+eval(1+A-I)+"/"+eval(A
   Output(10,1,"Tweaking Height... "
   .5|LR(I->S
   [A]+PrandM(G,G->[A]
   Output(10,1,"Flooding...          "
   DelVar Q
   For(V,1,G,S
      For([recursiven],1,G,S
         Q+1->Q
         max(0,[A](V,[recursiven])-M->[A](V,[recursiven]
         Output(10,11,eval(int(100Q/int(1+(G-1)/S)^^2))+"%  "
   End:End
   P/R->P
End

Output(10,1,"Smoothening...       "
DelVar Q
[A]->[B]
For(V,1,G)
   For([recursiven],1,G)
      Q+1->Q
      (V>1)+([recursiven]>1)+(V<G)+([recursiven]<G->D
      0
      If V>1:[B](V-1,[recursiven]
      If [recursiven]>1:Ans+[B](V,[recursiven]-1
      If V<G:Ans+[B](V+1,[recursiven]
      If [recursiven]<G:Ans+[B](V,[recursiven]+1
      .5([A](V,[recursiven])+(Ans/D->[A](V,[recursiven]
      Output(10,14,eval(int(100Q/G^^2))+"%  "
End:End
ClrDraw
Pt-Off(0,0
Lsin(15)/A->B
Lsin(5)/A->C
DelVar Q
TextColor(Black
For(V,1,G,S)
   For([recursiven],1,G,S)
      Q+1->Q
      If V!=G and [recursiven] and V+S<=G:Then
         10->theta
         For(H,1,dim(|LC))
            If [A]([recursiven],V)>10fPart(|LC(H)) or [A]([recursiven],V+S)>10fPart(|LC(H
            iPart(|LC(H))->theta
         End
         [recursiven]L/G
         Line([recursiven]B+|LX(V),Ans-VC+[A]([recursiven],V),[recursiven]B+|LX(V+S),Ans-(V+S)C+[A]([recursiven],V+S),theta
      End
      If [recursiven]!=G and [recursiven] and [recursiven]+S<=G:Then
         10->theta
         For(H,1,dim(|LC))
            If [A]([recursiven],V)>10fPart(|LC(H)) or [A]([recursiven]+S,V)>10fPart(|LC(H
            iPart(|LC(H))->theta
         End
         [recursiven]L/G
         Line([recursiven]B+|LX(V),Ans-VC+[A]([recursiven],V),([recursiven]+S)B+|LX(V),([recursiven]+S)L/G-VC+[A]([recursiven]+S,V),theta
      End
      Text(0,0,"Rendering... "+eval(int(100Q/int(1+(G-1)/S)^^2))+"%
   End
End
DelVar [B]
checkTmr(T->T
Text(150,1,"Elapsed Time: ",Ans


I would really like some feedback on what colors to use, and in what order. (From the colors at the lowest elevation, to the highest elevation.) Also, how does it look with the Medium Gray background?

Edit: Here is a sample terrain:
I did a few optimizations and added the code to draw a diagonal line. This made the overall time jump significantly.

With these settings:
    Seed of 42
    Smoothness of 1
    Height Scale of 3
    Sea Level at .3


Here are the following times:
    1 Iteration: 6 seconds
    2 Iterations: 16 seconds
    3 Iterations: 55 seconds
    4 Iterations: 206 seconds


So the code obviously needs optimizations, but I did all I really know how for optimizing. I also don't really know if I like having the diagonals. I would like some feedback on both that and the color choices. After the code gets optimized, I will try to increase the maximum resolution.

prgmFRACTERR

Code:
ClrHome:Degree:BackgroundOn MedGray
Input "plotsquareIterations (1-4): ",A
int(min(4,max(1,A->A
Input "plotsquareSeed ([i] For Random): ",S
Input "plotsquareSmoothness (0-2): ",R
1+min(2,max(0.1,R->R
Input "plotsquareHeight Scaling (1,5): ",P
.1min(5,max(1,P->P
Input "plotsquareSea Level (0,2): ",M
min(2,max(0,M->M
ClrHome
startTmr->T
If imag(S:int(.01randT->S
S->rand
Output(1,1,"Seed: "+eval(S
Output(10,1,"Initializing..."
~4->Xmin:33->Xmax
~6->Ymin:19->Ymax
15->L
seq(X,X,0,Ans,Ans/(2^A)->L1
dim(Ans->B
Ans->G
.1randabs(randM(Ans,Ans->[A]
{18,19,14,15,16,21->L2
{.2,.3,.4,3,4,5->L3

ClrHome
Output(1,1,"Seed: "+eval(S
For(I,A,1,~1
   Output(3,1,"Iteration "+eval(1+A-I)+"/"+eval(A
   Output(10,1,"Tweaking Height... "
   int(cosh(.7I->S
   [A]+PrandM(G,G->[A]
   Output(10,1,"Flooding...          "
   0->|N
   For(V,1,G,S
      For([recursiven],1,G,S
         max(0,[A](V,[recursiven])-M->[A](V,[recursiven]
         |N+1->|N
         Output(10,11,eval(int(100Ans/int(1+(G-1)/S)^^2))+"%  "
   End:End
   P/R->P
End

Output(10,1,"Smoothening...       "
0->|N
[A]->[B]
For(V,1,G
   For([recursiven],1,G
      0
      If V>1:[B](V-1,[recursiven]
      If [recursiven]>1:Ans+[B](V,[recursiven]-1
      If V<G:Ans+[B](V+1,[recursiven]
      If [recursiven]<G:Ans+[B](V,[recursiven]+1
      .5([A](V,[recursiven])+(Ans/((V>1)+([recursiven]>1)+(V<G)+([recursiven]<G->[A](V,[recursiven]
      |N+1->|N
      Output(10,14,eval(int(100Ans/G^^2))+"%  "
End:End
ClrDraw
Pt-Off(0,0
Lsin(15)/A->B
Lsin(5)/A->C
0->|N
TextColor(Black
For(V,G,1,~S)
   For([recursiven],1,G,S)
      If V and [recursiven]+S<=G:Then
         Blue->theta
         For(H,1,dim(L2))
            If [A](V,[recursiven])>L3(H) or [A](V,[recursiven]+S)>L3(H
            L2(H->theta
         End
         VL/G
         Line(VB+L1([recursiven]),Ans-[recursiven]C+[A](V,[recursiven]),VB+L1([recursiven]+S),Ans-([recursiven]+S)C+[A](V,[recursiven]+S),theta
      End
      If V and V+S<=G:Then
         Blue->theta
         For(H,1,dim(L2))
            If [A](V,[recursiven])>L3(H) or [A](V+S,[recursiven])>L3(H
            L2(H->theta
         End
         VL/G
         Line(VB+L1([recursiven]),Ans-[recursiven]C+[A](V,[recursiven]),(V+S)B+L1([recursiven]),(V+S)L/G-[recursiven]C+[A](V+S,[recursiven]),theta
      End
      If [recursiven] and V and [recursiven]+S<=G and V+S<=G:Then
         Blue->theta
         For(H,1,dim(L2))
            If [A](V,[recursiven])>L3(H) or [A](V+S,[recursiven]+S)>L3(H
            L2(H->theta
         End
         VL/G
         Line(VB+L1([recursiven]),Ans-[recursiven]C+[A](V,[recursiven]),(V+S)B+L1([recursiven]+S),(V+S)L/G-([recursiven]+S)C+[A](V+S,[recursiven]+S),theta
      End
      |N+1->|N
      Text(0,0,"Rendering... "+eval(int(100Ans/(1+(G-1)/S)^^2))+"%
   End
End
DelVar [B]
checkTmr(T->T
Text(150,1,"Elapsed Time: ",Ans
I tried to run the code here, but I had no luck, so I thought I'd try writing something myself. You have several size squares per size, 8 to 18. They must be even numbers. You can vary the scale and the height. For 8 sided, try 8 23 30. For 18 sided, try 18 10 20. The 8 sided one takes 7 seconds and the 18 sided one, 30 seconds. The first time you run this, it will ask you for the 3 values. When the plot is complete press Enter. The second time it will ask if you want to run again using the same values. The plot will be different each time. This was written for my TI84+CE.


Code:

BackgroundOn LTGRAY
50→Xmin:800→Xmax
0→Ymin:430→Ymax
0→N
Lbl Z
ClrDraw:ClrHome
If N>0:Then
Input "SAME VALUES 0=N 1=Y ",A
If A=1:Goto W
End
Disp "8,10,12,14,16,18 "
Input "NBR PER SIDE (N) ",N
If remainder(N,2)≠0:Goto Z
If N<8 or N>18:Goto Z
N+1→N
Input " SCALE (S) ",S
Input "HEIGHT (H) ",H
420→G:0→J
{N,N}→dim([A]
{N,N}→dim([B]
Lbl W:ClrDraw

Disp "CALC 1"
For(A,1,N):For(B,1,N
randInt(­H,H)→[B](A,B)
End:End

Disp "CALC 2"
For(A,1,N-1,2):For(B,1,N
[B](A,B)→C
[B](A+2,B)→D
(C+D)/2→[B](A+1,B)
End:End

Disp "CALC 3"
For(A,1,N):For(B,1,N-1,2
[B](A,B)→C
[B](A,B+2)→D
(C+D)/2→[B](A,B+1)
End:End

Disp "CALC 4"
For(A,1,N):For(B,1,N
G+B*2*S-A*2*S→C
(J+A*S+B*S+[B](A,B))/1000→D
(C+D)→[A](A,B)
End:End

For(A,N+1,2,­1
For(B,N,2,­1
iPart([A](A-1,B-1))→C
fPart([A](A-1,B-1))*1000→D
iPart([A](A-1,B)→E
fPart([A](A-1,B))*1000→F
[B](A-1,B)→U
If U<0:Then
Line(C,D,E,F,BLUE)
Else
If U<H/2:Then
Line(C,D,E,F,GREEN)
Else
Line(C,D,E,F,WHITE)
End:End:End:End

For(B,N+1,2,­1
For(A,N,2,­1
iPart([A](A-1,B-1))→C
fPart([A](A-1,B-1))*1000→D
iPart([A](A,B-1)→E
fPart([A](A,B-1))*1000→F
[B](A,B-1)→U
If U<0:Then
Line(C,D,E,F,BLUE)
Else
If U<H/2:Then
Line(C,D,E,F,GREEN)
Else
Line(C,D,E,F,WHITE)
End:End:End:End

Text(0,0,"N")
Text(0,20,N-1)
Text(15,0,"S"
Text(15,20,S)
Text(30,0,"H")
Text(30,20,H)
Text(150,0,"PRESS ENTER"
Pause
Goto Z
Updated the code for the way I calculate the line color. Everything else is the same. See above for instructions.


Code:

BackgroundOn LTGRAY
50→Xmin:800→Xmax
0→Ymin:430→Ymax
0→N
Lbl Z:ClrDraw:ClrHome
If N>0:Then
Input "SAME VALUES 0=N 1=Y ",A
If A=1:Goto W
End
Disp "8,10,12,14,16,18 "
Input "NBR PER SIDE (N) ",N
If remainder(N,2)≠0:Goto Z
If N<8 or N>18:Goto Z
N+1→N
Input " SCALE (S) ",S
Input "HEIGHT (H) ",H
420→G:0→J
{N,N}→dim([A]
{N,N}→dim([B]
Lbl W:ClrDraw

Disp "CALC 1"
For(A,1,N):For(B,1,N
randInt(­H,H)→[B](A,B)
End:End

Disp "CALC 2"
For(A,1,N-1,2):For(B,1,N
[B](A,B)→C
[B](A+2,B)→D
(C+D)/2→[B](A+1,B)
End:End

Disp "CALC 3"
For(A,1,N):For(B,1,N-1,2
[B](A,B)→C
[B](A,B+2)→D
(C+D)/2→[B](A,B+1)
End:End

Disp "CALC 4"
For(A,1,N):For(B,1,N
G+B*2*S-A*2*S→C
(J+A*S+B*S+[B](A,B))/1000→D
(C+D)→[A](A,B)
End:End

Text(0,0,"N")
Text(0,20,N-1)
Text(15,0,"S"
Text(15,20,S)
Text(30,0,"H")
Text(30,20,H)

For(A,N+1,2,­1
For(B,N,2,­1
iPart([A](A-1,B-1))→C
fPart([A](A-1,B-1))*1000→D
[B](A-1,B-1)→U
iPart([A](A-1,B)→E
fPart([A](A-1,B))*1000→F
([B](A-1,B)+U)/2→U
If U<0-H/2:Then
Line(C,D,E,F,BLUE)
Else
If U<H/2:Then
Line(C,D,E,F,GREEN)
Else
Line(C,D,E,F,WHITE)
End:End:End:End

For(B,N+1,2,­1
For(A,N,2,­1
iPart([A](A-1,B-1))→C
fPart([A](A-1,B-1))*1000→D
[B](A-1,B-1)→U
iPart([A](A,B-1)→E
fPart([A](A,B-1))*1000→F
([B](A,B-1)+U)/2→U
If U<0-H/2:Then
Line(C,D,E,F,BLUE)
Else
If U<H/2:Then
Line(C,D,E,F,GREEN)
Else
Line(C,D,E,F,WHITE)
End:End:End:End

Text(150,0,"PRESS ENTER"
Pause
Goto Z
  
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 UTC - 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