Skip to content

Commit

Permalink
lua scripts refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
schwarzlichtbezirk committed Jan 7, 2025
1 parent ea9fe8b commit f0acff1
Show file tree
Hide file tree
Showing 55 changed files with 101 additions and 161 deletions.
18 changes: 8 additions & 10 deletions game/slot/betsoft/2millionbc/2millionbc_calc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,22 @@ import (

var Eacbn float64

func ExpAcorn() float64 {
func ExpAcorn() {
var sum float64
for _, v := range Acorn {
sum += float64(v)
}
var E = sum / float64(len(Acorn))
fmt.Printf("len = %d, E = %g\n", len(Acorn), E)
return E
Eacbn = sum / float64(len(Acorn))
}

var Edlbn float64

func ExpDiamondLion() float64 {
func ExpDiamondLion() {
var sum float64
for _, v := range DiamondLion {
sum += float64(v)
}
var E = sum / float64(len(DiamondLion))
fmt.Printf("len = %d, E = %g\n", len(DiamondLion), E)
return E
Edlbn = sum / float64(len(DiamondLion))
}

func CalcStatBon(ctx context.Context) float64 {
Expand Down Expand Up @@ -61,8 +57,10 @@ func CalcStatBon(ctx context.Context) float64 {

func CalcStatReg(ctx context.Context, mrtp float64) float64 {
fmt.Printf("*bonus games calculations*\n")
Eacbn = ExpAcorn()
Edlbn = ExpDiamondLion()
ExpAcorn()
fmt.Printf("len = %d, E = %g\n", len(Acorn), Eacbn)
ExpDiamondLion()
fmt.Printf("len = %d, E = %g\n", len(DiamondLion), Edlbn)
fmt.Printf("*bonus reels calculations*\n")
var rtpfs = CalcStatBon(ctx)
if ctx.Err() != nil {
Expand Down
1 change: 1 addition & 0 deletions game/slot/megajack/aztecgold/aztecgold_calc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var (
)

func ExpBonus() {
Epyr = 0
for i, p := range app {
Epyr += p * apm[i]
}
Expand Down
2 changes: 1 addition & 1 deletion game/slot/megajack/aztecgold/aztecpyramid.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var apm = [6]float64{
// aztec pyramids frequency
var apf [6]float64

// aztec pyramid probability on max 4 attempts
// aztec pyramid probability on max 3 attempts
var app [6]float64

const att = 3 // number of attempts
Expand Down
19 changes: 11 additions & 8 deletions game/slot/megajack/champagne/champagne_calc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ import (
"github.com/slotopol/server/game/slot"
)

var Emjc float64 // Bottle game calculated expectation
var (
Ebot float64 // expectation of 1 bottle
Emjc float64 // Bottle game calculated expectation
)

func ExpBottle() float64 {
func ExpBottle() {
// avr 1 bottle gain
var m float64
Ebot = 0
for _, v := range Bottles {
m += float64(v)
Ebot += float64(v)
}
m /= float64(len(Bottles))
Ebot /= float64(len(Bottles))

// expectation
var E float64
Expand All @@ -32,8 +35,7 @@ func ExpBottle() float64 {
}
}
E /= float64(n)
fmt.Printf("len = %d, avr bottle gain = %.5g, E = %g\n", len(Bottles), m, E)
return E
Emjc = E
}

func CalcStatBon(ctx context.Context, mrtp float64) float64 {
Expand Down Expand Up @@ -71,7 +73,8 @@ func CalcStatBon(ctx context.Context, mrtp float64) float64 {

func CalcStatReg(ctx context.Context, mrtp float64) float64 {
fmt.Printf("*bonus games calculations*\n")
Emjc = ExpBottle()
ExpBottle()
fmt.Printf("len = %d, avr bottle gain = %.5g, E = %g\n", len(Bottles), Ebot, Emjc)
fmt.Printf("*bonus reels calculations*\n")
var rtpfs = CalcStatBon(ctx, mrtp)
if ctx.Err() != nil {
Expand Down
22 changes: 10 additions & 12 deletions game/slot/megajack/slotopol/slotopol_calc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ import (
var Emje float64 // Eldorado game 1 spin calculated expectation

// Eldorado expectation.
func ExpEldorado() float64 {
func ExpEldorado() {
var sum float64
for _, v := range Eldorado {
sum += v
}
var E = sum / float64(len(Eldorado))
fmt.Printf("eldorado 1 spin: count = %d, E = %g\n", len(Eldorado), E)
return E
Emje = sum / float64(len(Eldorado))
fmt.Printf("eldorado 1 spin: count = %d, E = %g\n", len(Eldorado), Emje)
}

var Emjm float64 // Monopoly game calculated expectation

func ExpMonopoly() float64 {
func ExpMonopoly() {
var dices = [7]int{1, 1, 1, 1, 1, 1, 1}
var sumi, sumii, sumj float64
var count, zcount int = 6 * 6 * 6 * 6 * 6 * 6 * 6, 0
Expand Down Expand Up @@ -74,18 +73,17 @@ func ExpMonopoly() float64 {
}
dices[0] = dices[0]%6 + 1
}
var E = sumi / float64(count)
var v = sumii/float64(count) - E*E
Emjm = sumi / float64(count)
var v = sumii/float64(count) - Emjm*Emjm
var sigma = math.Sqrt(v)
fmt.Printf("monopoly: count = %d, sum = %g, zerocount = %d, p(zero) = 1/%d, E = %g\n", count, sumi, zcount, int(float64(count)/float64(zcount)), E)
fmt.Printf("monopoly: variance = %.6g, sigma = %.6g, limits = %.6g ... %.6g\n", v, sigma, E-sigma, E+sigma)
return E
fmt.Printf("monopoly: count = %d, sum = %g, zerocount = %d, p(zero) = 1/%d, E = %g\n", count, sumi, zcount, int(float64(count)/float64(zcount)), Emjm)
fmt.Printf("monopoly: variance = %.6g, sigma = %.6g, limits = %.6g ... %.6g\n", v, sigma, Emjm-sigma, Emjm+sigma)
}

func CalcStat(ctx context.Context, mrtp float64) float64 {
fmt.Printf("*bonus games calculations*\n")
Emje = ExpEldorado()
Emjm = ExpMonopoly()
ExpEldorado()
ExpMonopoly()
fmt.Printf("*reels calculations*\n")
var reels, _ = slot.FindReels(ReelsMap, mrtp)
var g = NewGame()
Expand Down
4 changes: 2 additions & 2 deletions game/slot/megajack/slotopoldeluxe/slotopoldeluxe_calc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

func CalcStat(ctx context.Context, mrtp float64) float64 {
fmt.Printf("*bonus games calculations*\n")
slotopol.Emje = slotopol.ExpEldorado()
slotopol.Emjm = slotopol.ExpMonopoly()
slotopol.ExpEldorado()
slotopol.ExpMonopoly()
fmt.Printf("*reels calculations*\n")
var reels, _ = slot.FindReels(ReelsMap, mrtp)
var g = NewGame()
Expand Down
9 changes: 4 additions & 5 deletions game/slot/playngo/fortuneteller/fortuneteller_calc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

var Ecards float64

func ExpCards() float64 {
func ExpCards() {
var sum float64
for c1 := 1; c1 <= 4; c1++ {
for c2 := 1; c2 <= 4; c2++ {
Expand All @@ -19,9 +19,7 @@ func ExpCards() float64 {
}
}
}
var E = sum / 4 / 4 / 4
fmt.Printf("total = %d, E = %g\n", 4*4*4, E)
return E
Ecards = sum / 4 / 4 / 4
}

func CalcStatBon(ctx context.Context, mrtp float64) float64 {
Expand Down Expand Up @@ -52,7 +50,8 @@ func CalcStatBon(ctx context.Context, mrtp float64) float64 {

func CalcStatReg(ctx context.Context, mrtp float64) float64 {
fmt.Printf("*bonus games calculations*\n")
Ecards = ExpCards()
ExpCards()
fmt.Printf("total = %d, E = %g\n", 4*4*4, Ecards)
fmt.Printf("*bonus reels calculations*\n")
var rtpfs = CalcStatBon(ctx, mrtp)
if ctx.Err() != nil {
Expand Down
9 changes: 4 additions & 5 deletions game/slot/playtech/goldentour/goldentour_calc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@ import (

var Egolfbn float64

func ExpGolf() float64 {
func ExpGolf() {
var sum float64
for _, v := range Golf {
sum += float64(v)
}
var E = sum / float64(len(Golf))
fmt.Printf("len = %d, E = %g\n", len(Golf), E)
return E
Egolfbn = sum / float64(len(Golf))
}

func CalcStat(ctx context.Context, mrtp float64) float64 {
fmt.Printf("*bonus games calculations*\n")
Egolfbn = ExpGolf()
ExpGolf()
fmt.Printf("len = %d, E = %g\n", len(Golf), Egolfbn)
fmt.Printf("*reels calculations*\n")
var reels, _ = slot.FindReels(ReelsMap, mrtp)
var g = NewGame()
Expand Down
6 changes: 2 additions & 4 deletions helper/2millionbc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,5 @@ local neighbours = {
}

math.randomseed(os.time())
local reel, iter = makereel(symset, neighbours)
printreel(reel, iter)
local reel5, iter5 = makereel(symset5, neighbours)
printreel(reel5, iter5)
printreel(makereel(symset, neighbours))
printreel(makereel(symset5, neighbours))
3 changes: 1 addition & 2 deletions helper/aislot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ local neighbours = {
}

math.randomseed(os.time())
local reel, iter = makereel(symset, neighbours)
printreel(reel, iter)
printreel(makereel(symset, neighbours))
3 changes: 1 addition & 2 deletions helper/alwayshot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ local chunklen = {
}

math.randomseed(os.time())
local reel, iter = makereelhot(symset, 3, {}, chunklen)
printreel(reel, iter)
printreel(makereelhot(symset, 3, {}, chunklen))
3 changes: 1 addition & 2 deletions helper/arabiannights.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ local neighbours = {
}

math.randomseed(os.time())
local reel, iter = makereel(symset, neighbours)
printreel(reel, iter)
printreel(makereel(symset, neighbours))
3 changes: 1 addition & 2 deletions helper/atthemovies.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ local neighbours = {
}

math.randomseed(os.time())
local reel, iter = makereel(symset, neighbours)
printreel(reel, iter)
printreel(makereel(symset, neighbours))
24 changes: 9 additions & 15 deletions helper/aztecgold.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ local path = arg[0]:match("(.*[/\\])")
dofile(path.."lib/reelgen.lua")

local symset1 = {
5, -- 1 tomat 100
5, -- 2 corn 100
4, -- 1 tomat 100
4, -- 2 corn 100
4, -- 3 lama 100
4, -- 4 frog 100
4, -- 5 jaguar 100
Expand All @@ -17,8 +17,8 @@ local symset1 = {
}

local symset2 = {
5, -- 1 tomat 100
5, -- 2 corn 100
4, -- 1 tomat 100
4, -- 2 corn 100
4, -- 3 lama 100
4, -- 4 frog 100
4, -- 5 jaguar 100
Expand Down Expand Up @@ -93,14 +93,8 @@ local neighbours = {
}

math.randomseed(os.time())
local reel, iter
reel, iter = makereel(symset1, neighbours)
printreel(reel, iter)
reel, iter = makereel(symset2, neighbours)
printreel(reel, iter)
reel, iter = makereel(symset3, neighbours)
printreel(reel, iter)
reel, iter = makereel(symset4, neighbours)
printreel(reel, iter)
reel, iter = makereel(symset5, neighbours)
printreel(reel, iter)
printreel(makereel(symset1, neighbours))
printreel(makereel(symset2, neighbours))
printreel(makereel(symset3, neighbours))
printreel(makereel(symset4, neighbours))
printreel(makereel(symset5, neighbours))
3 changes: 1 addition & 2 deletions helper/beetlemania.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ local neighbours = {
}

math.randomseed(os.time())
local reel, iter = makereel(symset, neighbours)
printreel(reel, iter)
printreel(makereel(symset, neighbours))
3 changes: 1 addition & 2 deletions helper/captainstreasure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ local neighbours = {
}

math.randomseed(os.time())
local reel, iter = makereel(symset, neighbours)
printreel(reel, iter)
printreel(makereel(symset, neighbours))
3 changes: 1 addition & 2 deletions helper/cherryhot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ local chunklen = {
}

math.randomseed(os.time())
local reel, iter = makereelhot(symset, 3, {[8]=true}, chunklen)
printreel(reel, iter)
printreel(makereelhot(symset, 3, {[8]=true}, chunklen))
3 changes: 1 addition & 2 deletions helper/chicago.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ local neighbours = {
}

math.randomseed(os.time())
local reel, iter = makereel(symset, neighbours)
printreel(reel, iter)
printreel(makereel(symset, neighbours))
3 changes: 1 addition & 2 deletions helper/copsnrobbers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ local neighbours = {
}

math.randomseed(os.time())
local reel, iter = makereel(symset, neighbours)
printreel(reel, iter)
printreel(makereel(symset, neighbours))

local fsn = {10, 15, 15, 20, 25}
local sum = 0
Expand Down
3 changes: 1 addition & 2 deletions helper/deserttreasure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ local neighbours = {
}

math.randomseed(os.time())
local reel, iter = makereel(symset, neighbours)
printreel(reel, iter)
printreel(makereel(symset, neighbours))
3 changes: 1 addition & 2 deletions helper/diamonddogs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ local neighbours = {
}

math.randomseed(os.time())
local reel, iter = makereel(symset, neighbours)
printreel(reel, iter)
printreel(makereel(symset, neighbours))

local dd = {10,20,20,40,40,80,120,120,450}
local sum = 0
Expand Down
3 changes: 1 addition & 2 deletions helper/doubleice.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ local chunklen = {
}

math.randomseed(os.time())
local reel, iter = makereelhot(symset, 3, {}, chunklen, true)
printreel(reel, iter)
printreel(makereelhot(symset, 3, {}, chunklen, true))
3 changes: 1 addition & 2 deletions helper/egypt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ local neighbours = {
}

math.randomseed(os.time())
local reel, iter = makereel(symset, neighbours)
printreel(reel, iter)
printreel(makereel(symset, neighbours))
7 changes: 2 additions & 5 deletions helper/extraspin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,5 @@ local chunklen234 = {
}

math.randomseed(os.time())
local reel, iter
reel, iter = makereelhot(symset15, 3, {[1]=true, [2]=true}, chunklen15, true)
printreel(reel, iter)
reel, iter = makereelhot(symset234, 3, {[1]=true, [2]=true}, chunklen234, true)
printreel(reel, iter)
printreel(makereelhot(symset15, 3, {[1]=true, [2]=true}, chunklen15, true))
printreel(makereelhot(symset234, 3, {[1]=true, [2]=true}, chunklen234, true))
3 changes: 1 addition & 2 deletions helper/firejoker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ local neighbours = {
}

math.randomseed(os.time())
local reel, iter = makereel(symset, neighbours)
printreel(reel, iter)
printreel(makereel(symset, neighbours))
3 changes: 1 addition & 2 deletions helper/fortuneteller.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ local neighbours = {
}

math.randomseed(os.time())
local reel, iter = makereel(symset, neighbours)
printreel(reel, iter)
printreel(makereel(symset, neighbours))
3 changes: 1 addition & 2 deletions helper/fruitshop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ local neighbours = {
}

math.randomseed(os.time())
local reel, iter = makereel(symset, neighbours)
printreel(reel, iter)
printreel(makereel(symset, neighbours))
Loading

0 comments on commit f0acff1

Please sign in to comment.