take9

package
v0.0.0-...-4b218a3 Latest Latest
Warning

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

Go to latest
Published: May 1, 2022 License: MIT Imports: 15 Imported by: 0

README

take9

玉は逃げてくれてるようだし、アルファベータ探索入れてみよかな(^~^)
その前に駒得評価関数入れてみるかな(^~^)?
駒が文字列なのは気になるな、定数にするかな(^~^)

Test1

# 何が反則手なのか(^~^)?
position startpos moves 7g7f 6c6d 6i7h 6a5b 7i6h 1c1d 6h7g 7a6b 5i6h 4a3b 4i5h 1d1e 6g6f 5a4a 5h6g 6b6c 7f7e 8b9b 3i3h 4c4d 6g5f 9b7b 5f5e 1a1d 5e4d 7b7a 9g9f 3c3d 4d3d 7a7b 3d3e 3b4b 3e2e 3a3b 2e1d 2b5e L*4f 4a3a 4f4b+ 3a2b G*4e 5e4f 4b5b 7b5b 4g4f
# go btime 83000 wtime 82000 binc 2000 winc 2000
# 反則手
# bestmove L+3e

Test2

# 持ち駒がいっぱいある局面(^~^)
position sfen 4k4/9/9/9/9/9/9/9/4K4 b RBG2S2N2L2P9rbg2s2n2l2p9 1

Documentation

Overview

駒の価値

Index

Constants

View Source
const RESIGN_MOVE_END = MoveEnd(0)

0 は 投了ということにするぜ(^~^)

Variables

App - アプリケーション変数の宣言

View Source
var OneDigitNumbers = [10]byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}

position sfen の盤のスペース数に使われますN

Functions

func Demote

func Demote(piece l03.Piece) l03.Piece

Demote - 成っている駒を、成っていない駒に戻します

func EvalMaterial

func EvalMaterial(piece l03.Piece) int16

EvalMaterial - 駒の価値。開発者のむずでょが勝手に決めた(^~^)

func FlipPhase

func FlipPhase(phase l03.Phase) l03.Phase

FlipPhase - 先後を反転します

func GenMoveList

func GenMoveList(pPos *Position) []l03.Move

GenMoveList - 現局面の指し手のリスト。合法手とは限らないし、全ての合法手を含むとも限らないぜ(^~^)

func MainLoop

func MainLoop()

MainLoop - 開始。

func NifuFirst

func NifuFirst(pPos *Position, file l03.Square) bool

NifuFirst - 先手で二歩になるか筋調べ

func NifuSecond

func NifuSecond(pPos *Position, file l03.Square) bool

NifuSecond - 後手で二歩になるか筋調べ

func OnBoard

func OnBoard(sq l03.Square) bool

盤上なら真。ラベルのとこを指定しても場所によっては真だがめんどくさいんでOKで(^~^)

func Promote

func Promote(piece l03.Piece) l03.Piece

Promote - 成ります

func Search(pPos *Position) l03.Move

Search - 探索部

func SprintBoard

func SprintBoard(pPos *Position) string

Print - 局面出力(^q^)

func SprintRecord

func SprintRecord(pPos positionForRecord) string

SprintRecord - 棋譜表示(^~^)

func SquareFrom

func SquareFrom(file l03.Square, rank l03.Square) l03.Square

From - 筋と段からマス番号を作成します

Types

type MoveEnd

type MoveEnd uint8

MoveEnd - 移動先と成り

pddd dddd

1~7bit: 移動先(0~127) 8bit: 成(0~1)

func GenMoveEnd

func GenMoveEnd(pPos *Position, from l03.Square) []MoveEnd

GenMoveEnd - 利いているマスの一覧を返します。動けるマスではありません。

func NewMoveEnd

func NewMoveEnd(to l03.Square, promotion bool) MoveEnd

NewMoveEnd - 移動先マス、成りの有無 を指定してください

func (MoveEnd) Destructure

func (moveEnd MoveEnd) Destructure() (l03.Square, bool)

Destructure

移動先マス 0111 1111 (Mask) 0x7f pddd dddd

成 1000 0000 (Mask) 0x80 pddd dddd

func (MoveEnd) ToString

func (moveEnd MoveEnd) ToString() string

ToString - 確認用の文字列

type Position

type Position struct {
	// Go言語で列挙型めんどくさいんで文字列で(^~^)
	// [19] は 1九、 [91] は 9一(^~^)反時計回りに90°回転した将棋盤の状態で入ってるぜ(^~^)想像しろだぜ(^~^)
	Board [l03.BOARD_SIZE]l03.Piece
	// 玉と長い利きの駒の場所。長い利きを消すのに使う
	// [0]先手玉 [1]後手玉 [2:3]飛 [4:5]角 [6:9]香
	PieceLocations [l07.PCLOC_SIZE]l03.Square
	// 利きテーブル [0]先手 [1]後手
	// マスへの利き数が入っています
	ControlBoards [2][l03.BOARD_SIZE]int8
	// マスへの利き数の差分が入っています。デバッグ目的で無駄に分けてるんだけどな(^~^)
	// プレイヤー1つにつき、5レイヤーあるぜ(^~^)
	ControlBoardsDiff [2][5][l03.BOARD_SIZE]int8

	// 持ち駒の数だぜ(^~^) R, B, G, S, N, L, P, r, b, g, s, n, l, p
	Hands []int
	// 先手が1、後手が2(^~^)
	Phase l03.Phase
	// 開始局面の時点で何手目か(^~^)これは表示のための飾りのようなものだぜ(^~^)
	StartMovesNum int
	// 開始局面から数えて何手目か(^~^)0から始まるぜ(^~^)
	OffsetMovesIndex int
	// 指し手のリスト(^~^)
	// 1手目は[0]へ、512手目は[511]へ入れろだぜ(^~^)
	Moves [l02.MOVES_SIZE]l03.Move
	// 取った駒のリスト(^~^)アンドゥ ムーブするときに使うだけ(^~^)指し手のリストと同じ添え字を使うぜ(^~^)
	CapturedList [l02.MOVES_SIZE]l03.Piece
}

Position - 局面

func NewPosition

func NewPosition() *Position

func (*Position) AddControlDiff

func (pPos *Position) AddControlDiff(layer int, from l03.Square, sign int8)

AddControlDiff - 盤上のマスを指定することで、そこにある駒の利きを調べて、利きの差分テーブルの値を増減させます

func (*Position) AddControlDiffAllSlidingPiece

func (pPos *Position) AddControlDiffAllSlidingPiece(layer int, sign int8, excludeFrom l03.Square)

AddControlDiffAllSlidingPiece - すべての長い利きの駒の利きを調べて、利きの差分テーブルの値を増減させます

func (*Position) ClearControlDiff

func (pPos *Position) ClearControlDiff()

ClearControlDiff - 利きの差分テーブルをクリアーするぜ(^~^)

func (*Position) DoMove

func (pPos *Position) DoMove(move l03.Move)

DoMove - 一手指すぜ(^~^)

func (*Position) Dump

func (pPos *Position) Dump() string

Dump - 内部状態を全部出力しようぜ(^~^)?

func (*Position) GetCapturedPieceAtMovesIndex

func (pPos *Position) GetCapturedPieceAtMovesIndex(movesIndex int) l03.Piece

func (*Position) GetLocationOfLongPiece

func (pPos *Position) GetLocationOfLongPiece(index int) l03.Square

GetLongPiece - 長い利きの駒の場所を取得

func (*Position) GetMoveAtMovesIndex

func (pPos *Position) GetMoveAtMovesIndex(movesIndex int) l03.Move

func (*Position) GetOffsetMoveIndex

func (pPos *Position) GetOffsetMoveIndex() int

func (*Position) Hetero

func (pPos *Position) Hetero(from l03.Square, to l03.Square) bool

Hetero - 移動元と移動先の駒を持つプレイヤーが異なれば真。移動先が空マスでも真 持ち駒は指定してはいけません。 Homo の逆だぜ(^~^)片方ありゃいいんだけど(^~^)

func (*Position) Homo

func (pPos *Position) Homo(from l03.Square, to l03.Square) bool

Homo - 移動元と移動先の駒を持つプレイヤーが等しければ真。移動先が空なら偽 持ち駒は指定してはいけません。

func (*Position) IsEmptySq

func (pPos *Position) IsEmptySq(sq l03.Square) bool

IsEmptySq - 空きマスなら真。持ち駒は偽

func (*Position) MergeControlDiff

func (pPos *Position) MergeControlDiff()

MergeControlDiff - 利きの差分を解消するぜ(^~^)

func (*Position) ReadPosition

func (pPos *Position) ReadPosition(command string)

ReadPosition - 局面を読み取ります。マルチバイト文字は含まれていないぜ(^q^)

func (*Position) SprintControl

func (pPos *Position) SprintControl(phase l03.Phase, flag int) string

SprintControl - 利き数ボード出力(^q^)

Parameters ---------- * `flag` - 0: 利き数ボード, 1-5:利き数の差分ボードのレイヤー[0]~[4]

func (*Position) SprintRecord

func (pPos *Position) SprintRecord() string

SprintRecord - 棋譜表示(^~^)

func (*Position) SprintSfen

func (pPos *Position) SprintSfen() string

SprintSfen - SFEN文字列返せよ(^~^)

func (*Position) UndoMove

func (pPos *Position) UndoMove()

UndoMove - 棋譜を頼りに1手戻すぜ(^~^)

Jump to

Keyboard shortcuts

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