bei

package module
v0.0.0-...-bcc7b69 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 2 Imported by: 3

README

BEI - Backgammon Engine Interface

GoDoc Donate via LiberaPay

The BEI specification is available here.

Applications

The following applications use BEI:

Documentation

Documentation is available via godoc.

Support

Please share issues and suggestions here.

Documentation

Index

Constants

View Source
const (
	CommandBEI    = "bei"
	CommandList   = "list"
	CommandSet    = "set"
	CommandDouble = "double"
	CommandMove   = "move"
	CommandChoose = "choose"
)
View Source
const (
	StateHome1       = 0
	StateHome2       = 25
	StateBar1        = 26
	StateBar2        = 27
	StateRoll1       = 28
	StateRoll2       = 29
	StateTurn1       = 30
	StateTurn2       = 31
	StateCubeValue   = 32
	StateCubePlayer  = 33
	StatePoints1     = 34
	StatePoints2     = 35
	StateTotalPoints = 36
	StateCrawford    = 37
	StateJacoby      = 38
	StateMurphy      = 39
	StateBeavers     = 40
	StateVariant     = 41
	StateEntered1    = 42
	StateEntered2    = 43
)
View Source
const (
	EventTypeOkBEI      = "okbei"
	EventTypeOkList     = "oklist"
	EventTypeFailSet    = "failset"
	EventTypeOkSet      = "okset"
	EventTypeFailDouble = "faildouble"
	EventTypeOkDouble   = "okdouble"
	EventTypeFailMove   = "failmove"
	EventTypeOkMove     = "okmove"
	EventTypeFailChoose = "failchoose"
	EventTypeOkChoose   = "okchoose"
)
View Source
const CellCount = 44

Variables

This section is empty.

Functions

func DecodeEvent

func DecodeEvent(message []byte) (interface{}, error)

func EncodeEvent

func EncodeEvent(e interface{}) ([]byte, error)

func EncodeState

func EncodeState(s *State) []int

Types

type BeaversType

type BeaversType int
const (
	BeaversNone BeaversType = iota
	BeaversOnly
	BeaversAndRaccoons
)

type ChooseRoll

type ChooseRoll struct {
	Roll          int
	Probabilities Probabilities
}

type CubeEvaluation

type CubeEvaluation struct {
	Offer bool
	Take  bool
}

type Event

type Event struct {
	Type string
}

type EventFailChoose

type EventFailChoose struct {
	Event
	Reason string
}

type EventFailDouble

type EventFailDouble struct {
	Event
	Reason string
}

type EventFailMove

type EventFailMove struct {
	Event
	Reason string
}

type EventFailSet

type EventFailSet struct {
	Event
	Name   string
	Reason string
}

type EventOkBEI

type EventOkBEI struct {
	Event
	Version int
	ID      map[string]string
}

type EventOkChoose

type EventOkChoose struct {
	Event
	Rolls []*ChooseRoll
}

type EventOkDouble

type EventOkDouble struct {
	Event
	Cube          CubeEvaluation
	Probabilities Probabilities
}

type EventOkList

type EventOkList struct {
	Event
	List []*ListEntry
}

type EventOkMove

type EventOkMove struct {
	Event
	Moves []*Move
}

type EventOkSet

type EventOkSet struct {
	Event
	Name  string
	Value string
}

type ListEntry

type ListEntry struct {
	Name        string
	Type        SettingType
	Description string
	Default     string
	Value       string
	Min         int
	Max         int
}

type Move

type Move struct {
	Play          []*Play
	Probabilities Probabilities
}

type Play

type Play struct {
	From int
	To   int
}

type Probabilities

type Probabilities struct {
	LoseBackgammon float64
	LoseGammon     float64
	Win            float64
	WinBackgammon  float64
	WinGammon      float64
}

type SettingType

type SettingType int
const (
	SettingBoolean SettingType = iota
	SettingInteger
	SettingString
)

type State

type State struct {
	Board []int

	Roll1 int
	Roll2 int

	Turn1 int
	Turn2 int

	CubeValue  int
	CubePlayer int

	Points1     int
	Points2     int
	TotalPoints int

	Crawford bool
	Jacoby   bool
	Murphy   bool
	Beavers  BeaversType

	Variant  int
	Entered1 bool
	Entered2 bool
}

func DecodeState

func DecodeState(state []int) (*State, error)

Jump to

Keyboard shortcuts

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