Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Raylin on April 11, 2010, 08:48:23 pm

Title: Shifting Order
Post by: Raylin on April 11, 2010, 08:48:23 pm
Say that 7 players have a number (1-7).
Say there is a list that is populated with these numbers (1-7).
The concept here is to establish some sort of order here.

i.e. When Player 1 moves, he moves to the bottom of the list and works his way up the list. Every other player follows suit.

EDIT: The list looks like this.

Code: [Select]
1
2
3
4
5
6
7

*Player 1 ends his turn

The list should look like this.

Code: [Select]
2
3
4
5
6
7
1
Title: Re: Shifting Order
Post by: _player1537 on April 11, 2010, 08:58:17 pm
Code: [Select]
Repeat Getkey(15)
(player does turn here)
{L1}->A
For(B,1,6
{L1+B}->{L1+B-1
End
A->{L1+6
End
Title: Re: Shifting Order
Post by: Raylin on April 11, 2010, 09:05:16 pm
Thank you, good sir.
Title: Re: Shifting Order
Post by: cooliojazz on April 11, 2010, 09:11:00 pm
wouldn't seq(L1(X),X,2,7)->L1 be faster than the for loop?
Title: Re: Shifting Order
Post by: JonimusPrime on April 11, 2010, 09:13:17 pm
wouldn't seq(L1(X),X,2,7)->L1 be faster than the for loop?
Except this is in the axe parser subforum and I'm not sure if axe has a sequence command. Other wise yes that would be the better solution.
Title: Re: Shifting Order
Post by: meishe91 on April 11, 2010, 09:14:59 pm
I don't think Axe supports seq(.

Edit:
Ninja'd.
Title: Re: Shifting Order
Post by: cooliojazz on April 11, 2010, 09:15:37 pm
Oh, lol didnt notice, and the axe code looks so similar... :P
Title: Re: Shifting Order
Post by: meishe91 on April 11, 2010, 09:16:08 pm
I think that's the point of Axe ;)
Title: Re: Shifting Order
Post by: Will_W on April 11, 2010, 09:16:17 pm
Augment(seq(L1(X),X,2,7),{L1(1->L1
It's faster to put the last element in position 1 though
Augment({L1(dim(L1))},L1->L1
dim(L1)-1->dim(L1
Edit:Oh, this is in Axe, never mind.
Title: Re: Shifting Order
Post by: cooliojazz on April 11, 2010, 09:35:04 pm
meishe91, i dont think its the point, but still a major bonus  ;D
Title: Re: Shifting Order
Post by: meishe91 on April 11, 2010, 09:36:26 pm
I know :P I was just kidding but you see what I meant (hopefully :P)
Title: Re: Shifting Order
Post by: Raylin on April 11, 2010, 10:34:48 pm
Player, if you're still around, could you change the code to address the fact that I used an AppVar?
Title: Re: Shifting Order
Post by: _player1537 on April 11, 2010, 10:37:53 pm
oh yeah, np, one sec working on that sort(a thing
Title: Re: Shifting Order
Post by: Quigibo on April 11, 2010, 11:05:59 pm
There is a very simple optimization you can do:

{A+B^7+L1}

Will return the Ath player after B turns (where both start at zero).  I guess it would require you to keep track of how many turns are played so far, but its pretty simple.  You can even make it a subroutine if you call it a lot to save space.

Title: Re: Shifting Order
Post by: _player1537 on April 11, 2010, 11:08:44 pm
yeah, I was kinda wondering why he didn't do that in the first place, I figured the routine could also be used for something else
Title: Re: Shifting Order
Post by: DJ Omnimaga on April 11, 2010, 11:12:26 pm
Oh, lol didnt notice, and the axe code looks so similar... :P
Yeah sometimes we need to be careful when we use the New Posts feature, because we tend to miss the subforum it was posted in and since Axe code is similar it may lead to confusion x.x