Leading the way to the Future
 Quote: If F=2.5:Then LEPA(43->Z "0ZAL prgmZRS prgmTEMP "0 prgmZRS dimLAL->dim(LAM 1->A While LEPA(46)>=iPart(LAL(A LAL(A->LAM(A A+1->A End dim(LAM->A While LAM(A)=0 A-1->A End A->dim(LAM:3->B "0ZAD prgmZRS While A>0 and B<7 fPart(LAM(A))E3->LEPA(B LEPA(B->Z prgmTEMP Ans-LT LT(1->LEPA(B+12 LT(2->LEPA(B+4 LT(3->LEPA(B+8 LT(4->LEPA(B+16 LT(4->LEPA(B+20 LT(5->LEPA(B+50 B+1->B A-1->A End End

What this code does is give the pokemon its attacks. This part of the program takes roughly 9 seconds to run. The rest of the stat generation runs in under 2 seconds, which I can find acceptable. Any ideas or hints on how I could speed this up drastically?
 30 Aug 2008 03:06:19 pm by Weregoose Assuming all stats are positive, try replacing this: dim(LAM→A While LAM(A)=0 A-1→A End A→dim(LAM ...with this: cumSum(LAM 1+sum(Ans≠max(Ans→dim(LAM This will work faster only if there are plenty of zeros at the end of LAM. [EDIT] Also, in LEPA(B→Z, it'd be faster to access Ans repeatedly.
See if this works:
 Code: If F=2.5:Then LEPA(43->Z "0ZAL prgmZRS prgmTEMP "0 prgmZRS cumSum(LALnot(cumSum(LEPA(46)A 3->B "0ZAD prgmZRS While A>0 and B<7 E3fPart(LAL(A->LEPA(B Ans->Z prgmTEMP Ans->LT LT(1->LEPA(B+12 LT(2->LEPA(B+4 LT(3->LEPA(B+8 LT(4->LEPA(B+16 LT(4->LEPA(B+20 LT(5->LEPA(B+50 B+1->B A-1->A End End

I got rid of LAM completely since you can just read the elements from LAL in the last loop. All you need to find is the value of A.

Edit: Fixed a typo where Ans was used instead of LAL
 Weregoose wrote: Assuming all stats are positive, try replacing this: dim(LAM→A While LAM(A)=0 A-1→A End A→dim(LAM ...with this: cumSum(LAM 1+sum(Ans≠max(Ans→dim(LAM This will work faster only if there are plenty of zeros at the end of LAM. [EDIT] Also, in LEPA(B→Z, it'd be faster to access Ans repeatedly. [post="126492"]<{POST_SNAPBACK}>[/post]

So, it would be faster to store Ans to both the list element and variable Z? I have to store to both because the list element is attack name, and Z gathers the attack data :/
 30 Aug 2008 10:26:12 pm by Weregoose E3fPart(LAM(A→LEPA(B Ans→Z Just like what calc84maniac did in his code (except his is using LAL).
 31 Aug 2008 10:17:31 am by tifreak8x Well... still sitting at 9 seconds... anything else? Edit: hmm, upon further inspecting, seems it one of the attacks twice to the pokemon... That is why I had the second list, was to keep from having that kind of problem..
 tifreak8x wrote: Well... still sitting at 9 seconds... anything else? Edit: hmm, upon further inspecting, seems it one of the attacks twice to the pokemon... That is why I had the second list, was to keep from having that kind of problem.. [post="126499"]<{POST_SNAPBACK}>[/post]

Could the duplicate be because of the:
 Code: LT(4->LEPA(B+16 LT(4->LEPA(B+20
 31 Aug 2008 11:32:47 pm by tifreak8x No, the attack itself is LEPA(B The rest is stats for attacks and such. There was no problem with duplicates before. How ever, it is nice to know that it is seeing more than 2 attacks. :) I am thinking on a way to rewrite all of that code to be smaller and faster... I have tomorrow off, so when I take my breaks from learning asm or whatever I am doing tomorrow, I will look at it again.
 03 Sep 2008 07:10:35 am by luby Try commenting out each line with a " to find the problem. Note: you'll have to change the -> to a . or something when you comment it out.
 03 Sep 2008 08:36:15 am by tifreak8x I looked into that, those pieces of code are not slowing it down, as they happen instantly. I am truly not sure what is slowing it down, probably the recall attack data program... I wonder if things speed up if I split them up into smaller programs...
 03 Sep 2008 10:47:00 am by JoostinOnline Have you been testing the program by itself, or only when run as a subroutine? It could just be that you have something slowing it down in the main program right before it runs.
 03 Sep 2008 03:02:28 pm by tifreak8x I tested the routines individually. F=1 runs in less than a second, iPart(F)=2 runs in less than 2, but F=2.5 runs over 9 seconds. I am certain it has to do with the while loops, just not certain at this time what to do to replace them.
 03 Sep 2008 07:14:37 pm by luby ZRS is called twice. This looks like a potential slow down.
 03 Sep 2008 09:11:51 pm by tifreak8x prgmZRS has one line in it, :Asm(prgmRESOURCE :P I have shaved some time off of it, hoping to take off more now, by separating the attack data program. So far, took the LT out of the picture entirely, and added some :If Z<##:Return into the code to shave off 2 seconds. Edit: Splitting the attack data program in to two pieces shaved this off to just under 6 seconds.
 10 Sep 2008 07:22:35 pm by tifreak8x Well, a bit of an update. I took and recombined the attack data programs, removed all the If Z=###: and made it so Celtic2 will read the data at the lines. This as shaved miliseconds off... So it is now nearly 5 seconds flat. It is not terrible, however, I am still hoping to improve it. I am, however, running into problems with it displaying incorrect data. I am going to revert back to the original code, optimize some of it, and see if I can see what part of the code is causing the troubles.