tak

package
v0.0.0-...-7c4a433 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	White   Color = 1 << 7
	Black   Color = 1 << 6
	NoColor Color = 0

	Flat     Kind = 1
	Standing Kind = 2
	Capstone Kind = 3
)

Variables

View Source
var (
	ErrOccupied       = errors.New("position is occupied")
	ErrIllegalSlide   = errors.New("illegal slide")
	ErrNoCapstone     = errors.New("capstone has already been played")
	ErrIllegalOpening = errors.New("illegal opening move")
)

Functions

This section is empty.

Types

type Analysis

type Analysis struct {
	WhiteGroups []uint64
	BlackGroups []uint64
}

type Color

type Color byte

func (Color) Flip

func (c Color) Flip() Color

func (Color) String

func (c Color) String() string

type Config

type Config struct {
	Size      int
	Pieces    int
	Capstones int
	// contains filtered or unexported fields
}

type Kind

type Kind byte

type Move

type Move struct {
	X, Y   int
	Type   MoveType
	Slides []byte
}

func (*Move) Dest

func (m *Move) Dest() (int, int)

func (*Move) Equal

func (m *Move) Equal(rhs *Move) bool

func (*Move) Hash

func (m *Move) Hash() uint64

type MoveType

type MoveType byte
const (
	Pass      MoveType = 1 + iota
	PlaceFlat          //2
	PlaceStanding
	PlaceCapstone //4
	SlideLeft
	SlideRight //6
	SlideUp
	SlideDown //8
)
const TypeMask MoveType = 0xf

type Piece

type Piece byte

func MakePiece

func MakePiece(color Color, kind Kind) Piece

func (Piece) Color

func (p Piece) Color() Color

func (Piece) IsRoad

func (p Piece) IsRoad() bool

func (Piece) Kind

func (p Piece) Kind() Kind

func (Piece) String

func (p Piece) String() string

type Position

type Position struct {
	White    uint64
	Black    uint64
	Standing uint64
	Caps     uint64
	Height   []uint8
	Stacks   []uint64

	Threatmoves []Move
	// contains filtered or unexported fields
}

func Alloc

func Alloc(size int) *Position

func FromSquares

func FromSquares(cfg Config, board [][]Square, move int) (*Position, error)

FromSquares initializes a Position with the specified squares and move number. `board` is a slice of rows, numbered from low to high, each of which is a slice of positions.

func New

func New(g Config) *Position

func (*Position) AllMoves

func (p *Position) AllMoves(moves []Move) []Move

func (*Position) Analysis

func (p *Position) Analysis() *Analysis

func (*Position) At

func (p *Position) At(x, y int) Square

func (*Position) BlackCaps

func (p *Position) BlackCaps() int

func (*Position) BlackStones

func (p *Position) BlackStones() int

func (*Position) Clone

func (p *Position) Clone() *Position

func (*Position) GameOver

func (p *Position) GameOver() (over bool, winner Color)

func (*Position) GetHash

func (p *Position) GetHash() uint64

func (*Position) Hash

func (p *Position) Hash() uint64

func (*Position) IncrementMove

func (p *Position) IncrementMove()

func (*Position) Move

func (p *Position) Move(m *Move) (*Position, error)

func (*Position) MoveNumber

func (p *Position) MoveNumber() int

func (*Position) MovePreallocated

func (p *Position) MovePreallocated(m *Move, next *Position) (*Position, error)

func (*Position) Size

func (p *Position) Size() int

func (*Position) ToMove

func (p *Position) ToMove() Color

func (*Position) Top

func (p *Position) Top(x, y int) Piece

func (*Position) WhiteCaps

func (p *Position) WhiteCaps() int

func (*Position) WhiteStones

func (p *Position) WhiteStones() int

func (*Position) WinDetails

func (p *Position) WinDetails() WinDetails

type Square

type Square []Piece

type WinDetails

type WinDetails struct {
	Over       bool
	Reason     WinReason
	Winner     Color
	WhiteFlats int
	BlackFlats int
}

type WinReason

type WinReason int
const (
	RoadWin WinReason = iota
	FlatsWin
	Resignation
)

Jump to

Keyboard shortcuts

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