clock

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: May 3, 2025 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock struct {
	White        time.Duration
	Black        time.Duration
	WhiteTicking bool
	BlackTicking bool
}

func (*Clock) Side

func (c *Clock) Side(col chess.Color) *time.Duration

func (*Clock) SideTicking added in v0.9.1

func (c *Clock) SideTicking(col chess.Color) *bool

func (*Clock) Simple added in v0.9.4

func (c *Clock) Simple() SimpleClock

type Control

type Control struct {
	White ControlSide
	Black ControlSide
}

func ControlFromString

func ControlFromString(s string) (Control, error)

func (Control) Clone

func (c Control) Clone() Control

func (Control) Eq

func (c Control) Eq(o Control) bool

func (Control) MarshalJSON added in v0.9.1

func (c Control) MarshalJSON() ([]byte, error)

func (*Control) Side

func (c *Control) Side(col chess.Color) *ControlSide

func (Control) String

func (c Control) String() string

func (*Control) UnmarshalJSON added in v0.9.1

func (c *Control) UnmarshalJSON(data []byte) error

func (Control) Validate

func (c Control) Validate() error

type ControlItem

type ControlItem struct {
	Time  time.Duration
	Inc   time.Duration
	Moves int
}

func ControlItemFromString

func ControlItemFromString(s string, isFinal bool) (ControlItem, error)

func (ControlItem) String

func (c ControlItem) String() string

func (ControlItem) Validate

func (c ControlItem) Validate(isFinal bool) error

type ControlSide

type ControlSide []ControlItem

func ControlSideFromString

func ControlSideFromString(s string) (ControlSide, error)

func (ControlSide) Clone

func (c ControlSide) Clone() ControlSide

func (ControlSide) Eq

func (c ControlSide) Eq(o ControlSide) bool

func (ControlSide) String

func (c ControlSide) String() string

func (ControlSide) Validate

func (c ControlSide) Validate() error

type Game

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

func NewGame

func NewGame(game *chess.Game, control maybe.Maybe[Control], o GameOptions) *Game

func (*Game) Clock

func (g *Game) Clock() (Clock, bool)

func (*Game) CurBoard

func (g *Game) CurBoard() *chess.Board

func (*Game) CurSide

func (g *Game) CurSide() chess.Color

func (*Game) Deadline

func (g *Game) Deadline() (time.Time, bool)

func (*Game) Finish

func (g *Game) Finish(o chess.Outcome) error

func (*Game) HasTimer

func (g *Game) HasTimer() bool

func (*Game) Inner

func (g *Game) Inner() *chess.Game

func (*Game) IsFinished

func (g *Game) IsFinished() bool

func (*Game) Outcome

func (g *Game) Outcome() chess.Outcome

func (*Game) Push

func (g *Game) Push(mv chess.Move) error

func (*Game) UCITimeSpec

func (g *Game) UCITimeSpec() (UCITimeSpec, bool)

func (*Game) UpdateTimer

func (g *Game) UpdateTimer()

type GameOptions

type GameOptions struct {
	OutcomeFilter maybe.Maybe[chess.VerdictFilter]
	Now           func() time.Time
	Clock         maybe.Maybe[SimpleClock]
}

type SimpleClock added in v0.9.4

type SimpleClock struct {
	White time.Duration
	Black time.Duration
}

func (*SimpleClock) Side added in v0.9.4

func (c *SimpleClock) Side(col chess.Color) *time.Duration

type Timer

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

func NewTimer

func NewTimer(side chess.Color, control Control, o TimerOptions) *Timer

func (*Timer) Clock

func (t *Timer) Clock() Clock

func (*Timer) Deadline

func (t *Timer) Deadline() (time.Time, bool)

func (*Timer) Flip

func (t *Timer) Flip()

func (*Timer) Outcome

func (t *Timer) Outcome() chess.Outcome

func (*Timer) Side

func (t *Timer) Side() chess.Color

func (*Timer) Stop

func (t *Timer) Stop(outcome chess.Outcome)

func (*Timer) UCITimeSpec

func (t *Timer) UCITimeSpec() UCITimeSpec

func (*Timer) Update

func (t *Timer) Update()

type TimerOptions

type TimerOptions struct {
	NumFlips int
	Outcome  chess.Outcome
	Now      func() time.Time
	Clock    maybe.Maybe[SimpleClock]
}

type UCITimeSpec

type UCITimeSpec struct {
	Wtime     time.Duration
	Btime     time.Duration
	Winc      time.Duration
	Binc      time.Duration
	MovesToGo int
}

func (*UCITimeSpec) Validate

func (s *UCITimeSpec) Validate() error

Jump to

Keyboard shortcuts

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