Calculator Community > Axe

Turn order based on value in AppVar?

(1/4) > >>

Raylin:
Basically, there are seven values (1-99) in an AppVar.

What I'm trying to figure out is how to make a turn order based on these values.
Highest value goes first in the turn order.

So...


--- Code: (vCake) ---15
26
48
71
65
56
12
--- End code ---


--- Code: (Turn Order) ---6
5
4
1
2
3
7
--- End code ---

calc84maniac:
A simple algorithm I just thought up is this (A points to appvar, B points to output list)

--- Code: ---:Fill(0->{B},6
:For(X,0,6
: {A+X}->Z
: For(Y,0,6
:  If {A+Y}>=Z
:   {B+Y}+1->{B+Y}
:  End
: End
:End
--- End code ---
Haven't tested it, but it should work in theory.

Raylin:
My calc rewarded me with a kick in the face. (RAM clear)

DJ Omnimaga:
Would this be for a turn-based RPG? For turns, I generally have the character and enemy have a speed attribute, usually from 1 to 99, and when battle begins, the char/enemy turn counters are set to a random value from LV to 2*LV. Then there's a loop where those two values increments. Once your char reaches 255, it's his turn to attack, and his value is reset to his speed LV. Same for enemy turns. In TI-BASIC this can be quite slow if you have 3vs3 battles, though.

Btw remember to archive or backup your stuff before testing random routines, so you won't lose too much if an error occurs.

Quigibo:
That definitely shouldn't cause a RAM clear.  What is the other code you put around it?

Navigation

[0] Message Index

[#] Next page

Go to full version