Browse Source

testing

master
Jeffrey Paul 3 years ago
parent
commit
830e6b66bf
  1. 1
      main.go
  2. 10
      misc/generateTestSuite.go
  3. 26
      pokercore/pokercore.go

1
main.go

@ -4,6 +4,7 @@ import (
"errors"
"fmt"
log "github.com/sirupsen/logrus"
"github.com/sneak/gopoker/pokercore"
"io"
"net/http"
"net/rpc"

10
misc/generateTestSuite.go

@ -0,0 +1,10 @@
package main
import "fmt"
import "github.com/sneak/gopoker/pokercore"
func main() {
myDeck := pokercore.NewDeck()
myDeck.ShuffleRandomly()
fmt.Println("%s", myDeck.Cards)
}

26
pokercore/pokercore.go

@ -54,14 +54,6 @@ func NewRandom() *rand.Rand {
var rnd *rand.Rand
seed := int64(42)
if trueRandom {
rnd = rand.New(rand.NewSource(int64(cryptoUint64())))
} else {
rnd = rand.New(rand.NewSource(seed))
}
return rnd
}
@ -96,7 +88,6 @@ func NewDeck() *Deck {
self.Cards = make([]*Card, 52)
// Loop over each type and suit appending to the deck
tot := 0
for i := 0; i < len(ranks); i++ {
for n := 0; n < len(suits); n++ {
@ -111,8 +102,15 @@ func NewDeck() *Deck {
return self
}
func (self *Deck) Shuffle() {
r := NewRandom()
func (self *Deck) ShuffleRandomly() {
rnd := rand.New(rand.NewSource(int64(cryptoUint64())))
//FIXME(sneak) not sure if this is constant time or not
rnd.Shuffle(len(self.Cards), func(i, j int) { self.Cards[i], self.Cards[j] = self.Cards[j], self.Cards[i] })
}
func (self *Deck) ShuffleDeterministic(int64 seed) {
r := rand.New(rand.NewSource(seed))
//FIXME(sneak) not sure if this is constant time or not
r.Shuffle(len(self.Cards), func(i, j int) { self.Cards[i], self.Cards[j] = self.Cards[j], self.Cards[i] })
}
@ -139,9 +137,11 @@ func (s Cards) String() (output string) {
return output
}
func main2() {
func generate() {
log.SetLevel(log.DebugLevel)
}
func proto() {
myDeck := NewDeck()
myDeck.Shuffle()

Loading…
Cancel
Save