javascript 简单的鞅重复下注X后连续连胜

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 简单的鞅重复下注X后连续连胜相关的知识,希望对你有一定的参考价值。

const baseBet = 100                    // how many satoshis to bet initially
const target = 2.00                    // target multiplier

const betMultiplier = 2                // what to multiply the bet size by when we lose a wager
const stopGameAfterLoss = 7             /* Trigger will lead to drop/stop script */
const sleepTimeInMS = 100
const dropInsteadOfStopScript = true    /* stop script or drop losses and continue play  */
const changeSeed = 3                    /* How much losses obtain, and then change seed to decrease chance of big streak, 0 to disable */

const engine = this

let lossCount = 0

this.log(`Starting simple martingale with a base bet of ${baseBet} satoshis.`)

while (true) {
  await sleep(sleepTimeInMS)
  if (lossCount >= stopGameAfterLoss){
      if (dropInsteadOfStopScript == true){
          lossCount = 0
        } else{
            await this.stop()
          }
      }
      
    if (lossCount > changeSeed && changeSeed != 0) {
        await generateSeed()
    }
  // make the bet and wait for the result
  const { multiplier } = await this.bet(betSize(lossCount), target)

  if (multiplier < target) { // loss
    collectSound()
    lossCount++
    this.log(`Lost bet. Multiplying bet size by ${betMultiplier} for new bet size of ${betSize(lossCount)} satoshis.`)
  } else { // win
    gong()
    lossCount = 0
    this.log(`Won bet. Setting bet size to ${baseBet} satoshis.`)
  }
}

function betSize(lossCount) {
  const bet = baseBet * Math.pow(betMultiplier, lossCount)
  return Math.round(bet / 100) * 100
}

function gong() {
    const audio = new Audio("https://bustadice.com/5bb187b7ef764e76fb519939f77288c1.mp3")
    audio.play()
    return new Promise(resolve => audio.onended = resolve)
  }
  function collectSound(){
    let pathStr = "http://kz-developer.ru/sounds/chipsHandle" + getRandomInt(6,7) + ".wav"

      
      const audio = new Audio (pathStr)
      audio.play()
      return new Promise(resolve => audio.onended = resolve)
  }
 
  async function generateSeed(){
      const { server_seed_hash } = await engine.newSeedPair()
      engine.log(`Server seed: ${server_seed_hash}`)
      try {
          const clientSeed = randomSeed()
          await engine.setClientSeed(clientSeed)
          engine.log(`Seed was set to: ${clientSeed}`)
      }
      catch(e){
          engine.log(`Client seed already was reset and not used`)
      }
  }
  
  function randomSeed(){
      const words = ['Alegra ','Bravon ','Charlik ','Delago ','Zecho ','Forextromb ','Hotelka ','Gnomus ','Addicted ','Aurelia ','Zigalo ','Wiverma ',
      'Mariner ','Octoberfest ','Nascar ','Papaja ','Alberts ','Gomus ','Fierra ','GTO ','Unicorn ','Vicantus ','Siski ','Xavier ','Poiuplet ','Antutulika ']
  
      return words[Math.floor(words.length * Math.random())] + words[Math.floor(words.length * Math.random())] + words[Math.floor(words.length * Math.random())]
  }
  
  function getRandomInt(min, max){
      return Math.floor(Math.random() * (max - min)) + min;
  }

 async function sleep(ms){return new Promise(resolve => setTimeout(resolve, ms))}

以上是关于javascript 简单的鞅重复下注X后连续连胜的主要内容,如果未能解决你的问题,请参考以下文章

javascript 1.3x比赛,失利1.1x 3轮和下注乘数5

javascript 5次下注后增加的基础筹码

在熊猫队中连续几周获得最长连胜纪录

javascript 两连胜Promise链

如何计算每位球员的最长连胜纪录

如何对 RDD 中的项目进行排名以建立连胜?