rdbstore

package
v0.0.0-...-2c859fb Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package rdbstore implements CFR storage components that keep data in a RocksDB database, rather than in memory datastructures.

These implementations are substantially slower than the corresponding in-memory components but can scale to games that do not fit in memory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Params

type Params struct {
	Path         string
	Options      *rocksdb.Options
	ReadOptions  *rocksdb.ReadOptions
	WriteOptions *rocksdb.WriteOptions
}

func DefaultParams

func DefaultParams(path string) Params

func (Params) Close

func (p Params) Close()

type PolicyTable

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

PolicyTable is a tabular CFR policy table that keeps all node policies on disk in a LevelDB database. PolicyTable implements cfr.StrategyProfile.

It is functionally equivalent to a cfr.PolicyTable. In practice, it is significantly slower but will use constant amount of memory since all policies are kept on disk.

func New

func New(params Params, discounts cfr.DiscountParams) (*PolicyTable, error)

New creates a new PolicyTable backed by a LevelDB database at the given path.

func (*PolicyTable) Close

func (pt *PolicyTable) Close() error

Close implements io.Closer.

func (*PolicyTable) GetPolicy

func (pt *PolicyTable) GetPolicy(node cfr.GameTreeNode) cfr.NodePolicy

GetPolicy implements cfr.StrategyProfile.

func (*PolicyTable) Iter

func (pt *PolicyTable) Iter() int

Iter implements cfr.StrategyProfile.

func (*PolicyTable) MarshalBinary

func (pt *PolicyTable) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*PolicyTable) UnmarshalBinary

func (pt *PolicyTable) UnmarshalBinary(buf []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (*PolicyTable) Update

func (pt *PolicyTable) Update()

Update implements cfr.StrategyProfile.

type ReservoirBuffer

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

ReservoirBuffer implements a reservoir sampling buffer in which samples are stored in a LevelDB database.

It is functionally equivalent to deepcfr.ReservoirBuffer. In practice, it will be somewhat slower but use less memory since all samples are kept on disk.

func NewReservoirBuffer

func NewReservoirBuffer(params Params, maxSize int) (*ReservoirBuffer, error)

NewReservoirBuffer returns a new ReservoirBuffer with the given max number of samples, backed by a LevelDB database at the given directory path.

func (*ReservoirBuffer) AddSample

func (b *ReservoirBuffer) AddSample(s deepcfr.Sample)

AddSample implements deepcfr.Buffer.

func (*ReservoirBuffer) Close

func (b *ReservoirBuffer) Close() error

Close implements io.Closer.

func (*ReservoirBuffer) GetSample

func (b *ReservoirBuffer) GetSample(idx int) deepcfr.Sample

GetSample implements Buffer.

func (*ReservoirBuffer) GetSamples

func (b *ReservoirBuffer) GetSamples() []deepcfr.Sample

GetSamples implements deepcfr.Buffer.

func (*ReservoirBuffer) Len

func (b *ReservoirBuffer) Len() int

Len implements Buffer.

func (*ReservoirBuffer) MarshalBinary

func (b *ReservoirBuffer) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*ReservoirBuffer) UnmarshalBinary

func (b *ReservoirBuffer) UnmarshalBinary(buf []byte) error

UnmarshalBinary implements encoding.BinaryMarshaler.

Jump to

Keyboard shortcuts

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