I'm not sure that the Δlist( method should be the primary routine used in this page. Even though it saves two bytes it's a great deal slower than the usual (K=34)-(K=25). I understand that for things such as menus the speed isn't as important and smaller size is preferable, but I think most people viewing this page will be applying these techniques in character movement in games (this page is under the "Games" category).
There already is a Custom Menu page so we can add in the use of Δlist( there (where it will probably have it's largest application).
Good point. I plan on putting both types of movement techniques because I still use the regular algebraic way a lot, and it would be ideal to include it into the page as an alternate technique. And I think the Δlist( way saves more than two bytes. I think it saves about 6 for each implementation, but it is indeed slower.
Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me
"(K=25)-(K=34)" is 13 bytes (12 if you don't close the parenthesis) and "sum(Δlist(K={25,34}))" is 14 bytes (11 if you don't close the bracket and parentheses). So if you close parentheses it's one byte more, and if you don't it saves one byte.
Unless you include some of the boundary test stuff.
:A-(K=25 and A>1)+(K=34 and A<8
22 bytes
:min(8,max(1,A+sum(ΔList(K={25,34
19 bytes
So, you actually save 3 bytes, and for one with each coordinate (A,B), you save a total of six. The downfall to the code is the speed, so a speed optimization should not use this code. The reason I am closing all the parentheses and brackets in the starter kit is because, well, I found it that way, and two, I figured that to someone with little or no programming experience, it would be easier to learn with the closed brackets and just teach the optimization later.
Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me
Sorry for replying to a 6.5 year old post, but what you said isn't 100% correct.
:startTmr->T
:1->P
:For(A,1,2000
:25+9(randInt(0,1->K
//code
:End
:checkTmr(T
In the place of //code, I put:
:min(8,max(1,P+sum(Δlist(K={25,34->P
19 bytes; 67/68 seconds
:min(8,max(1,P+(K=34)-(K=25->P
20 bytes; 60/61 seconds
The second one is the same as your first, I don't know why you didn't use min(max( for that one too, because you waste 2 bytes by combining the K= and the A conditional.
So when you use the Δlist method, you only save 1 byte, not 3, while slowing down the program by 10%.
Isn't this for people who want to learn basic ? I remember learning it and I wouldn't have understand a word from A-(K=25 and A>1)+(K=34 and A<8
First, there are optimizations and it's the last chapter of this big tutorial and second, the Graph Screen (which is 4th chapter), is barely explained and here's only one example of a line of code thrown in the first steps of learning basic when you don't even know about Graph Screen by now:
ZStandard
104→Xmax
72→Ymax
ZInteger
We should review a little these pages to not confuse people who start.
I am in complete agreement with those who say that introducing the full optimized movement loop in the starter kit is too much. However, we also don't want to be teaching people bad programming techniques. My solution would be to simply lay out what the numbers in the code represent so that learners can put in whatever variables they require, while directly pointing them to the main resource page which already does an in depth explanation of the code. This way those who want to just use it can just use it, and those who want to understand it can understand it. I will also remove the graphscreen stuff as it isn't relevant at this point in the tutorial.
I agree that the Δlist( method is a bit too intimidating for a beginner. They'd be likely to just copy the code without actually learning what it is that they're telling the calculator to do. If a situation came up that isn't explicitly explained (like complicated boundaries or something), they'd be stuck with no ability to solve the problem. The piecewise method is still my preferred movement method in most cases, and it's fairly straightforward to understand once you know the calculator's Boolean logic. Still it wouldn't hurt to show them the absolute, bare-bones basics—maybe something like
:Repeat K
:getKey→K
:End
:If K=24
:X-1→X
:If K=26
:X+1→X
while thoroughly explaining the thought process. e.g. The repeat loop runs until a key is pressed, storing that value as K. We use X to represent the coordinates of our object. Pressing the left arrow shifts the coordinate negatively (to the left), and the right arrow shifts it positively (to the right).
Then introduce the piecewise optimization, with a link to the page about piecewise operations.
Using piecewise functions is faster and makes more sense. Saving a few bytes doesn't really matter if it makes your program slower. Also, the Δlist( method is much more confusing.