Skip to content

Drop chance over time. #5

@VictorioBerra

Description

@VictorioBerra

A cool feature would be to lower the chance over time.

This would be all the variables needed for the simplest linear dropoff. Calculate the span of time between start and end, and based on where we are at time of emission, determine the current chance, and then roll.

  • StartChance
  • EndChance
  • StartDateTIme
  • EndDateTime

Example

The below example shows that a tell starting at 100% and ending at 5% would have 62.7% of emitting its response if it were triggered 40 hours into its life. (life being the hours between start and end DateTime).

  • Start: 10/10/2018 12:00 (MM/DD/YYYY HH:MM)
  • End: 10/15/2018 12:00
  • Start Chance: 100%
  • End Chance: 5%
  • Emission DateTime: 10/12/2018 4:00
var TotalHours = Math.abs(new Date('2018-10-10T12:00:00') - new Date('2018-10-15T12:00:00')) / 36e5;
// 120 total hours
var hours = Math.abs(new Date('2018-10-12T04:00:00') - new Date('2018-10-15T12:00:00')) / 36e5;
// 80 hours left

var progressBar =  hours / totalHours; // .66 (66%)

var possiblePercentage = StartChance - EndChance; // 95 (95%)

var currentChanceInTime = possiblePercentage * progressBar;  // 62.7%

There are probably different ways to create a curve, but this is incredibly simple and the code above is a live working prototype of the algorithm.

I am open to any libraries that would make this easier or even more configurable. For example, this would not allow a steep drop off after the first 5% of its life, and then the drop would slow.

You could also introduce a step amount, but I am not sure what that would look like programatically. Snap to the nearest step maybe?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions