how should I make tthe graphics?
ascii art
 25%  [ 5 ]
Xlib
 75%  [ 15 ]
Total Votes : 20

spud2451 wrote:
1702 bytes
Is that better Kerm
"Is that better, Kerm?" is better, but it's an improvement. Don't worry, we'll mold you over time, and you'll be happy we did. Qazz42 is my poster child on someone who was nearly unintelligible when he first joined and now constructs perfectly well-written posts.
That are quite a lot of programs used! Shock
Here's the source


TICRAFT/The main TI-Craft program

Code:

prgmTICSETUP
:6→X
:1→Y
:0→A
:10→H
:10→M
:
:While A≠22
:
:0→A
:
:While A=0
:getKey→A
:End
:
:0→[J](Y,X)
:
:
:0→θ
:X→K
:Y→L
:
:If A=25 and Y>2
:Then
:Y-1→Y
:[J](Y,X)→θ
:2→[J](Y,X)
:real(2,9,0,0,8,12,0,12,0,8,9,0,8,1
:0→A
:For(N,1,25
:If A=0
:Then
:getKey→A
:End
:End
:Y→L
:X→K
:0→[J](Y,X)
:End
:
:0→N
:
:If A=24 and X>1
:Then
:X-1→X
:End
:
:If A=26 and X<12
:Then
:X+1→X
:End
:
:If A=34 and Y<7
:Then
:Y+1→Y
:End
:
:If A=73 or A=93 or A=82 or A=84
:Then
:prgmTICBLKPL
:End
:
:If A=21
:Then
:prgmTICCRAFT
:End
:
:If A=31
:Then
:prgmTICINVTY
:End
:
:If M<0
:Then
:K→X
:L→Y
:End
:
:[J](Y,X)→W
:
:If W=1 or θ=1
:Then
:1→[H](1,1)
:∟INVTY(1)+1→∟INVTY(1)
:If W=1 and θ=1
:Then
:∟INVTY(1)+1→∟INVTY(1)
:End
:End
:
:If W=3 or θ=3
:Then
:4→[H](1,2)
:∟INVTY(2)+4→∟INVTY(2)
:If W=3 and θ=3
:Then
:∟INVTY(2)+4→∟INVTY(2)
:End
:End
:
:If Y<8:Then
:prgmTICGRAV
:End
:
:2→[J](Y,X)
:
:real(2,9,0,0,12,8,0,12,0,8,9,0,8,1)
:
:If H≤0
:Then
:Goto X
:End
:
:End
:Lbl X


TICSETUP/game setup

Code:

:1→W
:
:{3,3}→dim([I])
:
:{8,12}→dim([J])
:{3,9}→dim([H])
:
:7→dim(∟INVTY)
:Fill(0,∟INVTY)
:
:Fill(0,[J])
:
:Fill(0,[H])
:
:Fill(0,[I])
:
:For(N,1,8
:For(I,1,12)
:If N>2
:Then
:prgmTICTERRN
:End
:If I≤10
:Then
:5→[J](1,I)
:End
:1→[J](8,I)
:0→[J](2,I)
:End
:End
:
:2→[J](2,6)
:real(2,9,0,0,12,8,0,12,0,8,9,0,8,1


TICTERRN/terrain maker

Code:

:If W=0:Then
:randInt(1,38)→A
:End
:
:If W=1:Then
:randInt(1,25)→A
:End
:
:If A<22:Then
:
:If W=0:Then
:0→[J](N,I)
:Else
:randInt(1,5)→A
:If A<5:Then
:1→[J](N,I)
:Else
:
:3→[J](N,I)
:End
:End
:
:Else
:
:If W=0:Then
:1→W
:Else
:
:0→W
:End
:
:End


TICGRAV/gravity

Code:

:If W=0:Then
:randInt(1,38)→A
:End
:
:If W=1:Then
:randInt(1,25)→A
:End
:
:If A<22:Then
:
:If W=0:Then
:0→[J](N,I)
:Else
:randInt(1,5)→A
:If A<5:Then
:1→[J](N,I)
:Else
:
:3→[J](N,I)
:End
:End
:
:Else
:
:If W=0:Then
:1→W
:Else
:
:0→W
:End
:
:End


TICBLKPL/block placing

Code:

:X→D
:Y→E
:
:If A=73
:Then
:E-1→E
:End
:
:If A=93
:Then
:E+1→E
:End
:
:If A=82
:Then
:D-1→D
:End
:
:If A=84
:Then
:D+1→D
:End
:
:[J](E,D)→W
:
:If W≠1 and W≠3 and ∟INVTY(1)>0
:Then
:1→[J](E,D)
:∟INVTY(1)→W
:W-1→∟INVTY(1)
:End
:
:
:
:real(2,9,0,0,12,8,0,12,0,8,9,0,8,1
:
:


TICINVTY/inventory

Code:

:1→S
:1→T
:0→U
:0→V
:
:real(0,1
:
:real(2,7,0,0,9,3,0,9,0,3,9,0,8,1
:
:real(1,U,V,1,8,9,10,0,3,0,1
:
:0→A
:
:While A≠21
:
:0→A
:
:While A=0
:getKey→A
:End
:
:If A=24 or A=25 or A=26 or A=34
:Then
:
:real(1,U,V,1,8,9,10,0,3,0,1
:
:If A=24 and S>1
:Then
:S-1→S
:End
:
:If A=26 and S<9
:Then
:S+1→S
:End
:
:If A=25 and T>1
:Then
:T-1→T
:End
:
:If A=34 and T<3
:Then
:T+1→T
:End
:
:(S-1)*8→U
:(T-1)*8→V
:
:real(1,U,V,1,8,9,10,0,3,0,1
:
:
:End
:End
:
:[H](T,S)→Z


TICCRAFT(crafting not finished)

Code:

:2→O
:2→P
:
:real(0,1
:
:{3,3}→dim([I]
:
:Fill(0,[I]
:
:While A≠21
:0→A
:While A≠0
:getKey→A
:End
:
:O→Q
:P→R
:
:
:If A=



ya its a lot Very Happy Graphing Calculator
Tons of optimization suggestions for you!

1) :If W=0:Then:1→W:Else:0→W:End. There are two things you could do with this, either not(W)->W, or 1-W->W. Learn to think like this, how you could use simple math to do what you need instead of conditionals. My book will have a lot of such tricks for you. Wink

2) :0→V. Almost always use DelVar V for setting variables to zero! As an added bonus, :0->A:0->B:0->C becomes DelVar ADelvar BDelvar C

3) :If A=73:Then:E-1→E:End. When there's only one instruction inside Then/End, remove them: :If A=73:E-1->E

4) :If A=73:E-1→E:If A=93:E+1→E. More math tricks: E-(A=73)+(A=93->E

5) TICCRAFT has some incoming bugs
Kerm you said that it has some incoming bugs. What are they?
Your first program is labelled "TICRAFT/The main TI-Craft program", but then it starts off with "prgmTICSETUP" ... did you paste the wrong code, or did you just put the wrong name?

Anyway, I have some more optimizations for you (and I will pretend that the first program you listed is "TICRAFT") ... sorry, I kinda went to town on this:

((prgmTICRAFT))

Replace: "10→H:10→M"
With: "10→H:H→M"
- Saves 1 byte

Replace: "0→A:While A=0:getKey→A:End"
With: "Repeat A:getKey->A:End"
- A "Repeat X" is the same as "While not(X)", but has the bonus that it will ALWAYS loop at least once. This means that you do not have to set the value of A first.
- "Repeat A≠0" is the same as just "Repeat A". Likewise, "While A=0" is the same as "While not(A". The reason is that anything that wants a condition ("While", "If", etc.) just checks to see if the answer is 0 or not. Something "A=B" gives 1 if it's true, and 0 if it is false. This is why Kerm's #4 suggestions works (you can multiply and add conditional statements because they will be 0 or 1; and adding 0*something makes no change).
- Saves 6 bytes

Replace:

Code:
:If W=1 or θ=1
:Then
:1→[H](1,1)
:∟INVTY(1)+1→∟INVTY(1)
:If W=1 and θ=1
:Then
:∟INVTY(1)+1→∟INVTY(1)
:End

With:

Code:
:If W=1 or θ=1
:1→[H](1,1)
:∟INVTY(1)+(W=1)+(θ=1)→∟INVTY(1)

- The condition for "1→[H](1,1)" is the same (only happens when W=1 or θ=1).
- As for ∟INVTY, you store 1 to it if either W or θ is 1, and again if they are BOTH 1. This is the same as storing a 1 for both of them individually. This uses the technique in #4 of Kerm's last post.
- ...The main idea is that, if there are multiple parts of code that are almost the same, find a way to combine them and use a variable or expression to make the same piece of code work for different situations. This is something for everyone to figure out how to do in different situations.
- The reason you did not combine here was because in one of the situations you were storing to [H], but not in the other (makes sense). Some times if you pull the "odd ball" instruction/chunk out and do it separately, the rest can then be collapsed into one chunk (and sometimes is more optimized that way ... this time it saves 25 bytes).

...You can do something similar to replace:

Code:
:If W=3 or θ=3
:Then
:4→[H](1,2)
:∟INVTY(2)+4→∟INVTY(2)
:If W=3 and θ=3
:Then
:∟INVTY(2)+4→∟INVTY(2)
:End

With:

Code:
:If W=3 or θ=3
:4→[H](1,2)
:∟INVTY(2)+4(W=3)+4(θ=3)→∟INVTY(2)


Suggestion for: "If H≤0:Then:Goto X:End::End:Lbl X" (end of program)
It looks as though you are trying to break out of the "While" around most of the program by jumping to "Lbl X". I suggest doing one of two things (but not both):
- putting the "exit the loop" condition as part of the "While" condition in the first place ("While A≠22" becomes "While A≠22 and H>0")
- Instead of jumping out of the loop, set a condition that will cause the loop to exit naturally ("goto X" becomes "22→A").
The reason for this is that (1) not having labels in the program makes them smaller, and (2) it takes longer for the program to jump to labels, because it must scan the entire program for the label each time, and (3) using loops instead of labels (where possible) makes the code more logical to read because you put the complete condition for the loop in one place. However, I admit that there are circumstances where using "goto" is just easier and quicker (e.g. when you can only determine this in the middle of the loop).

((TICTERRN))

Replace:

Code:
:If W=0:Then
:randInt(1,38)→A
:End
:
:If W=1:Then
:randInt(1,25)→A
:End

With: "If W=0 or W=1:randInt(1,25+13W→A"
- This is a bit tricky to throw at you right now, but if you can follow how that works out, it saves 16 bytes! ... this is Kerm's #4 again; it's an advanced technique, but is worth learning ... but can come later if it's a bit much for now. But DO learn it! Very Happy

((TICINVTY))

Replace: "(S-1)*8→U"
With: "8*(S-1→U"
- Swapping the order allows you to leave off the ending parenthesis. Not a huge optimization; but leaving off ending ")" or "]" or "}" etc. and removing "Then"s (where possible) and removing blank lines are things that can be done everywhere and add up to a lot of space saved in general ... this can be done later though, and will not affect your program speed by much anyway

((Other suggestions))

Instead of using "∟INVTY", you could just use L1,L2,...,L6. This would save you 5 bytes in EVERY place that that list is used (because the name has to be typed out). If you want to keep a custom list for saving information after the program is done, then you could copy the list into "∟INVTY" when the program quits, and copy "∟INVTY" into L1,...,L6 when it starts. This is not vital either, and can be optimized later; but it would save you a lot on program size.
  
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 5 of 5
» 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