[plugin] Not Quite Random

0 favourites
  • 7 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Hi. A few psuedo-random number generator plugins are already available, but none of them achieve what this plugin can do (AFAIK...). My current project needed this, so I rolled my sleeves up, learned a bit of JavaScript and created my first ever c2 plugin!! Please feel free to use it in your projects; if you make it big as a result then shout out to me and I'll be satisfied.

    What does it do? This plugin creates random numbers that conform to non-linear distribution curves. The random(range) expression offers no bias to producing numbers that are near the middle of the range. For example, with a range of 100, 1 is as likely to be returned as is 50. That might fit your needs, but if you want to scatter or spread your random numbers with some bias then this plugin should provide a useful method.

    For example - here's a scatter of returned values from a Math.random() expression (x axis = 0 to 1, y axis = frequency, from 50k runs):

    And here are a few examples of what can be produced by this plugin:

    Demo

    Plugin

    The plugin is on Github, so feel free to modify / improve etc as you desire. The .js library was obtained from here and a good demo of its speed and versatility can be found here - although not all methods have been implemented because I didn't see the need for some of the distribution patterns.

    Distribution options available (% figures are speed of execution compared to Math.random):

      1 Precision Normal Distribution - Gaussian distribution (20%) 2 Precision Custom Loaded - High Quality (20%) 3 Range Float - Uniformly distributed numbers in range (like random()) (90%) 4 Range Integer - Uniformly distributed integers (inclusive) (70%) 5 Range Loaded - Middle/End loaded numbers in range (30%) 6 Game Normal - Normal shaped game distribution (30%) 7 Game Spire - Spire shaped game distribution (50%) 8 Game Thorn - Thorn shaped game distribution (30%) 9 Game Trapezoid - Trapezoid game distribution (50%) 10 Game Bowl - Bowl shaped game distribution (50%) 11 Game Wedge - Wedge shaped game distribution (30%) 12 Game Teat - Teat shaped game distribution (30%)

    Thanks.

  • Nice to have some more rng options.

    Makes me want to stay away from Vegas however.

    Grats.

  • question can this plugin deal with dynamic Ai situation based. As in if the Ai is almost dead intead of being a blood thristy attacker it should start to think about defend or using a heal from an ally or an item. as oppose to when it has 100% hp it should relie on attacking.

    And what about making it a bit smarter as in if you are weak against a particular spell it should be thinking to use that but if you fully resist it as in if it use an attack and it didnt work on you the first time drop it ? and use a different number placement?

    Because often times ive seen random number to alway choose one number and its irrating as hell like choose 1 2 3. so that 30% effective choice......1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 oh hi 3 back to 1111111. you can understand this fusteration.

  • question can this plugin deal with dynamic Ai situation based. As in if the Ai is almost dead intead of being a blood thristy attacker it should start to think about defend or using a heal from an ally or an item. as oppose to when it has 100% hp it should relie on attacking.

    And what about making it a bit smarter as in if you are weak against a particular spell it should be thinking to use that but if you fully resist it as in if it use an attack and it didnt work on you the first time drop it ? and use a different number placement?

    Because often times ive seen random number to alway choose one number and its irrating as hell like choose 1 2 3. so that 30% effective choice......1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 oh hi 3 back to 1111111. you can understand this fusteration.

    This plugin will only generate a random number; the AI is for you to manage in events. Depending on the distribution profile you select, it will produce a 'loaded' random number to fit that profile. Have a look at the demo if you're not sure / I'll try to answer if you have more questions.

  • Nice work Bender!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Cheers, Unconnected!

  • When installing it into the "Program Files\Construct 2\exporters\html5\Plugins" folder you have to move the contents of the "src" back one file in the file tree.

    In other words you have to take the contents of "Src" out of the "Src" folder and place it where the "Src" folder is.

    It took me a small bit to figure that out.

    Works great too, Thanks again.

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