lafferjm wrote:
Its very good that you learned how to do that. Now you should figure out how to do it with strings Smile

I found that way annoying, so I never bothered to memorize it.
Based on the original code, this version A) creates a pair of backup variables, and B) doesn't bother searching for an obstacle before the character enters a tile. It blindly "walks" into each space and then does a check to see what tile it's on. If it finds that it doesn't belong there, it reverts to its old position using the backup variables. Of course, this all happens first, and then the character gets drawn afterward.


Code:
:ClrHome
:2→C:2→D
:[[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2][2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2][2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,2][2,0,0,0,2,2,2,2,0,0,0,2,1,2,0,2][2,0,2,0,0,0,0,0,0,2,0,0,0,2,0,2][2,0,2,2,2,2,2,2,2,2,2,2,2,2,0,2][2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2][2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]]→[A]
:For(A,1,8)
:For(B,1,16)
:[A](A,B)
:If Ans≠0:Then
:Output(A,B,sub("WX",[A](A,B),1))
:End
:End
:End
:Output(D,C,"θ")
:Repeat [A](D,C)=1
:getKey→K
:If K≠0:Then
:Output(D,C," ")  //1 space

Modified code begins here


:C→U:D→V
:C-(K=24)+(K=26)→C
:D-(K=25)+(K=34)→D
:If 1<[A](D,C)
:Then
:U→C:V→D
:End


Modified code ends here

:Output(D,C,"θ")
:End
:End
:ClrHome
:Output(1,4,"YOU  WIN")
:Pause
:ClrHome
:Return


With fewer tests to perform, this code is actually a little faster than its predecessor.
Weregoose, here's an improvement on your modified code:

Code:
:C-(K=24)+(K=26)→U
:D-(K=25)+(K=34)→V
:If 1>=[A](V,U)
:Then
:U→C:V→D
:End
MufinMcFlufin wrote:
Weregoose, here's an improvement on your modified code:

Code:
:C-(K=24)+(K=26)→U
:D-(K=25)+(K=34)→V
:If 1>=[A](V,U)
:Then
:U→C:V→D
:End
Very nice thinking there. Smile Also, I presume that we're not yet doing any substantial syntactical optimizations on the code for the sake of clarity?
KermMartian wrote:
MufinMcFlufin wrote:
Weregoose, here's an improvement on your modified code:

Code:
:C-(K=24)+(K=26)→U
:D-(K=25)+(K=34)→V
:If 1>=[A](V,U)
:Then
:U→C:V→D
:End
Very nice thinking there. :) Also, I presume that we're not yet doing any substantial syntactical optimizations on the code for the sake of clarity?
Yes, this is correct.
wow. This code is something I haven't found out how to use. *facepalm* I am such an idiot.
MufinMcFlufin wrote:
KermMartian wrote:
MufinMcFlufin wrote:
Weregoose, here's an improvement on your modified code:

Code:
:C-(K=24)+(K=26)→U
:D-(K=25)+(K=34)→V
:If 1>=[A](V,U)
:Then
:U→C:V→D
:End
Very nice thinking there. Smile Also, I presume that we're not yet doing any substantial syntactical optimizations on the code for the sake of clarity?
Yes, this is correct.


Well what happened to your comment on optimizations?
This was to show how to use it, point blank, if people know that you can omit any [" ) and whatever else there is, then they will know how to do that and not mess up the code.
Ah yes, I remember fooling around with this a long time ago as a possible detection system for AOD:R. I found it too bulky and slow for my needs sadly, with all the checking and the like.

Good tutorial on that, fairly simple and straight to the point. Maybe some aspects of it are a little too broken down, like where the movement math code is.

Otherwise, nice job. Reminds me I have so many tutorials to mess with for my site. *sigh* one of these days I'll find time to work on them. ><
tifreak8x wrote:
Ah yes, I remember fooling around with this a long time ago as a possible detection system for AOD:R. I found it too bulky and slow for my needs sadly, with all the checking and the like.

Good tutorial on that, fairly simple and straight to the point. Maybe some aspects of it are a little too broken down, like where the movement math code is.

Otherwise, nice job. Reminds me I have so many tutorials to mess with for my site. *sigh* one of these days I'll find time to work on them. ><


I thought about it being too broken down, but I figured some people might now know how to make movement with that kind of setup over If K=24:Then
....:End
etc..
Well, not to say it shouldn't be broken down, but showing that line of code, then explaining how the calculator sees it with an example if the up key is pressed, usually is enough. If they still don't understand, then they can ask questions.
tifreak8x wrote:
Well, not to say it shouldn't be broken down, but showing that line of code, then explaining how the calculator sees it with an example if the up key is pressed, usually is enough. If they still don't understand, then they can ask questions.


I was trying to make it so that questions were not needed about the movement at least, it took that example for me to realize how "C+(K=.....)->C" worked.
Sonlen wrote:
MufinMcFlufin wrote:
KermMartian wrote:
MufinMcFlufin wrote:
Weregoose, here's an improvement on your modified code:

Code:
:C-(K=24)+(K=26)→U
:D-(K=25)+(K=34)→V
:If 1>=[A](V,U)
:Then
:U→C:V→D
:End
Very nice thinking there. :) Also, I presume that we're not yet doing any substantial syntactical optimizations on the code for the sake of clarity?
Yes, this is correct.


Well what happened to your comment on optimizations?
This was to show how to use it, point blank, if people know that you can omit any [" ) and whatever else there is, then they will know how to do that and not mess up the code.
:P

It's one thing to eliminate end parenthesis. It's another to make the calculator have to store less values and do less checks while performing the same function. I did the later, and while it can still be comprehended by a reader of the tutorial, I recommend it still be done to all code (except to the point of some of my own code, like: "sum(seq(inString(sub(...")
  
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