Here's a challenge I've been thinking about. Who can create the SMALLEST movement loop that only uses Ans. It could actually be a quite helpful loop. I'm working on my version as I write this, but I'll wait to put it up until I see some good ideas.
edit: on the homescreen or graphscreen, whichever you can make smaller. Also, the routine must be fully functional. No flashing, lack of erasing, or screen exiting.
Wait, what's a movement loop? Like on the homescreen?
yes, like that thing at the beginning of the movement in maps tutorial. You just move a guy around the screen with the arrow keys and he can't go off the screen.
didnt test this but..
0->xmin
0->xmin
94/3->xmax
0.062/3->ymax
2,.02
repeat 0
repeat ans(2)
{ans,getkey
end
//code is split cuz of instanse length...
pt-off(ans(1),fpart(ans(1)),2
ans(1)+(ans(2)=24 and ans(1)<93)-(ans(2)=26 and ans(1)>1)
...+E-3((ans(2)=25 and fpart(ans(1))<.062)
...-( ans(2)=34 and fpart(ans(1))>0
pt-on(ans(1),fpart(ans(1)),2
end
171 bytes (bit diferent than this version)
i think that works
impressive use of window settings if you ask me
how to do code blocks?
Okay, I guess I'll start out with 138 bytes. (The codesize displayed in the MEM menu, minus the length of the title of the program.)
:ClrHome
:{8,4
:Repeat 0
:Repeat min(Ans
:{Ans(1),Ans(2),getKey
:End
:Output(Ans(2),Ans(1),"_
:{max(1,min(16,Ans(1)-(Ans(3)=24)+(Ans(3)=26))),max(1,min(8,Ans(2)-(Ans(3)=25)+(34=Ans(3
:Output(Ans(2),Ans(1),"+
:End
good, but it can be improved still.
Well I made a version that was only 6 lines long, but it erased the cursor every frame, which made everything really flickery. I assume that wouldn't be a satisfactory movement engine.
you can do it in 5
Well, post yours and lets see what you do.
well, mine (see post 4…. lol) is 171 byes atm (graphscreen)
mine's 115. I'm sure somebody can figure it out.
0:Repeat 0
Ans+16−1iPart(2.5tan(50r−20rsum(cumSum(getKey={34,24,26,25
Output(int(Ans)+1,16fPart(Ans)+1,1
End
good job weregoose, except with that it isn't even possible to erase without that flashing effect and you are allowed to exit the screen and crash the program.
Didn't post it to meet the challenge requirements. ;)
It is actually a genius program being only 67 bytes, and you can somewhat fix the screen exit problem.
That gives domain errors if you try to exit the screen from the top or bottom. Plus, it doesn't erase the last position of the thing, leaving a trail, unlike the example on the movement page. Edit: never mind, that's been discussed.
That's pretty cool, though. Did you just use trial and error to find the right numbers for the iPart(tan( stuff?
Two similar programs are:
:0
:Repeat 0
:Ans+8-1sum({-8,-1,8,1}(getKey=24,25,26,34
:Output(1+8fPart(Ans),1+int(Ans),1
:End
:1.1
:Repeat 0
:Ans+sum({-1,-.1,1,.1}(getKey=24,25,26,34
:Output(10fPart(Ans),int(Ans),1
:End
The first doesn't wrap horizontally, but it does wrap vertically; plus it takes 4 less bytes. The second doesn't wrap at all, but takes 5 less bytes.
Edit: another version of your first program:
:0:Repeat 0
:Ans+16-1sum({-1,-16,1,16}(getKey={24,25,26,34
:Output(1+int(Ans),1+16fPart(Ans),1
:End
This one replicates the horizontal wrap and I believe has the same size.
Now 109 bytes – no crashing, still the odd wrap, and also hard to follow when holding an arrow key down.
0:Repeat 0
max(0,min(8−16−1,Ans+16−1iPart(2.5tan(50r−20rsum(cumSum(Ans(1)={34,24,26,25
{getKey,Ans(2
Output(int(Ans(2))+1,16fPart(Ans(2))+1,sub(" 0",not(Ans(1))+1,1
End
I used a trivariate guess-and-check, but it wasn't hard to step through the values because they had to maintain the same proportion to one another to keep both the signs and values cyclic; it needed to return the numbers -16, -1, 1, and 16 in some order, and then it had to return a zero for when a key wasn't pressed.
It moves just like a text editor – try pressing down at the bottom or up at the top.
Ah, I see. Did you intend it to move that way or did it just come out that way?
BTW, using sum({-1,-16,1,16}(Ans(1)={24,25,26,34 instead of iPart and tangent makes it run faster, improving visibility when a key is held down, on my TI-84+ SE. Another way to improve visibility is to change the keys, so that the key press isn't repeated when a key is held down.
Again, pretty clever. Nice.
That's the way it moved when I made a program like this years ago, and it's how I was expecting it to move today. It makes use of a simple congruence with modulus 16. 'nuff said.
Ok. Now that someone's made something better than what I made, I'll show what I made. I found that same sub( routine on my own too. Weird, huh? 115 bytes.
:{0,1,1
:While 1
:{getKey,min(8,max(1,Ans(2)+(Ans(1)=34)-(Ans(1)=25))),min(16,max(1,Ans(3)+(Ans(1)=26)-(24=Ans(1
:Output(Ans(2),Ans(3),sub(" 1",1+not(Ans(1)),1
:End