Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Raylin on May 16, 2010, 11:35:12 pm

Title: [UPDATE] Speed Order Program
Post by: Raylin on May 16, 2010, 11:35:12 pm
This is the current program for the ARMY speed order.

Code: [Select]
:.SPDORDER
:Disp "Loading...
:"vARMYOrdr→Str1
:GetCalc(Str1)→θ
:If θ=0
:GetCalc(Str1,100)→θ
:For(X,0,99
:rand→{θ+X
:End
:End
:conj(θ,L1,100
:1→A
:While A
:0→A
:For(X,0,99
:If {L1+X}<{L1+X+1}
:expr(L1+X,L1+X+1,1
:1→A
:End
:End
:End
:1→A
:Fill 0→{L2},100
:For(X,0,99
:{θ+X}→Z
:For(Y,0,99
:If Z={L1+Y}
:(Y+1)→{L2+X}
:End
:End
:End
:For(X,0,99
:Disp {L2+X}►Dec,i
:Repeat getKey
:End
:End

If anyone has any optimizations for this, that would be nice.
And, if anyone can patch up the little problem that occurs with duplicates (The problem is that the same value is assigned to duplicates.), that would be nice as well.
Title: Re: [UPDATE] Speed Order Program
Post by: ztrumpet on May 17, 2010, 05:06:28 pm
Let's see, I see one little thing:
If θ=0
could be
!If θ

I'm not the best at optimizing for Axe, so I wouldn't doubt if more optimizations are out there.  Good luck! ;D
Title: Re: [UPDATE] Speed Order Program
Post by: DJ Omnimaga on May 17, 2010, 11:05:59 pm
I'm not sure if I understand "Fill 0→{L2},100"

Isn't it Fill(, not Fill?
Title: Re: [UPDATE] Speed Order Program
Post by: Raylin on May 17, 2010, 11:14:09 pm
That's weird.
I copied this from SourceCoder 2 over at Cemetech.
Title: Re: [UPDATE] Speed Order Program
Post by: DJ Omnimaga on May 17, 2010, 11:15:23 pm
Oh, I think SC2 had some issues with commands. I should maybe report them to KermMartian unless it was already reported before. Horizontal changes to Horizontal(

I can't find optimizations, though
Title: Re: [UPDATE] Speed Order Program
Post by: Quigibo on May 18, 2010, 12:47:32 am
I found several, but before I post, could you explain what you're trying to do from start to finish?  It appears you're sorting a list first and then sorting another list the same way as the first one right after?  I know how to sort both at the same time if that's what your trying to do.  Can you give me an example of what input and output should be?

Also, how useful would a sort command be?  I was going to add it later, but maybe I can whip one up for the next version.  It would probably be SortA(ptr,size) to sort size bytes in the array at ptr or you can use an optional 3rd argument SortA(ptr,size,ptr2) to sort the data at the second pointer in the same order as the first.
Title: Re: [UPDATE] Speed Order Program
Post by: Builderboy on May 18, 2010, 01:11:29 am
A sort command would indeed be useful, although what algorithm would you end up using?  There would be tradeoff's between size and speed, like bubble vs something like quicksort.
Title: Re: [UPDATE] Speed Order Program
Post by: Quigibo on May 18, 2010, 01:13:54 am
It would probably use quicksort since it sorts in place, is simple and small to code, and computes in nlog(n) time.
Title: Re: [UPDATE] Speed Order Program
Post by: DJ Omnimaga on May 18, 2010, 01:53:16 am
Sort would come handy for example in RPG item menus, where items are listed from the lowest to highest item type ID. See for example Illusiat 13.
Title: Re: [UPDATE] Speed Order Program
Post by: Raylin on May 18, 2010, 06:45:53 am
SortA() and SortD() would be very useful!
:D

Quigibo, basically, I'm trying to take values from the AppVar and throw them in a list. Then, I copy that list to another list and sort that one. Then, going down the list, it compares the values of the sorted list to the unsorted AppVar and assigns a number in ANOTHER list. It is this list that I need.

tl;dr - It produces a list of (Offset+1). The order of units in essence.
Title: Re: [UPDATE] Speed Order Program
Post by: ztrumpet on May 18, 2010, 04:39:17 pm
I like the idea of SortA( and SortD(.  Those would be useful in Axe! ;D
Title: Re: [UPDATE] Speed Order Program
Post by: calcdude84se on May 18, 2010, 06:50:40 pm
i would think the arguments would be SortA(addr,bytes) for an 8-bit val sort and SortA(addr,words)r for 16-bit.
for consistency.
Edit: If no one has, someone should suggest it to quigibo on the Features Wishlist thread.
Title: Re: [UPDATE] Speed Order Program
Post by: DJ Omnimaga on May 18, 2010, 08:00:06 pm
What would addr stands for?

Title: Re: [UPDATE] Speed Order Program
Post by: calcdude84se on May 18, 2010, 08:01:23 pm
address of place to start sorting
Title: Re: [UPDATE] Speed Order Program
Post by: DJ Omnimaga on May 18, 2010, 08:07:21 pm
oooh ok. I tend to have troubles with acronyms x.x