@DJ_O - I wasn't really attacking, just commenting that lists are slower. Of course, with a list, you can do things that my code can't do - specifically, make sure that the food isn't generated on the snake body. But personally, I don't like them for speed reasons. I was comparing to Merthsoft because his is a really good standard to compete with. No disrespect meant. @Eiyeron - pxl tests. I move 2 pixels at a time, yes.
lol. On another note, testing the snake going from the far left to the far right of the screen - Merthsoft was in ~10 seconds, and mine was in ~13.5 seconds. Divide my time by 3 (points to pixels) and multiply by 2 (me going every other pixel), and mine is ~10% faster than his. I've shown that lists, even when not using calculations with them, are slower than static variables. but ticalc needs a collection not infested by 4 times as many snake games as other games... idk should I work on flushing this out, or should I move onto other things?
Oh wow... I would've expected numbers like 10,000, not 10,000,000. But more bytes = more space. It's a simple matter of multiplying by the base and adding. In BASIC, it's easy, right?
I've dealt with that pretty easily in Axe by using 2 bytes to store it. Just multiply the first byte by 256 and add. And voila, you have a range of 16 thousand.
1 byte int lists??!!?!?!? YES. That would be great. I usually use strings because they're just so much more memory efficient - lists temporarily during execution, then I translate them into strings for long term. Int arrays of 1 byte would be a dream come true.
Yeah, I actually downloaded that and another snake game before being disappointed at them using lists. imo lists are only useful temporarily due to the 9 bytes per element issue due to supporting 14 digits and imaginary numbers etc. - most of which don't get used (usually only ints are stored in them). I wish TI made it custom strings rather than custom lists. I'm not on Cemetech, but I'll try to see if I can find Weregoose there. (Does cemetech have PMs?) This is really just a test for speed. I'm going to test his code from 1 end of the screen to another end and multiply the time by 3 to compare with mine. (I'm pretty sure 3 should be the factor between pts to pxls). If mine is faster, I might flush it out with highscrores, making it look better, showing the score, more features etc.
EDIT: No disrespect meant to any of those authors, I swear! I just meant to that lists slow things down even though they are useful, and I wanted to make a faster version without lists, but not necessarily with all the features a list can help make. Slower doesn't mean worse, but my goal here is speed. I wasn't attacking their work at all. Sorry for coming across as disrespectful to them.
Oh lol, I thought it was homescreen from the pic. My bad for not reading your code, sorry! Regarding lists... I don't believe it will cause a slowdown. But I'm running out of memory, after downloading every CSE program on ticalc. And each element taking up 9 bytes, something like 5,200 elements would overflow, being pixel based. (80*260/4 cuz I'm doing every other pixel). You don't have that problem because you're using text, and it can't get that big. But for the pro players on mine... ERR:OVERFLOW - so I don't use lists.
Hi. I noticed Hayleia's BASIC snake game on the homescreen, and I wondered how fast it could be on the graphscreen. Made this today while seeking Weregoose's snake game code for help. (He posted code to it a while ago, and I've used it since, but idk how to contact him about it.) It uses a trick called the pathfinding tail eater. So no lists! :D Anyhow, here's the code, at 351 bytes:
Spoiler For the code:
::"SNAKE :ClrHome :ClrDraw :AxesOff :BackgroundOn WHITE :120→A :84→B :118→D :84→E :26→K :132→Xmax :Vertical Ans :‾Ans→Xmin :Vertical Ans :82→Ymax :Horizontal Ans :‾Ans→Ymin :Horizontal Ans :For(C,0,E9 :2randInt(2,128→F :2randInt(2,40→G :0 :Repeat K=45 or pxl-Test(B,A :If Ans :Then :E+2(pxl-Test(E+1,D)-pxl-Test(E-1,D→X :D+2(pxl-Test(E,D+1)-pxl-Test(E,D-1 :Pt-Off(D-132,82-E :Ans→D :X→E :End :Pxl-On(B,A,ORANGE :Pxl-On(B+(K=25)-(K=34),A+(K=24)-(K=26),ORANGE :Pxl-On(G,F,GREEN :getKey :If max(Ans={24,25,26,34,45 :Ans→K :A+2(K=26)-2(K=24→A :B+2(K=34)-2(K=25→B :End :If A=F and B=G :End :ClrDraw :ClrHome :Disp "SCORE:",C
Unfortunately, the snake is quite skinny due to me using pixels (necessary point-pixel usage to the pathfinding tail eater):
Ah, but with the most recent code, with your optimization of using DelVar ADelVar B instead of 1->A, A and B are now 0. It would've caused some problems with that first erasing output, but I moved that to the bottom. Now the first line in the loop is the min(max(stuff)), which will move it to 1. And even if C=34 or something, max(1,0+1) = 1.
DelVar ADelVar BClrHome Repeat Ans=45 max(1,min(16,A-(Ans=24)+(Ans=26→A // If Ans=24, max(1,min(16,0-1))=1. If Ans=26, max(1,min(16,0+1))=1. If otherwise, max(1,min(16,0))=1 still. Yay. max(1,min(8,B-(C=25)+(C=34→B //Same applies for C. The max(1,X) guarantees it, and putting A and B as 0 with DelVar makes it so that the maximum it can be from the beginning is 1, which is fine. :) Output(B,A,"* Repeat Ans getKey→C End Output(B,A," //This would've caused some problems - it would've given out of bounds. But I moved it to the end. End Test it!
And further, you can remove the DelVar C because the maximum the numbers can become is 1, and the minimum is -1, but is overwritten in the bound check.
Actually, you CAN do the DelVars. The min() and max() reset it, remember? All we need to do is move the erasing Output to the end of the loop, so that it doesn't give an error for out of bounds coordinates. Like so:
DelVar ADelVarBDelVarCClrHome //I don't think commas work for DelVars. Repeat Ans=45 max(1,min(16,A-(Ans=24)+(Ans=26→A max(1,min(8,B-(C=25)+(C=34→B Output(B,A,"* Repeat Ans getKey→C End Output(B,A," End
What state of matter is that in? Assuming liquid... I count 17... So that's 18.02g/6.02/10^23... which is 0.508870432 yl... 10^-24 litres = 1 yl. You wouldn't even be able to see that. Not wet. *trollface*
...and after losing my hard drive months ago and refusing to buy Windoze for my replacement, I'm playing only Portal and TF2, as everything else is Windoze only. I thought Portal 2 was supposed to work on Linux, but I guess not.