forked from CookieMonsterTeam/CookieMonster
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added cummulative probability handling
- Loading branch information
1 parent
ca1c28d
commit e083c4a
Showing
4 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* The probability that a GC or reindeer has NOT spawned | ||
*/ | ||
let chanceTotal = 1.0; | ||
let chanceTotalDeer = 1.0; | ||
|
||
export function resetChanceTotal() { | ||
chanceTotal = 1.0; | ||
} | ||
|
||
export function resetChanceTotalDeer() { | ||
chanceTotalDeer = 1.0; | ||
} | ||
|
||
export function getChanceTotal() { | ||
return chanceTotal; | ||
} | ||
|
||
export function getChanceTotalDeer() { | ||
return chanceTotalDeer; | ||
} | ||
/** | ||
* Update the probability that a cookie has not spawned | ||
* @param {number} chanceToSpawn The probablity that a GC appears | ||
*/ | ||
export function updateChanceTotal(chanceToSpawn) { | ||
chanceTotal *= 1 - chanceToSpawn; | ||
} | ||
|
||
/** | ||
* Update the probability that a reindeer has not spawned | ||
* @param {number} chanceToSpawn The probablity that a reindeer appears | ||
*/ | ||
export function updateChanceTotalDeer(chanceToSpawn) { | ||
chanceTotalDeer *= 1 - chanceToSpawn; | ||
} | ||
/** | ||
* | ||
* @returns the cummulative probability that a GC has appeared from beginning to now | ||
*/ | ||
export function getChanceFinal() { | ||
return 1 - chanceTotal; | ||
} | ||
/** | ||
* | ||
* @returns the cummulative probability that a reindeer has appeared from beginning to now | ||
*/ | ||
export function getChanceFinalDeer() { | ||
return 1 - chanceTotalDeer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters