Avoid repetion in random combinations

1 favourites
From the Asset Store
Over 2700 files with all the colour combinations from a 15 colours palette!
  • Thank you so much R0J0hound

    I thought you wouldn't have time so soon and I ended up trying hard to get this problem resolved so I could proceed. I managed to do this last night, but I'll take a look at your file to see if I can optimize my solution. It will definitely be much better than mine.

    I'm having a problem finding a solution for another question and I think you can help me (if it's not asking too much)

    The exercise has 3 answer options. I would like to make one of them (randomly) receive the value of the right answer signed in a variable (eg: varAnswer=0,3,2,1) and the other two options would have to be randomized to generate other different combinations between them. In the end, I need to know which of the options was signed as right, that is, the one that has the value of the varAnswer variable. Could you give me an idea of how to build this? It can be in pseudocode even if you prefer.

    EDITED: I am still talking about the same game, where each answer option consists of 4 numbers. Just to clarify.

  • I thought to use something like this:

  • I apologize, I’m not great at reading events at the moment. I thought I had given a solution to your last question in one of the first files I posted. I think I’m causing more confusion with every new capx I post since I do things slightly different over time.

    In the last capx it just makes three shuffled value. If they are all unique (don’t equal each other) then one is picked randomly to be the right answer.

    You could just make two shuffled values and make them unique by comparing with each other and a correct answer.

    I’d recommend doing some tests to swap two values or two positions of objects. Once you can do that you have all the tools you need to shuffle anything.

    In general you could swap a and b with:

    Temp=a

    A=b

    B=temp

  • Hi R0J0hound

    Thanks a lot for the last example. I've been studying this file and I've also made some changes to my event sheet to make it look more like your solution, however, I'm looking to raise the difficulty once again and ended up getting stuck. I've duplicated your file already in the format it should be (two lines of options instead of 1), but the rest remains the same. I decided to clone the sprite to use in the other row, but I can't make it draw the numbers. The idea is that one of the options from the top row and another from the bottom row arrive in the final result. Could you take a look?

    we.tl/t-ZqYIS3lFi1

  • All the code refers to same sprite type. The new choices are a different type.

    I made all the numbers be the same type and used a group variable to differentiate between then to reduce the amount of events.

    There are many ways to setup the events. Currently it does most of the stuff with variables and only deals with sprites when displaying. Nothing is automatic. To display it picks a certain group of sprites and sets it from a certain variable.

  • Hi R0J0hound

    Thank you for replying

    OK. I understand what you said, but even though it's a new row of options I have to leave it in the same sprite as the others? Because in that case, I would have to select two options (1 in the top row and one in the bottom row).

  • There isn’t one way you have to do it. You can set it up any way you like. With any setup you’ll have to do some juggling with events.

    If it’s any consolation I find any changes to this to be complicated too. I attempted to simplify things into manageable chunks but I still find rough to debug or modify.

  • Ok. Please let me know if you have any ideas on how to turn this into the new format (2 lines). I'll keep making my attempts around here

  • If anyone else has any ideas on how to resolve this I would be grateful to hear your suggestions. I'm still stuck here. :(

  • Hi R0J0hound,

    Will you accept some coffee to help me solve this problem? If so,

    how many coffees would it be?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I appreciate the offer but I’m a bit pressed for time lately. No coffees needed. I’m actually considering getting rid of that since I’m happy to help as I have time usually. I can try to have a look again one of these days. It’s just not a fun problem to work on and I’ve created more work for myself since I haven’t been able to create something that is easy to understand or use.

    I burn out on projects pretty quick, even the ones I enjoy. But I’ll see if I can get a chance to look at this again later.

  • I appreciate the offer but I’m a bit pressed for time lately. No coffees needed. I’m actually considering getting rid of that since I’m happy to help as I have time usually. I can try to have a look again one of these days. It’s just not a fun problem to work on and I’ve created more work for myself since I haven’t been able to create something that is easy to understand or use.

    I burn out on projects pretty quick, even the ones I enjoy. But I’ll see if I can get a chance to look at this again later.

    I would really appreciate it. I know it's a lot of work to develop something that meets these new possibilities, but unfortunately, I only need to solve this one to be able to show my idea. I've almost given up several times, but I need to insist a little more and that's why I'm asking you to help me with this. I think the "coffees" are a great way for people to give some form of retribution for your help. I'm totally comfortable with it.

  • Hi R0J0hound

    I think I managed to simplify the problem in a way that you can just tell which way I should go to solve it.

    The interface is made up of:

    1) randomly shuffled sequence of letters (ABCD) (eg CDAB appeared in the draw (which corresponds to frames 2301))

    2) 3 blocks of 4 random numbers from 1 to 4, a sequence of which is drawn. (eg 4213/3214/2134 - the last one was drawn and a list of frame numbers was saved in a variable)

    3) 4 numbers that serve as parameters for a new position change (eg 4321 - a list of frame numbers saved in a variable)

    4) 3 blocks of 4 random numbers from 1 to 4, a sequence of which is drawn. (eg 1234/2413/3142 - the last one was drawn and a list of frame numbers was saved in a variable)

    5) Randomly shuffled sequence of letters (ABCD) or we can leave them all in frame 0 and then adjust according to the formation of the stage 4)

    Making a simulation of the process based on the data previously informed and with the user selecting the correct options:

    1) CDAB

    2) 2134 (corresponds to DCAB)

    3) 4321 (BACD)

    4) 3124 (CBAD)

    5) Sequence of letters that corresponds to the positions of stage 4, that is, the sequence that will form the CBAD if we change the positions of the letters from the bottom to the top.

    In this case the correct solution would be BACD. This is the sequence that should appear below.

    I need to know how to register these frame changes at each stage. If I have this stage 4 value, I can use it to form the letters that are in stage 5 and when I do the reverse order, I would have to hit the bottom with the letters at the top. Do you think it's clearer now?

  • Hi,

    Had a look and no, I'm not wrapping my head around it. I just see a lot of shuffling going on.

    Based on this whole thread you are doing three things: shuffling, shuffling using a specified order, and displaying the numbers.

    function shuffle(text) 
    -- var i=0 
    -- repeat 10 times 
    -- -- set i to int(random(4)) 
    -- -- set text to left(text, i) & mid(text,i+1,10) & mid(text,i,1) 
    -- return text 
     
    function shuffleBy(text, order) 
    -- var ret="" 
    -- repeat 4 times 
    -- -- add mid(text, find(text, loopindex), 1) 
    -- return ret 
     
    function display(text, x, y, anim) 
    -- repeat 4 times 
    -- -- create sprite at (x, y+32*loopindex) 
    -- -- sprite: set frame to int(mid(text,loopindex,1)) 
    -- -- sprite: set animation to anim

    I can't follow all of what you're trying to do but everything can be done with those building blocks. Notice the display just creates the sprites. Just delete the old ones first.

    I the case of one of your first example. You have a number, it's then shuffled by one of three unique choices, then it's shuffled by another value and you get a result.

    var A = shuffle("0123") 
    var B1="",B2="",B3="" 
    while B1==B2 or B1==B3 or B2==B3  
    -- B1 = shuffle("0123") 
    -- B2 = shuffle("0123") 
    -- B3 = shuffle("0123") 
    var correctB = choose(B1,B2,B3) 
    var C = shuffle("0123") 
    var answer = shuffleBy(shuffleBy(A, correctB), C) 
     
    //display 
    display(A, 100,100, "alpha") 
    display(B1, 100,100+32*1, "digits") 
    display(B2, 100,100+32*2, "digits") 
    display(B3, 100,100+32*3, "digits") 
    display(C, 100,100+32*4, "digits") 
    display(answer, 100,100+32*5, "alpha")

    Beyond that all I can gather from your other posts is you have additional steps added. Here I just had the display create the objects on the fly but you can have it pick existing objects instead.

    I'm not sure if any of that is helpful. I'm going to have to take a break from this problem though.

  • Is it possible to record each frame change from the letter sequence to step 4?

    For example:

    1) ADCB - Letter Sequence

    2) 3124 - First change of position (CADB) - Frames: 2013

    3) 4123 - Second Amendment (BCAD) - Frames: 1203

    4) 1324 - Third Amendment (BACD) - Frames: 1023

    Based on the information from the frames from step 4, I can assemble the sequence of letters in step 5.

    EDITED: Sorry. I didn't see your post before. I think this is the simpler way to solve this.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)