Author Topic: Turn order based on value in AppVar?  (Read 9240 times)

0 Members and 1 Guest are viewing this topic.

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Turn order based on value in AppVar?
« on: April 12, 2010, 08:46:29 pm »
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) [Select]
15
26
48
71
65
56
12

Code: (Turn Order) [Select]
6
5
4
1
2
3
7
« Last Edit: April 20, 2010, 02:16:17 pm by Raylin »
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Turn order based on value in AppVar?
« Reply #1 on: April 12, 2010, 08:58:26 pm »
A simple algorithm I just thought up is this (A points to appvar, B points to output list)
Code: [Select]
: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
Haven't tested it, but it should work in theory.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: Turn order based on value in AppVar?
« Reply #2 on: April 12, 2010, 09:07:50 pm »
My calc rewarded me with a kick in the face. (RAM clear)
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Turn order based on value in AppVar?
« Reply #3 on: April 12, 2010, 11:08:58 pm »
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.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Turn order based on value in AppVar?
« Reply #4 on: April 12, 2010, 11:21:13 pm »
That definitely shouldn't cause a RAM clear.  What is the other code you put around it?
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: Turn order based on value in AppVar?
« Reply #5 on: April 13, 2010, 07:06:54 am »
Code: (TEST) [Select]
:"vCake->Str1
:GetCalc(Str1,7)->A
:For(X,0,6
:rand->{A+X
:End
: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
:For(C,0,6
:Disp {B+C}>Dec,i
:End
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Turn order based on value in AppVar?
« Reply #6 on: April 13, 2010, 07:36:47 am »
The problem is that you didn't initialize B to the place where you want your 7-byte output list.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: Turn order based on value in AppVar?
« Reply #7 on: April 13, 2010, 08:11:21 am »
Oh?
I thought that the Fill( command did that!

:P

My fault.
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Turn order based on value in AppVar?
« Reply #8 on: April 13, 2010, 03:10:56 pm »
Everywhere in that sample where you used "B" just replace it with "L1".
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: Turn order based on value in AppVar?
« Reply #9 on: April 13, 2010, 07:38:03 pm »
It works.

Thank you, sir. :)
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: Turn order based on value in AppVar?
« Reply #10 on: May 11, 2010, 11:29:06 pm »
I've got problems with duplicates in my list.
I'm working on remedies now but help would be appreciated.
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Turn order based on value in AppVar?
« Reply #11 on: May 11, 2010, 11:45:43 pm »
mhmm what do you mean? Does the data unintentionnally duplicates, or do you actually want to duplicate it?

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: Turn order based on value in AppVar?
« Reply #12 on: May 11, 2010, 11:51:26 pm »
I mean that I want a list of values (1-100) that DOES NOT have repeats.
The method above doesn't create such a list.
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







_player1537

  • Guest
Re: Turn order based on value in AppVar?
« Reply #13 on: May 11, 2010, 11:53:40 pm »
hmmm, I haz an idea, give me a sec ok?  (or anyone else try it too)

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Turn order based on value in AppVar?
« Reply #14 on: May 12, 2010, 12:04:56 am »
Well, what should the behavior be in the event of a tie?  Just arbitrarily pick one to be more than the other?
« Last Edit: May 12, 2010, 12:05:32 am by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!