Background:
Note: While I have a specific use in mind for what I am inquiring how to do, I've tried to keep the actual question portion as general as possible because I think what I'm asking about might have applications in more usage cases than just the thing I'm trying to do. I feel like I have an idea on how conceptually to do it, but I don't know how to use script calls to actually make it happen. My only real programming experience is basic Python.
I'm attempting to create a system to semi-randomly generate a dungeon, with the rooms being predefined but their arrangement being random, as a sort of gimmick for one specific dungeon I have in mind. (Note - even if there's a way to fully randomly generate a dungeon, I intend on only randomizing the map connections so that I have more control over the dungeon's aesthetics than a completely randomly generated dungeon would allow). Currently I'm in a proof-of-concept phase with it, making an experimental project as a feasibility study.
The current implementation I've come up with involves generating a random number, using switches to check if the room is in use or not, and then if the room has already been used, try again. The problem is, though, as the number of rooms increases this gets a bit inefficient, because the probability of selecting an unused room gets lower over time. I'd like to know if there's a way that I could make the random number generator work more like drawing items out of a hat (and not replacing them). I assume this would be beyond the capabilities of the event editor's built in commands but I'm hoping it may be possible with script calls. It is okay if the list of possible random numbers to generate has to be created by hand - this might even be preferable because then I can use Map ID's directly instead of having events intended to convert the RNG result into an actual, usable Map ID.
The most important part of the question is the RNG implementation itself, as it should be applicable to more scenarios than the one I'm using (that said, if you know a better way to do what I'm trying to do, by all means tell me). As an example of what I want to happen in a very general form:
RNG chooses from the following list: [1, 2, 3, 4]
Run some events based on this choice.
Suppose "3" was chosen.
RNG chooses another value from the list, which is now [1, 2, 4]
Run some more events based on this choice.
The list needs to be restored to its original state whenever the common event used to generate the dungeon is called.
It is also preferable if I can check how many items are on the list (this will be especially important when I look into implementing a system to make sure everything connects properly, which I have a rough idea of how to go about doing that needs a proof-of-concept still).
I have a thought on the implementation, but I don't know how to make use of Javascript (I assume script calls would use that as well, yes?) to pull it off:
Create a list. A preset one, hard-coded into the common event governing the dungeon generation, should suffice.
Use a random number between 1 and n, where n is the size of the list, to select an element from the list. (may actually be 0 and/or n-1 because indexing; I'm not sure how it works in Javascript, assuming Javascript even HAS lists in it like Python does)
Store this number in a variable and remove it from the list.
Note: While I have a specific use in mind for what I am inquiring how to do, I've tried to keep the actual question portion as general as possible because I think what I'm asking about might have applications in more usage cases than just the thing I'm trying to do. I feel like I have an idea on how conceptually to do it, but I don't know how to use script calls to actually make it happen. My only real programming experience is basic Python.
I'm attempting to create a system to semi-randomly generate a dungeon, with the rooms being predefined but their arrangement being random, as a sort of gimmick for one specific dungeon I have in mind. (Note - even if there's a way to fully randomly generate a dungeon, I intend on only randomizing the map connections so that I have more control over the dungeon's aesthetics than a completely randomly generated dungeon would allow). Currently I'm in a proof-of-concept phase with it, making an experimental project as a feasibility study.
The current implementation I've come up with involves generating a random number, using switches to check if the room is in use or not, and then if the room has already been used, try again. The problem is, though, as the number of rooms increases this gets a bit inefficient, because the probability of selecting an unused room gets lower over time. I'd like to know if there's a way that I could make the random number generator work more like drawing items out of a hat (and not replacing them). I assume this would be beyond the capabilities of the event editor's built in commands but I'm hoping it may be possible with script calls. It is okay if the list of possible random numbers to generate has to be created by hand - this might even be preferable because then I can use Map ID's directly instead of having events intended to convert the RNG result into an actual, usable Map ID.
The most important part of the question is the RNG implementation itself, as it should be applicable to more scenarios than the one I'm using (that said, if you know a better way to do what I'm trying to do, by all means tell me). As an example of what I want to happen in a very general form:
RNG chooses from the following list: [1, 2, 3, 4]
Run some events based on this choice.
Suppose "3" was chosen.
RNG chooses another value from the list, which is now [1, 2, 4]
Run some more events based on this choice.
The list needs to be restored to its original state whenever the common event used to generate the dungeon is called.
It is also preferable if I can check how many items are on the list (this will be especially important when I look into implementing a system to make sure everything connects properly, which I have a rough idea of how to go about doing that needs a proof-of-concept still).
I have a thought on the implementation, but I don't know how to make use of Javascript (I assume script calls would use that as well, yes?) to pull it off:
Create a list. A preset one, hard-coded into the common event governing the dungeon generation, should suffice.
Use a random number between 1 and n, where n is the size of the list, to select an element from the list. (may actually be 0 and/or n-1 because indexing; I'm not sure how it works in Javascript, assuming Javascript even HAS lists in it like Python does)
Store this number in a variable and remove it from the list.