gobang

package
v0.0.0-...-934685d Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScreenWidth  = 800
	ScreenHeight = 600
)
View Source
const (
	ChessBoardSize = 600
	PieceSize      = 30
	TopLeftX       = 15
	TopLeftY       = 15
	BlockSize      = 39
)
View Source
const (
	BucketName = "menual"
)
View Source
const (
	GobangSize = 15
)
View Source
const (
	JingShouRule bool = false
)

Variables

This section is empty.

Functions

func Abs

func Abs(x int) int

func Max

func Max(x, y int) int

func Min

func Min(x, y int) int

func NewChessModel

func NewChessModel() *chessModel

Types

type AiPlayer

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

func NewAiPlayer

func NewAiPlayer(cb *ChessBoard, piece PieceType, menual *ChessMenual) *AiPlayer

func (*AiPlayer) Reset

func (ap *AiPlayer) Reset()

func (*AiPlayer) Resolve

func (ap *AiPlayer) Resolve(p Position) Position

type Chess

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

func NewChess

func NewChess() *Chess

func (*Chess) Draw

func (c *Chess) Draw(screen *ebiten.Image)

func (*Chess) Update

func (c *Chess) Update() error

type ChessBoard

type ChessBoard [chessBoardSizeIn64Bit]uint64

func NewChessBoard

func NewChessBoard() ChessBoard

func (*ChessBoard) Clear

func (cb *ChessBoard) Clear()

func (*ChessBoard) Get

func (cb *ChessBoard) Get(i, j int) PieceType

func (*ChessBoard) GetString

func (cb *ChessBoard) GetString() string

func (*ChessBoard) Set

func (cb *ChessBoard) Set(i, j int, piece PieceType)

type ChessMenual

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

func NewChessMenual

func NewChessMenual() *ChessMenual

func (*ChessMenual) CloseDB

func (cm *ChessMenual) CloseDB()

func (*ChessMenual) Get

func (cm *ChessMenual) Get(key MenualKey) *MenualItem

func (*ChessMenual) OpenDB

func (cm *ChessMenual) OpenDB()

func (*ChessMenual) Put

func (cm *ChessMenual) Put(key MenualKey, item *MenualItem)

type Game

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

func NewGame

func NewGame() (*Game, error)

func (*Game) Draw

func (g *Game) Draw(screen *ebiten.Image)

func (*Game) Layout

func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int)

func (*Game) Update

func (g *Game) Update() error

type GoBangTerm

type GoBangTerm int
const (
	Huosan GoBangTerm = iota
	ChongSan

	HuoSi
	ChongSI

	WuZiLianZhu
	ChangLian

	ShuangHuoSan

	SanSanSheng
	SiSanSheng
	SiSiSheng

	ShuangSanJinShou
	ShuangSiJinShou

	HuoEr
	ChongEr

	JinShou

	Others
)

type GobangDB

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

func OpenDB

func OpenDB(name string) (*GobangDB, error)

func (*GobangDB) Close

func (gbdb *GobangDB) Close()

func (*GobangDB) Get

func (gbdb *GobangDB) Get(key string) (*MenualItem, error)

func (*GobangDB) Init

func (gbdb *GobangDB) Init() error

func (*GobangDB) Put

func (gbdb *GobangDB) Put(key string, value MenualItem) error

type HumanPlayer

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

func NewHumanPlayer

func NewHumanPlayer(cb *ChessBoard) *HumanPlayer

func (*HumanPlayer) Reset

func (hp *HumanPlayer) Reset()

func (*HumanPlayer) Resolve

func (hp *HumanPlayer) Resolve(p Position) Position

type Input

type Input struct {
	// contains filtered or unexported fields
}
var (
	DefaultInput *Input
)

func NewInput

func NewInput() *Input

func (*Input) Draw

func (i *Input) Draw(screen *ebiten.Image)

func (*Input) Enable

func (i *Input) Enable()

func (*Input) GetClickPos

func (i *Input) GetClickPos() Position

func (*Input) Update

func (i *Input) Update()

type LRUCache

type LRUCache struct {
	Capacity int
	Used     int
	// contains filtered or unexported fields
}

func NewLRUCache

func NewLRUCache(capacity int) *LRUCache

func (*LRUCache) Get

func (this *LRUCache) Get(key MenualKey) *MenualItem

func (*LRUCache) Put

func (this *LRUCache) Put(key MenualKey, value *MenualItem)
type MenualItem struct {
	Level      int
	Estimation Score
}
type MenualKey string

type PieceType

type PieceType byte
const (
	Black PieceType = iota
	White
	Border
	None
)

type Player

type Player interface {
	Resolve(Position) Position
	Reset()
}

type Position

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

type Referee

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

func NewRefree

func NewRefree(cb *ChessBoard, players [2]Player) *Referee

func (*Referee) Start

func (ref *Referee) Start()

type Score

type Score = int
const (
	Win           Score = 30000
	Lose          Score = -30000
	HuoSiScore    Score = 20000
	SiSanSore     Score = 10000
	ChongSIScore  Score = 1000
	HuosanScore   Score = 800
	ChongSanScore Score = 400
	HuoErScore    Score = 50
	ChongErScore  Score = 20
)

func Evaluate

func Evaluate(cb ChessBoard, i, j int, piece PieceType) Score

Jump to

Keyboard shortcuts

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