rand

package
v0.0.0-...-1356a85 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashNoise

func HashNoise(position, seed uint32) (value uint32)

This is "Squirrel3" from "Guildhall's Squirrel Eiserloh"'s GDC 2017 talk

func HashNoise2D

func HashNoise2D(x, y, seed uint32) (value uint32)

func PerlinNoise1D

func PerlinNoise1D(x float32, seed int32) float32

*

  • 1D Perlin simplex noise
  • @param[in] x float coordinate
  • @return Noise value in the range[-1; 1], value of 0 on all integer coordinates.

Types

type HashRng

type HashRng struct {
	RandomNumberGenerator
	// contains filtered or unexported fields
}

func NewHashRng

func NewHashRng() *HashRng

func NewHashRngWithSeed

func NewHashRngWithSeed(seed uint32) *HashRng

func (*HashRng) Event

func (hr *HashRng) Event(chance int) bool

func (*HashRng) Maybe

func (hr *HashRng) Maybe() bool

func (*HashRng) NextFloat32

func (hr *HashRng) NextFloat32() (result float32)

func (*HashRng) NextUint32

func (hr *HashRng) NextUint32() (result uint32)

func (*HashRng) NextUint32InRange

func (hr *HashRng) NextUint32InRange(min, max int) (result uint32)

func (*HashRng) NextUint32LessThan

func (hr *HashRng) NextUint32LessThan(n int) (result uint32)

type RandomNumberGenerator

type RandomNumberGenerator interface {
	NextUint32() (result uint32)
	NextUint32LessThan(n int) (result uint32)
	NextUint32InRange(min, max int) (result uint32)
	NextFloat32() (result float32)
	Event(chance int) bool
	Maybe() bool
}

type StdLibGenerator

type StdLibGenerator struct {
	RandomNumberGenerator
	// contains filtered or unexported fields
}

func NewStdLibGenerator

func NewStdLibGenerator(seed int64) *StdLibGenerator

func (*StdLibGenerator) Event

func (g *StdLibGenerator) Event(chance int) bool

func (*StdLibGenerator) Maybe

func (g *StdLibGenerator) Maybe() bool

func (*StdLibGenerator) NextFloat32

func (g *StdLibGenerator) NextFloat32() float32

func (*StdLibGenerator) NextUint32

func (g *StdLibGenerator) NextUint32() uint32

func (*StdLibGenerator) NextUint32InRange

func (g *StdLibGenerator) NextUint32InRange(min, max int) (result uint32)

func (*StdLibGenerator) NextUint32LessThan

func (g *StdLibGenerator) NextUint32LessThan(n int) (result uint32)

func (*StdLibGenerator) Permutation

func (g *StdLibGenerator) Permutation(max int) []int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL