Loss streak probability distribution

 Loss streak probability distribution

This StencylWork is a simulated proiability distribution for straight up bets in roulettes . It shows that even in straight up bets, the longer the losing streak, the less occurance In fact winning streak occurs the most(2.564%) among all lose streaks. In this case, a triple-zero Roulette or Sands Roulette or equivalent after 2.1 billion bets. There  


Game project settings:
Physics: simple
Collision relationship and sensing disabled

Codes:
The scene behavior
package scripts;
import com.stencyl.Engine;
import com.stencyl.behavior.SceneScript; 
import com.stencyl.behavior.Script; 

class Sce0_behav extends SceneScript
{
public var f:F2 = new F2(); 
public var rows:Int = 50; public var colu:Int = 6; public var lag_check:Int =0; 
public function new(){super();}
override public function init()
{
//this.f.f_cu = Script.getFont(6); //this.f.color = 16777215; 
this.f.lesp = -2; 
Script.createRecycledActor(Script.getActorType(0), 5, 5, Script.FRONT);
Script.createRecycledActor(Script.getActorType(2), 250, 5, Script.FRONT);
Script.createRecycledActor(Script.getActorType(7), 550, 5, Script.FRONT);
Script.createRecycledActor(Script.getActorType(4), 630, 5, Script.FRONT);
Engine.engine.whenDrawingListeners.push(dwg);
}

public function dwg(u0,u1,u2,u3)
{
this.f.drawString("win 1 in: " + Lspd_data.win_1_in,6, 38);
this.f.drawString("bets_per_session: " + Lspd_data.number_of_bets,256, 38);
this.f.drawString("total bets: " + Lspd_data.total_bets,800,0);
this.f.drawString("partial streak: " + Lspd_data.partial_streak,800,15);
this.f.drawString("wins: " + Lspd_data.wins,800,30);
this.f.drawString("lag_check: " + this.lag_check,1100,0); this.lag_check +=1; 

var a:Int =0; var b:Int =0; var c =0; 
while(a < colu)
{
b =0; while(b < rows)
{
this.f.drawString("lose streak: " +c+ ", ocur: " + Lspd_data.lose_streaks[c],a * 300,100 + b*16);
b = b +1; c = c+1; 
}
a = a+1; 
}
this.f.drawString("lose streak 300 or more longer ocur: " + Lspd_data.lose_streaks[300],6,80);
}
}

bet button
package scripts;
import com.stencyl.behavior.ActorScript;

class Bet_behav extends ActorScript 
{
public var mos: Bool = false;  public var rh:RH = new RH(); 
public var x:Float; public var y:Float; public var w:Float; public var h:Float; 
public function new (a,b,c){super(b);}
override public function init()
{
actor.handlesCollisions = false; 
actor.whenDrawingListeners.push(dwg);
actor.mouseOverListeners.push(mis);
this.w = actor.cacheWidth; this.h = actor.cacheHeight;
this.x = actor.getX(); this.y = actor.getY(); 
}

public function dwg(u0,u1,u2,u3)
{
if(this.mos){this.rh.dRH(this.x,this.y,this.w,this.h);}
}

public function mis(ms:Int,u0)
{
if(ms ==-1){this.mos = false;}
else if(ms == 1){this.mos = true;}
else if(ms == 3){this.bet();}
}

public function bet()
{
var bet_remains = Lspd_data.number_of_bets; 
while(bet_remains > 0)
{
if(Math.random() < 1/ Lspd_data.win_1_in) // win
{
if(Lspd_data.partial_streak >= 300)
{
if(Lspd_data.lose_streaks[300]== null||""+Lspd_data.lose_streaks[300] == "undefined"){Lspd_data.lose_streaks[300] = 1;}
else Lspd_data.lose_streaks[300] +=1; 
}
else 
{
if(Lspd_data.lose_streaks[Lspd_data.partial_streak]==null ||""+Lspd_data.lose_streaks[Lspd_data.partial_streak]=="undefined"){Lspd_data.lose_streaks[Lspd_data.partial_streak]=1;}
else Lspd_data.lose_streaks[Lspd_data.partial_streak] +=1; 
}
Lspd_data.partial_streak = 0; Lspd_data.wins += 1; 
}
else // lose
{
Lspd_data.partial_streak +=1; 
}
bet_remains -= 1; Lspd_data.total_bets +=1; 
}
}
}

adjust number of bets per session
package scripts;
import com.stencyl.behavior.ActorScript;

class NOB_behav extends ActorScript
{
public var f:F2 = new F2(); public var line: Dline = new Dline(); 
public var mos: Bool = false;  public var rh:RH = new RH(); 
public var x:Float; public var y:Float; public var w:Float; public var h:Float; 

public var pos_px:Float =0; public var pos_int:Int =0; public var max_digit:Int = 9; public var text:String = ""; 
public function new(a,b,c){super(b);}
override public function init()
{
actor.handlesCollisions = false; 
actor.whenDrawingListeners.push(dwg);
actor.mouseOverListeners.push(mis);
this.w = actor.cacheWidth; 
this.h = actor.cacheHeight;
this.x = actor.getX(); this.y = actor.getY(); 

addKeyStateListener("0",press_0); addKeyStateListener("1",press_1); addKeyStateListener("2",press_2); addKeyStateListener("3",press_3); addKeyStateListener("4",press_4); 
addKeyStateListener("5",press_5); addKeyStateListener("6",press_6); addKeyStateListener("7",press_7); addKeyStateListener("8",press_8); addKeyStateListener("9",press_9); 

addKeyStateListener("erase",erase); 
addKeyStateListener("left",left); 
addKeyStateListener("right",right); 
}

public function dwg(u0,u1,u2,u3)
{
if(this.mos)
{
var type_indp:Int = Std.int(this.x + 150 + this.pos_px);  
this.rh.dRH(this.x,this.y,this.w, this.h);
this.line.draw(type_indp,this.y+3,type_indp,this.y+ this.h-3);
}
this.f.drawString(this.text,this.x+150,this.y+8); 
}

public function mis (ms:Int, u0)
{
if(ms == -1)
{
this.mos = false;
var exit_value:Float = 0;
var a:Int =0; var b:Int =0, c:Float=0;
var pow:Int = this.text.length-1; 

while(a < this.text.length)
{
if(this.text.charAt(a) =="1")b=1;
else if(this.text.charAt(a) =="2")b=2;
else if(this.text.charAt(a) =="3")b=3;
else if(this.text.charAt(a) =="4")b=4;
else if(this.text.charAt(a) =="5")b=5;
else if(this.text.charAt(a) =="6")b=6;
else if(this.text.charAt(a) =="7")b=7;
else if(this.text.charAt(a) =="8")b=8;
else if(this.text.charAt(a) =="9")b=9;
else b=0; 
c = Math.pow(10,this.text.length -a -1);
exit_value += c*b; 
a +=1; 
}
Lspd_data.number_of_bets = Std.int(exit_value); 
}
else if(ms == 1){this.mos = true;}
}

// typing feature
public function erase(p,r,u0)
{
if(p && this.mos)
{
if(this.pos_int > 0)
{
this.pos_px -=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int-1)] + this.f.lesp;
this.text = this.text.substring(0,this.pos_int-1) + this.text.substring(this.pos_int,this.text.length);
this.pos_int -=1;
}
}
}
public function press_0(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "0" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_1(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "1" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_2(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "2" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_3(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "3" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_4(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "4" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_5(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "5" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_6(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "6" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_7(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "7" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_8(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "8" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_9(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "9" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function left(p,r,u0):Void
{
if(p && this.mos)
{
if(this.pos_int > 0){this.pos_int -=1;}
if(this.pos_px > 0){this.pos_px -= this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;}
}
}
public function right(p,r,u0)
{
if(p&& this.mos)
{
if(this.pos_int < this.text.length)
{
this.pos_px += this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp; 
this.pos_int +=1;
}
}
}
}

reset button
package scripts;
import com.stencyl.behavior.ActorScript;

class Reset_behav extends ActorScript
{
public var mos: Bool = false;  public var rh:RH = new RH(); 
public var x:Float; public var y:Float; public var w:Float; public var h:Float; 
public function new (a,b,c){super(b);}
override public function init()
{
actor.handlesCollisions = false; 
actor.whenDrawingListeners.push(dwg);
actor.mouseOverListeners.push(mis);
this.w = actor.cacheWidth; this.h = actor.cacheHeight;
this.x = actor.getX(); this.y = actor.getY(); 
}

public function dwg(u0,u1,u2,u3)
{
if(this.mos){this.rh.dRH(this.x,this.y,this.w,this.h);}
}

public function mis(ms:Int,u0)
{
if(ms ==-1){this.mos = false;}
else if(ms == 1){this.mos = true;}
else if(ms == 3){this.reset();}
}

public function reset()
{
Lspd_data.wins =0;
Lspd_data.total_bets =0; 
Lspd_data.lose_streaks = []; 
Lspd_data.partial_streak = 0; 
}
}

Setting winning probability for straight up bets. 
  package scripts;
import com.stencyl.behavior.ActorScript; 

class Win_1_in_behav extends ActorScript
{
public var f:F2 = new F2(); public var line: Dline = new Dline(); 
public var mos: Bool = false;  public var rh:RH = new RH(); 
public var x:Float; public var y:Float; public var w:Float; public var h:Float; 

public var pos_px:Float =0; public var pos_int:Int =0; public var max_digit:Int = 9; public var text:String = ""; 
public function new(a,b,c){super(b);}
override public function init()
{
actor.handlesCollisions = false; 
actor.whenDrawingListeners.push(dwg);
actor.mouseOverListeners.push(mis);
this.w = actor.cacheWidth; 
this.h = actor.cacheHeight;
this.x = actor.getX(); this.y = actor.getY(); 

addKeyStateListener("0",press_0); addKeyStateListener("1",press_1); addKeyStateListener("2",press_2); addKeyStateListener("3",press_3); addKeyStateListener("4",press_4); 
addKeyStateListener("5",press_5); addKeyStateListener("6",press_6); addKeyStateListener("7",press_7); addKeyStateListener("8",press_8); addKeyStateListener("9",press_9); 

addKeyStateListener("erase",erase); 
addKeyStateListener("left",left); 
addKeyStateListener("right",right); 
}

public function dwg(u0,u1,u2,u3)
{
if(this.mos)
{
var type_indp:Int = Std.int(this.x + 83 + this.pos_px);  
this.rh.dRH(this.x,this.y,this.w, this.h);
this.line.draw(type_indp,this.y+3,type_indp,this.y+ this.h-3);
}
this.f.drawString(this.text,this.x+83,this.y+8); 
}

public function mis (ms:Int, u0)
{
if(ms == -1)
{
this.mos = false;
var exit_value:Float = 0;
var a:Int =0; var b:Int =0, c:Float=0;
var pow:Int = this.text.length-1; 

while(a < this.text.length)
{
if(this.text.charAt(a) =="1")b=1;
else if(this.text.charAt(a) =="2")b=2;
else if(this.text.charAt(a) =="3")b=3;
else if(this.text.charAt(a) =="4")b=4;
else if(this.text.charAt(a) =="5")b=5;
else if(this.text.charAt(a) =="6")b=6;
else if(this.text.charAt(a) =="7")b=7;
else if(this.text.charAt(a) =="8")b=8;
else if(this.text.charAt(a) =="9")b=9;
else b=0; 
c = Math.pow(10,this.text.length -a -1);
exit_value += c*b; 
a +=1; 
}
Lspd_data.win_1_in = Std.int(exit_value); 
}
else if(ms == 1){this.mos = true;}
}

// typing feature
public function erase(p,r,u0)
{
if(p && this.mos)
{
if(this.pos_int > 0)
{
this.pos_px -=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int-1)] + this.f.lesp;
this.text = this.text.substring(0,this.pos_int-1) + this.text.substring(this.pos_int,this.text.length);
this.pos_int -=1;
}
}
}
public function press_0(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "0" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_1(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "1" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_2(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "2" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_3(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "3" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_4(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "4" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_5(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "5" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_6(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "6" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_7(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "7" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_8(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "8" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function press_9(p,r,u0) // press[A]
{
if(p && this.mos)
{
if(this.text.length < this.max_digit)
{
this.text = this.text.substring(0,this.pos_int) + "9" + this.text.substring(this.pos_int,this.text.length);
this.pos_px +=  this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;
this.pos_int +=1; 
}
}
}
public function left(p,r,u0):Void
{
if(p && this.mos)
{
if(this.pos_int > 0){this.pos_int -=1;}
if(this.pos_px > 0){this.pos_px -= this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp;}
}
}
public function right(p,r,u0)
{
if(p&& this.mos)
{
if(this.pos_int < this.text.length)
{
this.pos_px += this.f.fs_char_width[this.text.charCodeAt(this.pos_int)] + this.f.lesp; 
this.pos_int +=1;
}
}
}
}

the interbehavior stuffs. 
package scripts;
class Lspd_data
{
public static var lose_streaks:Array <Int> = []; 
public static var number_of_bets:Int = 1; 
public static var partial_streak: Int =0; 
public static var win_1_in:Int = 39; 
public static var wins:Int =0; 
public static var total_bets:Int =0; 

public static function reset()
{
Lspd_data.lose_streaks = [];
Lspd_data.total_bets = 0;  
}
}

drawing systems are very sililar to drawing wothout G. 

No comments:

Post a Comment