Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualhaegarr

Posted 05 January 2013 - 04:07 AM

The OP describes IMHO: From a total of 30 different models a subset is to be picked during the run of level 1. This subset is to be re-used "as-is" during level 2 and perhaps following levels.

So the task is to pick n <= 30 (probably n < 30) models from the original set of 30 models, i.e. selection without putting back.

A solution would be to hold all IDs of still available models in an indexable storage (e.g. the array mentioned in the OP), generate a random integral number in the range [0, length(storage)-1], use that as index into the storage to read out the appropriate ID, remove it from the storage (i.e. in the case of an array by shifting all IDs with greater indices one index before and decrease the length of the storage by 1), and use the picked ID further for remembering and instantiation.

#1haegarr

Posted 05 January 2013 - 03:59 AM

The OP describes that from a total of 30 different models a subset is picked during the run of level 1. This subset is re-used "as-is" during level 2 and perhaps following levels.

 

So the task is to pick n <= 30 (probably n < 30) models from the original set of 30 models, i.e. selection without putting back.

 

A solution would be to hold all IDs of still available models in an indexable storage (e.g. the array mentioned in the OP), generate a random integral number in the range [0, length(storage)-1], use that as index into the storage to read out the appropriate ID, remove it from the storage (i.e. in the case of an array by shifting all IDs with greater indices one index before and decrease the length of the storage by 1), and use the picked ID further for remembering and instantiation.


PARTNERS