User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15

Thread: Best way to confirm that a series of values are different from each other?

  1. #1
    Clicker Multimedia Fusion 2
    Lethia's Avatar
    Join Date
    Apr 2012
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Best way to confirm that a series of values are different from each other?

    Hello, everyone. I've got a question on something that's come up with my programming on a few occasions now. It seems a simple thing to do, but it's had me stumped for a while now. Say you want multiple values to generate to a random number, but you don't want it to proceed to the next step until each of them are unique from each other. Is there any good way to do this?

    All I've been able to come up with so far is something basic like this.

    If:
    value 1 <> value 2
    value 1 <> value 3
    value 2 <> value 3

    Then move on to the next step.

    That works fine when I'm dealing with just a few values, but it gets troublesome when I start dealing with something like ten, when I need to have every single combination checked. It's impossible to do it in one event for something with dozens of values. Does anyone have any tips for a better way to do this without extensions?

  2. #2
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    (Val1-Val2)+(Val1-Val3)
    =
    0
    Working as fast as I can on Fusion 3

  3. #3
    Clicker Multimedia Fusion 2
    Lethia's Avatar
    Join Date
    Apr 2012
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by LB View Post
    (Val1-Val2)+(Val1-Val3)
    =
    0
    Thanks for the reply, LB, but could you go into more detail, please? As I'm afraid I don't understand.

    Say Val1 = 1, Val2 = 2, and Val3 = 3.

    "(Val1-Val2)+(Val1-Val3)" would give me -3, right?

    If both Val2 and Val3 were 2, then it would give me -2.

    Is there some other step I would have to take to get that formula to work here?

  4. #4
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Erp, I meant <> and not =

  5. #5
    Clicker Multimedia Fusion 2
    Lethia's Avatar
    Join Date
    Apr 2012
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by LB View Post
    Erp, I meant <> and not =
    So it would only proceed if the result is not zero then?

    Looking at my earlier example though, the first case has three different values, which results in -3, so the event would trigger. The second one has two identical values though, and that results in -2. The event would still trigger in that case, wouldn't it?

    As some extra information, I've tried in the past to do something like this.

    If:
    value 1 <> value 2 AND value 3
    value 2 <> value 3

    That seemed to work, but the equations seemed to still cut into the line limit for the event, due to their length. My most notable example is a card game test I did, where I wanted the deck to 'shuffle' at the start, by assigning each card's respective counter a random number, then confirm that each card was different from the others before proceeding. Long story short, that checker couldn't be contained in one event, as there were far too many combinations. I'm trying to find out if there's some trick to say 'if all of these values are different from each other' in a shorter event, rather than having to compare every single combination at once.

    It seems that something like "val1 <> val2 <> val3" would be perfect, but I don't know if there's any way to do that in one expression. Or would that not check val1 against val3?

  6. #6
    Clicker Fusion 2.5 DeveloperiOS Export Module
    ChrisBurrows's Avatar
    Join Date
    May 2011
    Location
    Tasmania, Australia
    Posts
    622
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    val1 <> val2
    val1 <> val3

  7. #7
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Ah, I see what you want now. @ChrisBurrows that won't work if val2 and val3 are the same.

    Try:
    (Val1-Val2)*(Val1-Val3)
    <>
    0
    Working as fast as I can on Fusion 3

  8. #8
    Clicker Fusion 2.5 DeveloperiOS Export Module
    ChrisBurrows's Avatar
    Join Date
    May 2011
    Location
    Tasmania, Australia
    Posts
    622
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    val1 <> val2
    val1 <> val3
    val2 <> val3

    But yeah, your expression is tight.

  9. #9
    Clicker Multimedia Fusion 2
    Lethia's Avatar
    Join Date
    Apr 2012
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks to both of you for the replies.

    Quote Originally Posted by LB View Post
    Ah, I see what you want now. @ChrisBurrows that won't work if val2 and val3 are the same.

    Try:
    (Val1-Val2)*(Val1-Val3)
    <>
    0
    I gave this a try with my example, but I'm afraid neither one is resulting in zero still.

    (1-2)*(1-3) = 2
    (1-2)*(1-2) = 1

    Quote Originally Posted by ChrisBurrows View Post
    val1 <> val2
    val1 <> val3
    val2 <> val3

    But yeah, your expression is tight.
    This method works fine, except when I'm dealing with many different values at once. I'd be willing to grit my teeth and write out each combination, but the event editor has a limit to how many lines a single event can have. For my card game test, I had 52 values to check against each other. That means the first value had to check against 51 values (51 lines), the second value had to check against 50 (101 lines), and so on, until I would need a grand total of 1,326 lines, I believe. I tried getting started on it, but didn't get far before the lines stopped copying into the event.

    I tried comparing all combinations for a given value at once, with something like this.

    value 1
    <>
    value 2 AND value 3 AND value 4 AND value 5

    value 2
    <>
    value 3 AND value 4 AND value 5

    The problem here was that it seemed to still stretch down into extra lines, and didn't seem to save me any space in the end.

    I realize I might be asking for something that doesn't exist here. I'm willing to bet most people would just use something like the Random Pool extension in a case like this. I was just hoping there was a way to do it in a shorter event without the use of an extension.

  10. #10
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    AND doesn't work like that, it is a bitwise AND.

    As for checking if they really are all different, I believe this should work:
    (A XOR B) + (A XOR C) + (B XOR C)
    =
    0
    Working as fast as I can on Fusion 3

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Video Tutorial Series
    By Jeff in forum News
    Replies: 0
    Last Post: 7th June 2012, 06:11 PM
  2. [Request]Confirm message for global object synchronization
    By ASD in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 3rd February 2012, 11:41 AM
  3. Possible Big Bug (Please Confirm)
    By Atom in forum SWF/Flash Export Module Version 2.0
    Replies: 17
    Last Post: 25th March 2010, 04:05 PM
  4. Ok... can someone please confirm a bug or not?
    By Gibbon in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 8th July 2009, 02:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •