GML Visual Randomized list with removable variables

B

bebesnuggles

Guest
I've sought your guys' help with this problem before but I just can't get it figured out.
The goal is to have a list of "Bones" that will randomly select, but only select once until the list has gone through all the bones. When all the bones have been selected, they should re-create the list. That's easy enough right?
When I score one of the Bones I want the specific bones to stay off the re-created list. I've tried using a large set of if than chains but it's not working. What would yall reccomend?
 

chamaeleon

Member
I've sought your guys' help with this problem before but I just can't get it figured out.
The goal is to have a list of "Bones" that will randomly select, but only select once until the list has gone through all the bones. When all the bones have been selected, they should re-create the list. That's easy enough right?
When I score one of the Bones I want the specific bones to stay off the re-created list. I've tried using a large set of if than chains but it's not working. What would yall reccomend?
Without knowing more about the selection process/mechanism, ds_list plus ds_list_shuffle() and pop off the first element for a random order and unique selection until the list is empty.
 
B

bebesnuggles

Guest
Without knowing more about the selection process/mechanism, ds_list plus ds_list_shuffle() and pop off the first element for a random order and unique selection until the list is empty.
Yeah, I have tried that, and it works well, i've also tried doing irandom(ds_list_size(bonelist)) I just can't figure out how to do the re-creation script with taking out scored bones.
 

chamaeleon

Member
Yeah, I have tried that, and it works well, i've also tried doing irandom(ds_list_size(bonelist)) I just can't figure out how to do the re-creation script with taking out scored bones.
Have a separate list that is identical in content at the start to the actively used one, and when "scoring" a bone use ds_list_find_index() to get the index of the bone "scored" and call ds_list_delete() with that index. Upon "regeneration" ds_list_copy() the list from which you remove "scored" bones to the one you use to go through in order, and ds_shuffle() it after copy.
 

Lumenflower

Yellow Dog
Yeah, I have tried that, and it works well, i've also tried doing irandom(ds_list_size(bonelist)) I just can't figure out how to do the re-creation script with taking out scored bones.
Can't you just use ds_list_delete to remove the bone from the list once you score it? Then scored bones won't be present in the list when you reshuffle it. From what I can understand of your issue, I feel the best solution would just be to loop sequentially through each element of the list to 'select' it, with the addition of removing it from the list entirely if you score it. Some for-loop like:

GML:
while (ds_list_size(list)>0) {
    for (var i=0;i<ds_list_size(list);i++) {
        select(list[| i]) //Or whatever your selection process is
        if (score) {//Whatever you need to check to score that bone
            add_score(list[| i]); //Do your scoring thing
            ds_list_delete(list,i); //Delete that bone from the list.
        }
    }

    ds_list_shuffle(list);
}
Obviously that all takes place within a single step - is that what you were after or do you need some player input each time a new bone is selected? Principle should be mostly the same.
 
B

bebesnuggles

Guest
Have a separate list that is identical in content at the start to the actively used one, and when "scoring" a bone use ds_list_find_index() to get the index of the bone "scored" and call ds_list_delete() with that index. Upon "regeneration" ds_list_copy() the list from which you remove "scored" bones to the one you use to go through in order, and ds_shuffle() it after copy.
i Think this will work! I'm going to try that out! Fingers Crossed!
 
Top