I just updated the GitHub with a few things:
1) I added the matrix [B] up for download, which is the pyramid-like structure I had. You can store this in matrix [A] to use it, and you will still have it in [B] if you want to generate other maps.
2) If you enter 0 for the seed, the generator now replaces the 0 with a display of the random seed it is generating. The seed value can be recalled from theta
3) The generator no longer does its previous top down render but goes straight into the isometric program (which includes the minimap top down render of course)
4) The isometric code is pretty much the same, except I optimized some things and now the grass draws faster. I also cleaned up the annoying extra pixels with two Pt-Off( commands.

Sam wrote:
I think it would be cool to have a render option that turns off the rendering of lines between blocks that are both on the same level and are the same type, so you only have lines between block types and at vertices.

So I kind of got that working. How's this?


I messed with the variables a lot but for some reason couldn't get all the black lines to meet up. Oh well. Here's what that looks like:

Code:
ClrDraw
2->R
BROWN->N
BackgroundOn DARKGRAY

//Draw MiniMap
RED
Line(3,~3,3,~52,Ans,1
Line(3,~3,52,~3,Ans,1
Line(3,~52,52,~52,Ans,1
Line(52,~3,52,~52,Ans,1
For(B,0,N-1
   For(A,0,N-1
      [A](A+1,B+1
      Ans-13(Ans=25)-2(Ans=20
      If Ans>25:RED
      Pt-On(3A+5,~3B-5,1,Ans
   End
End

//Draw Isometric Terrain
For(A,1,BROWN //substituting values in For loops with colors
   ~80+20(R-2)-R(A-1->S
   132-6A->T
   For(B,1,BROWN
      [A](B,A)-19->V
      BROWN+2(Ans<2)+3(Ans=2->C
      BLACK-2(Ans=LTBLUE->O
      If V>2 and randInt(0,1
      MEDGRAY->C
      T+6B->X
      S-BR-R+6(V-1->Z
      S-BR+6V-R->W
      
      //Fill Box
      For(I,Z-R+1,Ans+R-2
         Line(X-5,I,X+5,I,C,1
      End
      Pt-Off(X-5,Z-R+1,4
      Pt-Off(X+5,Z-R+1,4
      
      //Complete rest of fill at top
      Line(X-2R,Ans+R-2,X+2R,Ans+R-2,C,1
      Line(X-R,Ans+R-1,X+R,Ans+R-1,C,1
      
      //Draw grass
      If V>2 and C!=MEDGRAY
      Then
         For(I,0,3,.249
            Line(X-6+2I,Ans-I,X+2I,Ans+R-I,GREEN,1
         End
      End
      
      //Draw main vertical edge facing camera
      Line(X,Z-R,X,Ans-R,O,1
      
      //Other edges
      For(I,~6,6,BLACK
         Line(X+I,Z,X,Z-R,O,1
         Line(X+I,W,X+I,Z,O,1
         O
         If I=6 and B<BROWN
         Then
            If [A](B+1,A)=[A](B,A
            C
            If Ans=BROWN:GREEN
         End
         If I=~6 and A<BROWN
         Then
            If [A](B,A+1)=[A](B,A
            C
            If Ans=BROWN:GREEN
         End
         Line(X+I,W,X,W-R,Ans,1
         O
         If I=6 and A>1
         Then
            If [A](B,A-1)=[A](B,A
            C
            If Ans=BROWN:GREEN
         End
         If I=~6 and B>1
         Then
            If [A](B-1,A)=[A](B,A
            C
            If Ans=BROWN:GREEN
         End
         Line(X,W+R,X+I,W,Ans,1
      End
   End
End

It's basically the same as the regular code, except I added the W variable and changed everything in the loop under the "Other edges" comment.

Sam wrote:
Oh my goodness, I just had an idea. This is a great opportunity to use my TI-BASIC RTX code I made a few months ago and never finished! I'm gonna try to throw together a raytraced rendering engine for this program.

That sounds absolutely amazing, good luck! Keep me updated!
The download in the github doesn't include the display program
Here it is after some pretty heavy optimization, it runs on an old CE in 59 seconds and just over 43 with reduced wait states. Haven't tried it on a rev M. I did use finance variables a little bit but I didn't over-do it like the first time, I only used them in the places where it made the most sense. I'm sure I could easily slice off another 2 seconds just by replacing everything with finance variables. Note the the times I stated were without the minimap.

Code:
ClrDraw
BackgroundOn DarkGray
RED
Line(3,~3,3,~52,Ans,1
Line(3,~3,52,~3,Ans,1
Line(3,~52,52,~52,Ans,1
Line(52,~3,52,~52,Ans,1
For(B,0,N-1
   For(A,0,N-1
      [A](A+1,B+1
      Ans-13(Ans=25)-2(Ans=20
      Pt-On(3A+5,~3B-5,1,Ans
   End
End
For(A,1,Brown
   ~80-2(A-1->S
   132-6A->T
   For(B,1,Brown
      [A](B,A)-19->V
      Brown+2(Ans<2)+3(Ans=2->I%
      Black-2(Ans=LtBlue->O
      If V>2
      I%+6randInt(0,1->I%
      T+6B->|N
      S-B2-2+6(V-1->Z
      S-B2+6V-2
      For(I,Z,Ans,2
         Line(|N-5,I,|N+5,I,I%
      End
      Line(|N-2,Ans+1,|N+2,Ans+1,I%,1
      If V>2 and I%!=MedGray
      Then
         For(I,0,2
            Line(|N-5+2I,Ans-I,|N+2I,Ans+1,Green
         End
      End
      Line(|N,Z-2,|N,Ans-2,O,1
      For(I,~6,6,Black
         Line(|N+I,Z,|N,Z-2,O,1
         Line(|N+I,Ans,|N+I,Z,O,1
         Line(|N,Ans+2,|N+I,Ans,O,1
         Line(|N+I,Ans,|N,Ans-2,O,1
      End
   End
End

Notice that I only generate a random number if V>2. My strat is to just draw less lines, which seems to be very effective.
KosmicCyclone wrote:
The download in the github doesn't include the display program

When you download TERRAIN.8xg and send it to your calculator, it contains both the DISPLAY program and the GENERATE program, so I'm not sure how you're having that issue.

I updated the GitHub and download with mr womp womp's optimizations, but I made a few changes like keeping the camera angle variable R that mr womp womp threw away, and made sure the grass still went down the dirt block a tiny bit.


Code:
ClrDraw
2->R
16->N
BackgroundOn DARKGRAY

//Draw MiniMap
RED
Line(3,~3,3,~52,Ans,1
Line(3,~3,52,~3,Ans,1
Line(3,~52,52,~52,Ans,1
Line(52,~3,52,~52,Ans,1
For(B,0,N-1
   For(A,0,N-1
      [A](A+1,B+1
      Ans-13(Ans=25)-2(Ans=20
      If Ans>25:RED
      Pt-On(3A+5,~3B-5,1,Ans
   End
End

//Draw Isometric Terrain
For(A,1,BROWN //substituting values in For loops with colors
   ~80+20(R-2)-R(A-1->S
   132-6A->T
   For(B,1,BROWN
      [A](B,A)-19->V
      BROWN+2(Ans<2)+3(Ans=2->I%
      BLACK-2(Ans=LTBLUE->O
      If V>2
      I%+6(rand>.5->I%
      T+6B->|N
      S-BR-R+6(V-1->Z
      S-BR+6V-R
      
      //Fill Box
      For(I,Z,Ans,2
         Line(|N-5,I,|N+5,I,I%
      End
      Pt-Off(|N-5,Z-R+1,4
      Pt-Off(|N+5,Z-R+1,4
      Line(|N-R,Ans+R-1,|N+R,Ans+R-1,I%,1

      //Draw Grass
      If V>2 and I%!=MEDGRAY
      Then
         For(I,0,2
            Line(|N-5+2I,Ans-I,|N+2I,Ans+1,GREEN
         End
         Line(|N,Ans-3,|N+6,Ans+R-3,GREEN,1
      End
      
      //Draw Main Vertical Edge
      Line(|N,Z-R,|N,Ans-R,O,1

      //Other Edges
      For(I,~6,6,Black
         Line(|N+I,Z,|N,Z-R,O,1
         Line(|N+I,Ans,|N+I,Z,O,1
         Line(|N,Ans+R,|N+I,Ans,O,1
         Line(|N+I,Ans,|N,Ans-R,O,1
      End
   End
End


The run speeds (including minimap time) on my calculator are:
1:03 for an only water world
1:10 for your average generated world
1:22 for an only grass world

EDIT: I tried making a snow biome for fun:

Inb4 people ask for mobs!

The snow looks great btw.
Looks nice!

We need mods now Razz
Also, lucky that Minecraft doesn't normally render like that
MASSIVE update incoming!

No, I didn't completely redo the renderer, but I did make some optimizations as best I could to it, like grass/snow no longer overhangs. I think this helps with speed just a tiny bit. I did also add an option to pick between the stones (aka height map colors) or grass or snow for the renderer. And even another optimization, I removed the Pt-Off commands. I did try adding conditionals earlier to see if I could not draw some of the lines on the edges of the cube, but the conditionals actually ended up making the program slower (go figure).

I calculated the times for a bunch of different worlds on my new version, even an all water world and I happened to get about 1:07 every time. On an all grass/snow world, I got 1:21, and also for some funny reason I got 1:23 instead of 1:07 on a normal world when my calculator was plugged in and charging.

Ok, but now for the more important stuff: I spent the night making the main menu and even the height map editor! The whole thing is all one big program now located in TERRAIN.8xp. Check out the editor:



This works really well Smile I also made a minor change to the generator where instead of entering 0 to generate a random seed, you can punch in the imaginary i. This is so you can have a seed of 0.

Here's a full run-through:


The GitHub is up to date, and now I'm going to go sleep a good bit and get some outdoors time later.
A few ideas:
Raise the max height limit
Add the option to fill in overhangs
Create an underground system
Add the option to remove lines
Here is the optimized rendering portion, it'll run consistently in 55s-58s on my pre-A.

Code:
If not(C
"Yellow-(Ans<2)+V(Ans>1)-13(Ans=6->|u
If C=1
"Brown+2(V<2)+3(V=2->|u
If C=2
"Brown+2(V<2->|u
For(A,1,Brown
   ~78-2A->S
   132-6A->T
   For(B,1,Brown
      [A](B,A)-Yellow->V
      |u->I%
      Black-2(Ans=LtBlue)+Red(Ans=Black->O
      T+6B->|N
      S-2B+6V-8->Z
      S-2B+6V-2
      Pt-On(|N-3,Z+3,2,O
      Pt-On(|N+3,Z+3,2,O
      Pt-On(|N-2,Z+2,2,I%
      Pt-On(|N+2,Z+2,2,I%
      Pt-On(|N,Z+4,2,I%
      If I%=Brown
      Then
         Pt-On(|N,Ans,1,8+6C
         Line(|N-4,Ans,|N+4,Ans,8+6C
      End
      Pt-Off(|N-5,Z-R+1,4
      Pt-Off(|N+5,Z-R+1,4
      Line(|N,Z-2,|N,Ans-2,O,1
      For(I,~6,6,Black
         Line(|N+I,Z,|N,Z-2,O,1
         Line(|N,Ans+2,|N+I,Ans,O,1
         Line(|N+I,Ans,|N,Ans-2,O,1
      End
   End
End

Using system vars for Z and O would save approx 3.5 seconds, but I'll leave that up to you to decide Rolling Eyes
Also, for line 27 100/(2N-2->G, should be 50/(N-1->G Wink
What's with all those Pt-On( commands O__O

I'll try it though, also good idea using |u

KosmicCyclone wrote:
A few ideas:
Raise the max height limit
Add the option to fill in overhangs
Create an underground system
Add the option to remove lines

Can't promise anything here, I’ll see what I can do though. The height limit can be changed a bit if it doesn’t go off screen I guess, but regarding your underground suggestion I’m not sure how that would work or what that would look like really.

EDIT: WOW ok mr womp womp, I used your code and also changed var O and Z to finance variables PV and FV. I got a whopping 51-52 seconds consistently on 3 different tests, 56 seconds when everything is grass. That’s a great improvement and is actually pretty dang fast.

(Note, all of my times I’ve been measuring do include the minimap as well)

Is there any reason you aren’t using for loops with some of the pt-on commands? Are they slower?
Michael2_3B wrote:
What's with all those Pt-On( commands O__O

I'll try it though, also good idea using |u

KosmicCyclone wrote:
A few ideas:
Raise the max height limit
Add the option to fill in overhangs
Create an underground system
Add the option to remove lines

Can't promise anything here, I’ll see what I can do though. The height limit can be changed a bit if it doesn’t go off screen I guess, but regarding your underground suggestion I’m not sure how that would work or what that would look like really.

EDIT: WOW ok mr womp womp, I used your code and also changed var O and Z to finance variables PV and FV. I got a whopping 51-52 seconds consistently on 3 different tests, 56 seconds when everything is grass. That’s a great improvement and is actually pretty dang fast.

(Note, all of my times I’ve been measuring do include the minimap as well)

Is there any reason you aren’t using for loops with some of the pt-on commands? Are they slower?


Adding loops will usually always make it slower if you’re just converting repetitive code into a loop of one or two commands with incrementing arguments or something. It’s usually never done just because the space-saving benefit outweighs the time benefit.
Sam wrote:
Adding loops will usually always make it slower if you’re just converting repetitive code into a loop of one or two commands with incrementing arguments or something. It’s usually never done just because the space-saving benefit outweighs the time benefit.

Ah. Well in this case, saving time is better than saving space.

I updated the Github Good Idea
Yeah, the Pt-On commands are just quite a bit faster than Line() which is horrendously slow, so I used a few Pts to draw out the desired shapes, and it turns out you can do it with less Pt commands than lines. Also, yeah adding in the loop just makes things slower, if we were golfing for size then of course we could do that, but its getting called 256 times Wink
Regarding the use of |u, I noticed that we were checking the value of C 256 times, but it'll never change while rendering, so there's no point in re-checking it each time.
EDIT:
I got it down to around 42 seconds without grass and 44 seconds with grass. I did unroll the for loop for the Line commands, which bloats the program a little so I golfed a couple other parts of the program to compensate. Basically, I use a list to pre-compute the colors so that its done 6 times instead of 256 (once for each color). I did the same thing with the border colors. I also added a bit of finance vars for some extra spice and slightly re-organized some maths to be a bit faster. I also found that the 2 Pt-Offs could be changed into 1 Pt-On, which is faster by drawing the points a bit differently.

Code:
0->Xmin:264->Xmax
~164->Ymin:0->Ymax
Float
GridOff:AxesOff
16->N
Lbl 0
Menu("        Terrain CE        ","Generate",1,"Edit",2,"Render",3,"View Graph",4,"Quit",5
Lbl 1
ClrHome
Output(10,1,"(Enter [i] for random seed)
Input "Seed:",theta
If imag(theta:Then
   int(randstartTmr->theta
   Ans->rand
   Output(1,6,Ans
Else
   theta->rand
End
DelVar [A]{N,N->dim([A]
randInt(20,25->[A](1,1
~1->C
50/(N-1->G
Ans->P
Output(9,1,"Generating...
For(A,1,N
   Output(10,1,toString(int(P))+"%
   P+G->P
   For(B,1,N
      If C=~1
      DelVar C2->B
      randInt(~1,1
      If A=1
      Then
         Ans+[A](A,B-1
      Else
         If A>1 and B=1
         Then
            Ans+[A](A-1,B
         Else
            If A>1 and B>1
            Then
               If [A](A,B-1)!=[A](A-1,B
               Then
                  int(median({[A](A,B-1),[A](A-1,B
               Else
                  Ans+[A](A,B-1
      End:End:End:End
      If Ans<20:20
      If Ans>25:25
      Ans->[A](A,B
End:End
Output(9,1,"Smoothing...
If [A](1,1)!=[A](2,1) and [A](2,1)=[A](1,2
[A](2,1)->[A](1,1
If [A](1,N)!=[A](2,N) and [A](2,N)=[A](1,N-1
[A](2,N)->[A](1,N
If [A](N,1)!=[A](N,2) and [A](N,2)=[A](N-1,1
[A](N,2)->[A](N,1
If [A](N,N)!=[A](N-1,N) and [A](N-1,N)=[A](N,N-1
[A](N-1,N)->[A](N,N
For(C,2,N-1
   If [A](1,C)!=[A](1,C-1) and not(variance({[A](1,C-1),[A](2,C),[A](1,C+1
   [A](1,C-1)->[A](1,C
End
For(C,2,N-1
   If [A](C,1)!=[A](C-1,1) and not(variance({[A](C-1,1),[A](C,2),[A](C+1,1
   [A](C-1,1)->[A](C,1
End
For(C,2,N-1
   If [A](C,N)!=[A](C-1,N) and not(variance({[A](C-1,N),[A](C,N-1),[A](C+1,N
   [A](C-1,N)->[A](C,N
End
For(C,2,N-1
   If [A](N,C)!=[A](N,C-1) and not(variance({[A](N,C-1),[A](N-1,C),[A](N,C+1
   [A](N,C-1)->[A](N,C
End
For(A,2,N-1
   Output(10,1,toString(int(P))+"%
   P+G->P
   For(B,2,N-1
      If [A](A,B)!=[A](A-1,B) and not(variance({[A](A-1,B),[A](A+1,B),[A](A,B-1),[A](A,B+1)
      [A](A-1,B->[A](A,B
   End
End
Goto 3
Lbl 2
ClrDraw
BackgroundOn DarkGray
For(A,0,3
   Line(122+116(A=3),~23-116(A=1),238-116not(A),~139+116(A=2),Red
End
TextColor(Black
Text(150,0," New
Text(150,48," Load [A]
Text(150,168," Render
Text(150,227," Exit
Repeat sum(Ans={11,12,15,45
   getKey
End
Ans->K
If sum(Ans={15,45:Goto 0
Lbl 11
If K=11
Then
   DelVar [A]{N,N->dim([A]
   Fill(20,[A]
End
For(A,0,N-1
   For([recursiven],0,N-1
      [A]([recursiven]+1,A+1
      Ans-13(Ans=25)-2(Ans=20
      Pt-On(7[recursiven]+128,~7A-29,1,Ans
      Pt-On(7[recursiven]+128,~7A-29,2,Ans
   End
End
Text(56,2," Use arrow keys
Text(68,2," for cursor
Text(80,2," and +-
Text(92,2," to change block
DelVar ADelVar B
Repeat sum(K={11,14,15,45
   Pt-On(7B+128,~7A-29,Red
Repeat Ans:getKey:End
   Ans->K
   [A](B+1,A+1
   Ans+(K=95)(Ans<25)-(K=85)(Ans>20->C
   Ans->[A](B+1,A+1
   Ans-13(Ans=25)-2(Ans=20
   Pt-On(7B+128,~7A-29,Ans
   Pt-On(7B+128,~7A-29,2,Ans
   A-(K=25)(A>0)+(K=34)(A<15->A
   B-(K=24)(B>0)+(K=26)(B<15->B
End
If K=11:Goto 11
If K=14:Goto 3
Goto 0
Lbl 3
ClrHome
Repeat Ans
   Disp "Stones:0 Grass:1 Snow:2
   Input C
   max(C={0,1,2
   If not(Ans
   Disp "Invalid Entry.
End
ClrDraw
BackgroundOn DarkGray
For(A,0,3
   Line(3+49(A=3),~3-49(A=2),52-49not(A),~52+49(A=1),Red,1
End
{LtBlue,LtGray,MedGray,Gray,DarkGray,Black->L1
For(B,0,Orange
   For([recursiven],0,Orange
      Pt-On(3[recursiven]+5,~3B-5,1,L1([A]([recursiven]+1,B+1)-Yellow
   End
End
If C
{LtBlue,Yellow-3(C=2),Brown,Brown,Brown,Brown->L1
Black-2(L1=LtBlue)+Red(L1=Black->L2
8+6C->C
For(A,1,Brown
   ~83-2A->S
   132-6A->T
   For([recursiven],1,Brown
      T+6[recursiven]->|N
      [A]([recursiven],A)-Yellow->PMT
      L1(PMT->I%
      L2(PMT->PV
      S-2[recursiven]+6PMT->FV
      FV+3
      Pt-On(|N-3,FV,2,PV
      Pt-On(|N+3,FV,2,PV
      Pt-On(|N-2,FV,2,I%
      Pt-On(|N+2,FV,2,I%
      Pt-On(|N,FV+1,2,I%
      Pt-On(|N,FV-3,1,I%
      If I%=Brown
      Then
         Pt-On(|N,Ans,1,C
         Line(|N-4,Ans,|N+4,Ans,C
      End
      Line(|N,FV-5,|N,FV+1,PV,1
      Line(|N-6,FV-3,|N,FV-5,PV,1
      Line(|N+6,FV-3,|N,FV-5,PV,1
      Line(|N,FV+5,|N-6,Ans,PV,1
      Line(|N,FV+5,|N+6,Ans,PV,1
      Line(|N-6,Ans,|N,FV+1,PV,1
      Line(|N+6,Ans,|N,FV+1,PV,1
   End
End
Lbl 4
DispGraph
Repeat sum(getKey={21,45,105
End
Goto 0
Lbl 5
Return
Those are incredible optimizations, I don't know why you unrolled the for loop for the line commands though (I guess having such similar line commands like that is rather ugly to me). I put those back in the loop and I still ended up getting a time of 40-42 seconds, even with grass. Once again really great work! You are literally coauthor status at this point.
Michael2_3B wrote:
Those are incredible optimizations, I don't know why you unrolled the for loop for the line commands though (I guess having such similar line commands like that is rather ugly to me). I put those back in the loop and I still ended up getting a time of 40-42 seconds, even with grass. Once again really great work! You are literally coauthor status at this point.

Yeah its ugly but its fast

Apologies for the slight delay on the GitHub repo, I've been working on Fruit Ninja recently. I just updated the Terrain CE repository though.

I (reluctantly) included womp's unrolled line commands, added a generate button to the map editor to access the generator, and made a few other tiny changes. Once again, I'm getting 40-42 seconds now, which is a significant improvement from the original 1:25-2:23. Thanks womp!

I have yet to add any game-like features, I'll update you if I do any of that.

My next goal is to change the save format, I'll probably use a list.

EDIT: I updated the code and repository to use a list, which runs at about the same speed as the previous matrix version, if not one second faster. Maybe it's not really worth much, but it does save space.
I have now made it so that you can render the map from the front, back, left, or right using the buttons below the graph screen. 360 degrees would be cool, but not very feasible in TI-Basic.



And I've updated the GitHub.
I have gone ahead and uploaded the current version to the Cemetech Archives, which I am calling version 1.0! I would like to expand it a bit and perhaps make it so you can edit and render all blocks in the 3d space, to render your own 3d models or whatever, so that might be in a future version. Now that I think about it, I could also maybe add trees...

Anyways, here's the archives link: http://ceme.tech/DL2008
  
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 2 of 2
» 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