Documentation ¶
Index ¶
- Constants
- Variables
- func AssertEqualTrimmed(t *testing.T, actual, expected string)
- func BigintSeparated(num uint64) string
- func CacheFileExists(board *Board) bool
- func CalculateMovesOrder(board *Board) []int
- func HandleInterrupt(interruptible Interruptible) chan os.Signal
- func LoadCache(cache ICache, boardW, boardH int) error
- func MaximumZeroIndex(nums []uint64) int
- func MustLoadCache(cache ICache, boardW, boardH int)
- func MustSaveCache(cache ICache, boardW, boardH int)
- func NewProgressBar() *progressbar.ProgressBar
- func ReverseLines(s []string) []string
- func SaveCache(cache ICache, boardW, boardH int) error
- func ServeMetrics()
- type Board
- func (b *Board) ApplyMoves(startWithMoves string) *Board
- func (b *Board) CanMakeMove(x int) bool
- func (b *Board) Clear()
- func (b *Board) Clone() *Board
- func (b *Board) CountMoves() uint
- func (b *Board) GetCell(x int, y int) Player
- func (b *Board) NextPlayer() Player
- func (b *Board) Revert(x int, y int)
- func (b *Board) StackSize(x int) int
- func (b *Board) String() string
- func (b *Board) Throw(x int, player Player) int
- type BoardState
- type GameEnding
- type ICache
- type IMoveSolver
- type Interruptible
- type Mode
- type Option
- type Player
Constants ¶
View Source
const ( PlayerA Player = 0 // Player A moves first PlayerB Player = 1 // Player B has a second move Empty Player = 2 NoMove Player = 3 PlayerARune = 'A' PlayerBRune = 'B' EmptyCell = "." )
View Source
const ItReportPeriodMask = 0b11111111111111111111 // modulo 2^20 (1048576) mask
View Source
const ProgressBarResolution = 1_000_000_000
View Source
const RefreshProgressPeriod = 2 * time.Second
Variables ¶
View Source
var ( MetricCacheDepthSize = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "c4solver_cache_depth_size", Help: "Current size of cached endgames for each depth", }, []string{"depth"}) MetricProgress = promauto.NewGauge(prometheus.GaugeOpts{ Name: "c4solver_progress", Help: "Total progress of training", }) MetricTotalIterations = promauto.NewGauge(prometheus.GaugeOpts{ Name: "c4solver_iterations", Help: "Total number of iterations (considered boards)", }) )
View Source
var CacheSizeLimit int = 1_500_000_000
View Source
var InterruptError error = errors.New("Interrupt")
View Source
var PlayerDisplays = map[Player]string{ PlayerA: "\u001b[33;1mA\u001b[0m", PlayerB: "\u001b[31;1mB\u001b[0m", Empty: ".", NoMove: "-", }
View Source
var ShortGameEndingDisplays = map[GameEnding]string{ Win: "\u001b[32;1mW\u001b[0m", Tie: "\u001b[33;1mT\u001b[0m", Lose: "\u001b[31;1mL\u001b[0m", NoEnding: "-", }
View Source
var StackSizeLookup []int
Board column state -> stack size
Functions ¶
func AssertEqualTrimmed ¶
func BigintSeparated ¶
func CacheFileExists ¶
func CalculateMovesOrder ¶
func HandleInterrupt ¶
func HandleInterrupt(interruptible Interruptible) chan os.Signal
func MaximumZeroIndex ¶
func MustLoadCache ¶
func MustSaveCache ¶
func NewProgressBar ¶
func NewProgressBar() *progressbar.ProgressBar
func ReverseLines ¶
func ServeMetrics ¶
func ServeMetrics()
Types ¶
type Board ¶
type Board struct { W int H int WinStreak int State BoardState }
Board keeps state in a binary format: - first binary One signifies stack height - next bits signifies Player A (zero) or Player B (one)
func ParseBoard ¶
func (*Board) ApplyMoves ¶
func (*Board) CanMakeMove ¶
func (*Board) CountMoves ¶
func (*Board) NextPlayer ¶
type BoardState ¶
type BoardState []uint64
Slice of column states (a column is uint8, but keeping as uint64 improves operations later on)
type GameEnding ¶
type GameEnding string
const ( Win GameEnding = "\u001b[32;1mWin\u001b[0m" Tie GameEnding = "\u001b[33;1mTie\u001b[0m" Lose GameEnding = "\u001b[31;1mLose\u001b[0m" NoEnding GameEnding = "None" )
func EndingForPlayer ¶
func EndingForPlayer(ending Player, player Player) GameEnding
func (GameEnding) String ¶
func (e GameEnding) String() string
type IMoveSolver ¶
type Interruptible ¶
type Interruptible interface {
Interrupt()
}
type Option ¶
func WithWinStreak ¶
Click to show internal directories.
Click to hide internal directories.