-
Notifications
You must be signed in to change notification settings - Fork 80
Open
Description
Hello I've implemented a generator for reels to simulate all possible positions for the reels. Since I can't see the possibility to make a branch I am posting it here (you can replace the reel screen logic's random with it to permute all possible line symbols:
type CombGeneratorV2 struct {
c chan int
i, j, h, k, l int
data []int
}
func MakeCombGeneratorV2(i, j, h, k, l int) *CombGeneratorV2 {
cg := CombGeneratorV2{}
cg.data = make([]int, 5)
cg.c = make(chan int)
cg.i = i
cg.j = j
cg.h = h
cg.l = l
cg.k = k
return &cg
}
func (cg *CombGeneratorV2) Init(offset int) {
go func() {
for i := offset; i <= cg.i; i++ {
for j := offset; j <= cg.j; j++ {
for h := offset; h <= cg.h; h++ {
for k := offset; k <= cg.k; k++ {
for l := offset; l <= cg.l; l++ {
cg.c <- i
cg.c <- j
cg.c <- h
cg.c <- k
cg.c <- l
}
}
}
}
}
}()
}
func (cg *CombGeneratorV2) Next() []int {
for i := 0; i < 5; i++ {
cg.data[i] = <-cg.c
}
return cg.data
}
and the test file:
import (
"fmt"
"testing"
)
func TestWsServerV2(t *testing.T) {
combo3x3 := MakeCombGeneratorV2(3, 3, 3, 3, 3)
combo3x3.Init(1)
for h := 0; h < 50; h++ {
if combo := combo3x3.Next(); len(combo) != 0 {
i := 0
combo := combo[2:]
fmt.Println(combo)
for x := 1; x <= 3; x++ {
var hit = combo[i]
fmt.Printf("[%d]", hit)
i++
}
}
fmt.Println("")
}
}
Regards
Metadata
Metadata
Assignees
Labels
No labels