Jump to content

Labouchere hashdice scrypt


findyou

Recommended Posts

Here is an Others Script for hashdice ist called labouchere ... Have fun with it

 

var config = {
  bet: { label: "bet profit(Min allowed amount / split)", value: 0.0002, type: "number" },
  splitSize: { label: "Size of Split", value: 20, type: "number" },
  cycleSize: { label: "Maximum number of Cycles", value: 200, type: "number" },
  payout: { label: "payout", value: 2.1, type: "number" },

};

var betAmount = 0;
var iterationCount = 0;
var betCount = 0;

function createArray(profit,splitSize){
  var item = strip(profit/splitSize);
  var splits = [];
  for (var i=0;i<splitSize; i++){
    splits.push(item);
  }
  return splits;

}
var bettingArray;
function main() {
  bettingArray = createArray(config.bet.value,config.splitSize.value);
  betAmount = strip(bettingArray[0] + bettingArray[bettingArray.length-1]);
  
  game.onBet = function() {
    game.bet(betAmount, config.payout.value).then(function(payout) {
      betCount++;
      var message = betAmount + " NewBet" + betAmount + 
        " Bets Remaining[" + bettingArray.length + "]";
      if (payout > 1) {
        log.success(iterationCount + " Won! " +  message);
        console.log(iterationCount + " Won! " + betAmount);
        bettingArray.shift();
        bettingArray.pop();
      } else {
        bettingArray.push(betAmount);
        log.error("Lost!  " + message);
        console.log("Lost!  " + betAmount);
      }
      if(bettingArray.length == 0 || betCount == config.cycleSize.value){
        console.log("Resetting the bet!");
        bettingArray = createArray(config.bet.value,config.splitSize.value);
        iterationCount++;
        betCount = 0;
        clearConsoleLog();
      }
      if(bettingArray.length == 1){
        betAmount = bettingArray[0];
      }else{
        betAmount = strip(bettingArray[0] + bettingArray[bettingArray.length-1]);
      }
      
      console.log(betCount + " NewBet" + betAmount + 
        " BettingAray[" + bettingArray.length + "]" +
        bettingArray.join(" "));
      
    });
  };
}

function clearConsoleLog(){ 
  
  console.log("Restarting!"); 
}
function strip(number) {
    return (parseFloat(number).toPrecision(10))/1;
}

Link to comment
Share on other sites

what design decision made you think it was a better idea to create and array and store all of your current and future bet values in it to just push and pop them?  It would be much more performant and user friendly if you had just used a for loop or even a while loop so that it isn't always going to get a fixed number of bets.  i would expect most scripts to0 have a flow generally of (figure out how much to bet) -> bet and wait the outcome-> decision tree based of win lose-> decision tree on if to stop based on user input-> start new flow or end script.  But essentially for this if i wanted to run it for 100000 games or something your browser memory if going 6to bloat and slow your entire system down,.

 

Link to comment
Share on other sites

  • 10 months later...
  • 3 months later...

I asked ChatGPT to optimize the script and this was the result, I really don't know how beneficial it was because I don't know anything about programming, but it works fine and I wanted to leave it in case it helps someone or if someone can clarify which version it is better

 

const config = {
  betProfit: { label: "bet profit (Min allowed amount / split)", value: 0.002, type: "number" },
  splitSize: { label: "Size of Split", value: 20, type: "number" },
  cycleSize: { label: "Maximum number of Cycles", value: 200, type: "number" },
  payout: { label: "payout", value: 2.1, type: "number" }
};

let betAmount;
let iterationCount = 0;
let betCount = 0;
let bettingArray;

function createBetArray(profit, splitSize) {
  return Array.from({ length: splitSize }, () => profit / splitSize);
}

function main() {
  bettingArray = createBetArray(config.betProfit.value, config.splitSize.value);
  betAmount = bettingArray[0] + bettingArray[bettingArray.length - 1];

  game.onBet = function() {
    game.bet(betAmount, config.payout.value).then(function(payout) {
      betCount++;
      if (payout > 1) {
        console.log(`${iterationCount} Won! ${betAmount} NewBet. Bets Remaining [${bettingArray.length}]`);
        bettingArray.shift();
        bettingArray.pop();
      } else {
        bettingArray.push(betAmount);
        console.error(`Lost! ${betAmount} NewBet. Bets Remaining [${bettingArray.length}]`);
      }
      if (bettingArray.length === 0 || betCount === config.cycleSize.value) {
        console.log("Resetting the bet!");
        bettingArray = createBetArray(config.betProfit.value, config.splitSize.value);
        iterationCount++;
        betCount = 0;
      }
      betAmount = bettingArray.length === 1 ? bettingArray[0] : bettingArray[0] + bettingArray[bettingArray.length - 1];
      console.log(`${betCount} NewBet ${betAmount}. Betting Array [${bettingArray.length}]`);
    });
  };
}
 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...