Setting values in pairs?

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • I thought since my memory is so bad, that I would make a brain-exercise game for myself. The game is supposed to work in a way that you get some boxes with different numbers, and you have to remember which box has which number, so you can find matching pairs.
    Some things to keep in mind: The number placement is random each match, so you always have to use your memory to find matching pairs. The numbers will never be higher than half the number of boxes, so that if there's 10 boxes, you will need to find the pairs with the numbers 1,2,3,4 and 5.

    The problem: How do I do this? Assigning numbers to the boxes is no problem. It's basically just spreading values. The problem is to give half the boxes the same number as the other half, without there being more than 2 of one number. Example: I don't want 3 boxes to have the number 1, as the number 1 should only be found on 2 boxes (hence a pair).

    I have tried different solutions, like using a value that starts on 1, picks one random box and gives it that number, then adds 1 more to the value, assigns that number to a random box, etc. For some reason, this doesn't work.

    Any help please? :P Hope people can understand what I just tried to explain.

  • Make a list with all availible numbers like this:

    1
    1
    2
    2
    3
    3
    4
    4
    5
    5

    At start of frame run a ForEach loop on each box.
    On each loop, set a counter to Random(Number of lines), set the object's value to the value of the line(that random number) and then delete that line.
    This way your program assigns only values that are not allready taken.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!