Advanced Random Probability Tables

  • construct.net/en/make-games/manuals/construct-3/plugin-reference/advanced-random

    There's an action to create a named table, but no way to reference any specific table.

    Is that planned for the future?

    I hope so, because the ability to have more than one would be quite useful.

    Then again we also have an acton to set, or I guess rename the current probability table which doesn't make sense as is if there's only one table.

    Finally we have an action to remove a probability entry, which I would expect, but it also includes the entry weight. I don't see the point of that. I mean I thought there was just one weight to each entry.

    Thanks.

  • You can create as many probability tables as you want. You need to set the table before using the AdvancedRandom.Weighted expression to generate a value from the desired table:

    dropbox.com/s/uyyh6ysseszs9qq/Advanced%20Random.c3p

    It would be nicer to be able to call the table directly from the expression itself e.g. AdvancedRandom.Weighted("Table1").

    I believe you can have multiple entries on the table with the same name, hence the requirement to state the weighting. Why you would want duplicates I'm not sure - perhaps because you can't change a weighting for an entry once it's been added?

    It would also be nice to be able to import a table from json rather than having to set all the entries as actions.

  • mekonbekon is right on both counts.

    When a table is created it's added to a dictionary, using the name as a key, and is set as the "active" table. Using "Set probability table" gets the one with the given name from the dictionary and sets it as the "active" table. The weighted expression always uses the "active" table.

    Entries in a probability table are not unique, you can have multiple ones with the same name and/or weight. The reasoning is that it allows you to merge multiple lists into a single table, without having to look for and merge duplicates. You can pass a weight of "0" in and it will remove the first entry with a matching name. It gives more flexibility, but I never decided if it was more complex than what people needed it for.

    In terms of other stuff you've chatted about, there is probably some room for polish. While it was something we considered useful we got fairly minimal feedback at the time it was released, so it hasn't been adjusted much.

    You can't change the weight of an entry after it's been created, but you can always remove it and add a new one with a higher value.

    Importing from JSON might be nice, but it's quite easy to do with a for loop already ( parse JSON, for each: add probability entry ).

    I did consider adding a variation of "Weighted" that also took a table name, but again it's quite easy to do without. It's easy to bloat plugins with too many features and ACEs, which then makes them hard to maintain. Unless something is impossible to do, or it's a really useful shortcut we avoid adding such features.

    One thing that does occur to me as useful would be the ability to read all the entries in the table, so that it can be serialized for later ( if for example certain drops were removed after being obtained and you wanted that to be preserved without having to keep another list somewhere ).

  • mekonbekon Thanks for the example, that sort of makes sense.

    Speaking of, I do recall some games having multiple probabilities for things like drops. So in theory something could have both a 10% chance, and a 50% chance of dropping.

    Nepeo Yes both the table import, and expression sound nice. I'm good with where we are however. Thanks for clearing that up.

  • Yeah, JSON import would be neato

  • Nepeo What about the possibility of adding a seed to probabilities?

    Like for example you wanted to make a map, and have a chance that a tile was a rock, or a tree, etc.

  • Nepeo What about the possibility of adding a seed to probabilities?

    Well in a way it's already seeded, it uses the PRNG that AdvancedRandom includes. Each time you use the expression to get a value from it a new random number is generated which is then used to pick one of the options. If your using a fixed seed, and the order of PRNG uses is predictable then you would get the same output each time.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok, cool.

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