tabula

package module
v0.0.0-...-2be040d Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: AGPL-3.0 Imports: 14 Imported by: 4

README

tabula - Backgammon analysis engine

GoDoc Donate via LiberaPay

Information on the design of the engine is documented in DESIGN.md.

Play

A tabula bot is available to play against at https://bgammon.org for each supported variant:

  • Backgammon
  • Acey-deucey
  • Tabula

Support

Please share issues and suggestions here.

Documentation

Index

Constants

View Source
const (
	SpaceHomePlayer      int8 = 0
	SpaceHomeOpponent    int8 = 25
	SpaceBarPlayer       int8 = 26
	SpaceBarOpponent     int8 = 27
	SpaceRoll1           int8 = 28
	SpaceRoll2           int8 = 29
	SpaceRoll3           int8 = 30
	SpaceRoll4           int8 = 31
	SpaceEnteredPlayer   int8 = 32 // Whether the player has fully entered the board. Only used in acey-deucey games.
	SpaceEnteredOpponent int8 = 33 // Whether the opponent has fully entered the board. Only used in acey-deucey games.
	SpaceVariant         int8 = 34 // 0 - Backgammon, 1 - Acey-deucey, 2 - Tabula.
)
View Source
const (
	VariantBackgammon int8 = 0
	VariantAceyDeucey int8 = 1
	VariantTabula     int8 = 2
)

Variables

View Source
var (
	WeightBlot     = 0.9
	WeightHit      = -1.0
	WeightOppScore = -0.9
)
View Source
var (
	AnalysisBufferSize    = 128
	SubAnalysisBufferSize = 3072
)
View Source
var QueueBufferSize = 4096000
View Source
var Verbose bool

Functions

func PseudoPips

func PseudoPips(player int8, space int8, variant int8) int

Types

type Analysis

type Analysis struct {
	Board Board
	Moves [4][2]int8
	Past  bool
	Score float64

	Pips        int
	Blots       int
	Hits        int
	PlayerScore float64

	OppPips  float64
	OppBlots float64
	OppHits  float64
	OppScore float64
	// contains filtered or unexported fields
}

func (*Analysis) String

func (a *Analysis) String() string

type BEIServer

type BEIServer struct {
	Verbose bool
}

func NewBEIServer

func NewBEIServer() *BEIServer

func (*BEIServer) Listen

func (s *BEIServer) Listen(address string)

func (*BEIServer) ListenLocal

func (s *BEIServer) ListenLocal() chan net.Conn

type Board

type Board [boardSpaces]int8

Board represents the state of a game. It contains spaces for the checkers, as well as four "spaces" which contain the available die rolls.

func NewBoard

func NewBoard(variant int8) Board

NewBoard returns a new board with checkers placed in their starting positions.

func (Board) Analyze

func (b Board) Analyze(available [][4][2]int8, result *[]*Analysis, skipOpponent bool) (analyzedPositions int)

func (Board) Available

func (b Board) Available(player int8) ([][4][2]int8, []Board)

Available returns legal moves available.

func (Board) Blots

func (b Board) Blots(player int8) int

func (Board) ChooseDoubles

func (b Board) ChooseDoubles(result *[]*Analysis) int

func (Board) Evaluation

func (b Board) Evaluation(player int8, hitScore int, moves [4][2]int8) *Analysis

func (Board) FirstLast

func (b Board) FirstLast(player int8) (playerFirst int8, opponentLast int8)

func (Board) HaveRoll

func (b Board) HaveRoll(from int8, to int8, player int8) bool

HaveRoll returns whether the player has a sufficient die roll for the specified move.

func (Board) MayBearOff

func (b Board) MayBearOff(player int8) bool

func (Board) Move

func (b Board) Move(from int8, to int8, player int8) Board

Move moves a checker on the board.

func (Board) Past

func (b Board) Past() bool

func (Board) Pips

func (b Board) Pips(player int8) int

func (Board) Print

func (b Board) Print()

func (Board) SecondHalf

func (b Board) SecondHalf(player int8) bool

func (Board) SetValue

func (b Board) SetValue(space int, value int8) Board

func (Board) StartingPosition

func (b Board) StartingPosition(player int8) bool

func (Board) String

func (b Board) String() string

func (Board) UseRoll

func (b Board) UseRoll(from int8, to int8, player int8) Board

UseRoll uses a die roll. UseRoll must be called before making a move.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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