GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to order number (attribute) in a table?

stefdelecstefdelec Posts: 146Member, PRO
edited July 2015 in Working with GS (Mac)

Hi,

I am creating a game. Let's say it is a dice game, with 5 dice. So I can get 1,2,3,4,5 or 6. I'd like to be able to know if there is 5 dice with the same number (2 2 2 2 2 or 3 3 3 3 3 3). Or if there is a sequence 1 2 3 4 5 or 2 3 4 5 6. My problem is dice can be 2 3 4 5 1, or 3 4 2 1 5....etc.

I was thinking to put in ascending order all the value in a table, and then check them.

What do you think?

Regards,

Stéphane.

Comments

  • SocksSocks London, UK.Posts: 12,822Member
    edited July 2015

    1x2x3x4x5/6 = 20

    6x5x4x3x2/1 = 720

    You could perform a simple calculation on the 6 attributes in order.

    If AxBxCxDxE/F = 20 . . .

    Or . . .

    If A<B and B<C and C<D . . .

  • stefdelecstefdelec Posts: 146Member, PRO
    edited July 2015

    Tks for the calculation. However: 1x1x4x5x6/6=20 too. And I have only 5 dices.

    the "A<B and B<C and C<D" technic looks a bit too...boring to do! :-) That's why I asked. Also, if A<B and C<B. I don't know if C is < or > than A.

    Do you think I could do something with a loop?

  • ArmellineArmelline Posts: 4,709Member, PRO

    Perhaps use a quick bubble sort like this.

    You can do the same thing with a loop, but for smaller sets of numbers, this way is quicker.

  • SocksSocks London, UK.Posts: 12,822Member
    edited July 2015

    @stefdelec said:
    the "A<B and B<C and C<D" technic looks a bit too...boring to do! :-) That's why I asked. Also, if A<B and C<B. I don't know if C is < or > than A.

    The three dots at the end of what I wrote indicate that it continues as laid out, so if you see something that says "all the odd numbers should look like this 1 3 5 7 9 11 13 . . . . " you could point out that they have forgotten 15 (and every other larger odd number), but you might be missing the point/s ! :smile: :tongue:

  • stefdelecstefdelec Posts: 146Member, PRO

    Can you help me with a loop? I started something but I am getting confused...

Sign In or Register to comment.