sgc7plugin

package
v0.13.382 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const RngA int64 = 165403
View Source
const RngC int64 = 51654324
View Source
const RngM int64 = 2147483647

Variables

View Source
var (
	// ErrInvalidTag - invalid tag
	ErrInvalidTag = errors.New("invalid tag")
)
View Source
var IsNoRNGCache bool

Functions

This section is empty.

Types

type BasicPlugin

type BasicPlugin struct {
	PluginBase
}

BasicPlugin - basic plugin

func NewBasicPlugin

func NewBasicPlugin() *BasicPlugin

NewBasicPlugin - new a BasicPlugin

func (*BasicPlugin) Init

func (bp *BasicPlugin) Init()

Init - initial

func (*BasicPlugin) Random

func (bp *BasicPlugin) Random(ctx context.Context, r int) (int, error)

Random - return [0, r)

func (*BasicPlugin) SetSeed added in v0.13.124

func (bp *BasicPlugin) SetSeed(seed int)

SetSeed - set a seed

type FastPlugin added in v0.12.17

type FastPlugin struct {
	PluginBase
	RNG *fastrand.RNG
}

BasicPlugin - basic plugin

func NewFastPlugin added in v0.12.17

func NewFastPlugin() *FastPlugin

NewFastPlugin - new a BasicPlugin

func (*FastPlugin) Init added in v0.12.18

func (fp *FastPlugin) Init()

Init - initial

func (*FastPlugin) Random added in v0.12.17

func (fp *FastPlugin) Random(ctx context.Context, r int) (int, error)

Random - return [0, r)

func (*FastPlugin) SetSeed added in v0.13.124

func (fp *FastPlugin) SetSeed(seed int)

SetSeed - set a seed

type FuncNewPlugin

type FuncNewPlugin func() IPlugin

FuncNewPlugin - new a IPlugin

type IPlugin

type IPlugin interface {
	// Random - return [0, r)
	Random(ctx context.Context, r int) (int, error)
	// GetUsedRngs - get used rngs
	GetUsedRngs() []*sgc7utils.RngInfo
	// ClearUsedRngs - clear used rngs
	ClearUsedRngs()
	// TagUsedRngs - new a tag for current UsedRngs
	TagUsedRngs()
	// RollbackUsedRngs - rollback UsedRngs with the latest tag
	RollbackUsedRngs() error
	// SetCache - set cache
	SetCache(arr []int)
	// ClearCache - clear cached rngs
	ClearCache()
	// Init - initial
	Init()
	// SetScenePool - set scene pool
	SetScenePool(any)
	// GetScenePool - get scene pool
	GetScenePool() any
	// SetSeed - set a seed
	SetSeed(seed int)
}

IPlugin - plugin

type PRNGPlugin added in v0.13.124

type PRNGPlugin struct {
	PluginBase
	Seed int
}

PRNGPlugin - prng plugin

func NewPRNGPlugin added in v0.13.124

func NewPRNGPlugin() *PRNGPlugin

NewPRNGPlugin - new a PRNGPlugin

func (*PRNGPlugin) Init added in v0.13.124

func (prng *PRNGPlugin) Init()

Init - initial

func (*PRNGPlugin) Random added in v0.13.124

func (prng *PRNGPlugin) Random(ctx context.Context, r int) (int, error)

Random - return [0, r)

func (*PRNGPlugin) SetSeed added in v0.13.124

func (prng *PRNGPlugin) SetSeed(seed int)

SetSeed - set a seed

type PluginBase added in v0.12.23

type PluginBase struct {
	RngUsed   []*sgc7utils.RngInfo
	Cache     []int
	Tag       int
	ScenePool any
}

PluginBase - base

func NewPluginBase added in v0.12.23

func NewPluginBase() PluginBase

func (*PluginBase) AddRngUsed added in v0.12.23

func (bp *PluginBase) AddRngUsed(ri *sgc7utils.RngInfo)

AddRngUsed - added used rngs

func (*PluginBase) ClearCache added in v0.12.23

func (bp *PluginBase) ClearCache()

ClearCache - clear cached rngs

func (*PluginBase) ClearUsedRngs added in v0.12.23

func (bp *PluginBase) ClearUsedRngs()

ClearUsedRngs - clear used rngs

func (*PluginBase) GetScenePool added in v0.12.23

func (bp *PluginBase) GetScenePool() any

GetScenePool - get scene pool

func (*PluginBase) GetUsedRngs added in v0.12.23

func (bp *PluginBase) GetUsedRngs() []*sgc7utils.RngInfo

GetUsedRngs - get used rngs

func (*PluginBase) RollbackUsedRngs added in v0.12.23

func (bp *PluginBase) RollbackUsedRngs() error

RollbackUsedRngs - rollback UsedRngs with a tag

func (*PluginBase) SetCache added in v0.12.23

func (bp *PluginBase) SetCache(arr []int)

SetCache - set cache

func (*PluginBase) SetScenePool added in v0.12.23

func (bp *PluginBase) SetScenePool(pool any)

SetScenePool - set scene pool

func (*PluginBase) TagUsedRngs added in v0.12.23

func (bp *PluginBase) TagUsedRngs()

TagUsedRngs - new a tag for current UsedRngs

type PluginsMgr

type PluginsMgr struct {
	// contains filtered or unexported fields
}

PluginsMgr - plugins manager

func NewPluginsMgr

func NewPluginsMgr(funcNewPlugin FuncNewPlugin) *PluginsMgr

NewPluginsMgr - new a PluginsMgr

func (*PluginsMgr) FreePlugin

func (mgr *PluginsMgr) FreePlugin(plugin IPlugin)

FreePlugin - free a Plugin

func (*PluginsMgr) NewPlugin

func (mgr *PluginsMgr) NewPlugin() IPlugin

NewPlugin - new a Plugin

Jump to

Keyboard shortcuts

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