Last active
November 16, 2023 03:04
-
-
Save dsetzer/40801db5f3b2df4ade568002fb1700ee to your computer and use it in GitHub Desktop.
A few martingale oriented inverse utility functions.
This file contains hidden or 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
/** | |
* Calculates the base bet from the current wager, multiplier, and streak. | |
* | |
* @param {number} wager - The current wager. | |
* @param {number} multi - The multiplier. | |
* @param {number} streak - The streak. | |
* @returns {number} - The calculated base bet. | |
*/ | |
const getBaseBetFromCurrent = (wager, multi, streak) => (wager / (multi ** streak)); | |
/** | |
* Calculates the bet size for a given streak based on the base bet, multiplier, and streak. | |
* | |
* @param {number} base - The base bet. | |
* @param {number} multi - The multiplier. | |
* @param {number} streak - The streak. | |
* @returns {number} - The calculated bet size for the streak. | |
*/ | |
const getBetSizeForStreak = (base, multi, streak) => (base * (multi ** streak)); | |
/** | |
* Calculates the total bet sum for a given streak based on the base bet, payout, multiplier, and streak. | |
* | |
* @param {number} base - The base bet. | |
* @param {number} payout - The payout multiplier. | |
* @param {number} multi - The multiplier. | |
* @param {number} streak - The streak. | |
* @returns {number} - The calculated total bet sum for the streak. | |
*/ | |
const getBetSumForStreak = (base, payout, multi, streak) => (base * (multi ** streak) * payout) - (base * (payout - 1)); | |
/** | |
* Calculates the streak size from the base bet, current wager, and multiplier. | |
* | |
* @param {number} base - The base bet. | |
* @param {number} wager - The current wager. | |
* @param {number} multi - The multiplier. | |
* @returns {number} - The calculated streak size. | |
*/ | |
const getStreakSizeFromBet = (base, wager, multi) => (Math.log(wager / base) / Math.log(multi)); | |
/** | |
* Calculates the previous bet from the last bet and multiplier. | |
* | |
* @param {number} wager - The last wager. | |
* @param {number} multi - The multiplier. | |
* @returns {number} - The calculated previous bet. | |
*/ | |
const getPrevBetFromLastBet = (wager, multi) => (wager / multi); | |
/** | |
* Calculates the bet multiplier from the current wager and previous bet. | |
* | |
* @param {number} wager - The current wager. | |
* @param {number} prev - The previous bet. | |
* @returns {number} - The calculated bet multiplier. | |
*/ | |
const getBetMultiFromPrevBet = (wager, prev) => (wager / prev); | |
/** | |
* Calculates the optimal bet multiplier for a given payout. | |
* | |
* @param {number} payout - The payout multiplier. | |
* @returns {number} - The calculated bet multiplier. | |
*/ | |
const getBetMultiForPayout = (payout) => (payout / (payout - 1)); | |
/** | |
* Calculates the payout from the bet multiplier. | |
* | |
* @param {number} multi - The bet multiplier. | |
* @returns {number} - The calculated payout. | |
*/ | |
const getPayoutFromBetMulti = (multi) => (multi / (multi - 1)); |
This file contains hidden or 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
// Example usage for getBaseBetFromCurrent | |
// Returns the base bet for a wager of 100, multiplier of 2, and streak of 3. | |
const baseBet = getBaseBetFromCurrent(100, 2, 3); // 12.5 | |
// Example usage for getBetSizeForStreak | |
// Returns the bet size for a base bet of 50, multiplier of 2, and streak of 4. | |
const betSize = getBetSizeForStreak(50, 2, 4); // 800 | |
// Example usage for getBetSumForStreak | |
// Returns the total bet sum for a base bet of 25, payout of 3, multiplier of 2, and streak of 5. | |
const betSum = getBetSumForStreak(25, 3, 2, 5); // 2350 | |
// Example usage for getStreakSizeFromBet | |
// Returns the streak size for a base bet of 20, current wager of 80, and multiplier of 2. | |
const streakSize = getStreakSizeFromBet(20, 80, 2); //2 | |
// Example usage for getPrevBetFromLastBet | |
// Returns the previous bet for a last wager of 150 and multiplier of 2. | |
const prevBet = getPrevBetFromLastBet(150, 2); // 75 | |
// Example usage for getBetMultiFromPrevBet | |
// Returns the bet multiplier for a current wager of 120 and previous bet of 60. | |
const betMulti = getBetMultiFromPrevBet(120, 60); // 2 | |
// Example usage for getBetMultiForPayout | |
// Returns the bet multiplier for a payout of 2.5. | |
const payoutMulti = getBetMultiForPayout(2.5); // 1.66 | |
// Example usage for getPayoutFromBetMulti | |
// Returns the payout for a bet multiplier of 1.8. | |
const payout = getPayoutFromBetMulti(1.8); // 2.25 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment