take10

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: 18 Imported by: 0

README

take10

玉は逃げてくれてるようだし、アルファベータ探索入れてみよかな(^~^)
その前に駒得評価関数入れてみるかな(^~^)?
駒得評価を入れてみたけど、きふわらべがどう評価しているか見えないぜ(^~^) 評価値出してくれだぜ(^~^)
利きの差分表も 飛、角、香 は分けようかなあ(^~^)?
テスト用のランダム局面を増やすために、プレイアウトも欲しいぜ(^~^)
王手回避のときに打をしてないので、間駒するようにしたいぜ(^~^)

Test

# 強制終了した(^~^) -> 配列のサイズが変わっていたので length 再計算(^~^)
position startpos moves 7g7f 3a4b 6i7h 6c6d 7i6h 5a6b 8h5e 4b5a 5e6d 2c2d 6h7g 6b6c 6d4f 8b3b 4f2d 7a8b 3i4h 1c1d 5i6h 5a6b 7g8h 4a5a 8g8f 2b3a 8h8g 6a5b 7h7i 3b2b 2d4f
go btime 75000 wtime 74000 binc 2000 winc 2000

# 飛打されてなぜか即投了(^~^)->利きボードの内容がおかしい ->利きボードも、SFENパーサーもおかしかったので直した(^~^)
position startpos moves 7g7f 3c3d 2g2f 2b8h 7i8h 1c1d B*4e B*7h 6i7h 8c8d 4e6c+ 3d3e 6c5c 8b6b 5c6b 5a6b R*6d
go btime 69000 wtime 68000 binc 2000 winc 2000
# 手を戻してみよ(^~^)馬で王手されてるな(^~^)
position startpos moves 7g7f 3c3d 2g2f 2b8h 7i8h 1c1d B*4e B*7h 6i7h 8c8d 4e6c+ 3d3e 6c5c 8b6b 5c6b
movelist
MoveList
--------
(0) 5a6b
(1) 5a4b
* Except for those to be removed during the search

# 強制終了
position startpos moves 7i6h 4a3b 2h3h 6a5b 3h4h 3a4b 3i3h 7a7b 2g2f 3c3d 6h7i 4b3c 8g8f 5a4b 6i5h 3d3e 7i6h 8c8d 5i6i 7b8c 9i9h 9c9d 9g9f 5c5d 8h7i 8c7d 4i3i 7d7e 2f2e 7e8f 7g7f 8f8g 6h7g 8g9h+ 4g4f L*8e 5g5f 8e8i+ 7g8f 8i7i 6i7i N*8e 8f8e 8d8e N*4g 8e8f 4g3e 8f8g+ 3e2c 8g7h
go

# 違法手。香車持ってないのに打った(^~^)先後間違えてる(^~^)? -> 先後のどちらの駒も打つようになってたので修正(^~^)
position startpos moves 7g7f 8b4b 3i4h 9a9b 5i6h 6c6d 8h5e 6a7b 5e6d 9c9d 6d5c+ 8a9c 5c4b 3a4b R*9a B*8d 9a9b+ 8d5g 4h5g
go btime 70000 wtime 69000 binc 2000 winc 2000
info depth 0 nodes 118 score cp 0 currmove L*3b pv L*3b
bestmove L*3b
gameover win

Test2

# 平手初期局面
position startpos

# 利きボード目視確認
control layer 0

[Control(0)Sum l03.FIRST]

  9  8  7  6  5  4  3  2  1
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| a
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| b
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| c
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| d
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| e
+--+--+--+--+--+--+--+--+--+
| 1| 1| 1| 1| 1| 1| 1| 1| 1| f
+--+--+--+--+--+--+--+--+--+
| 3| 0| 2| 0| 0| 0| 1| 1| 2| g
+--+--+--+--+--+--+--+--+--+
| 1| 2| 3| 4| 4| 4| 3| 1| 2| h
+--+--+--+--+--+--+--+--+--+
| 1| 0| 2| 1| 2| 1| 1| 1| 0| i
+--+--+--+--+--+--+--+--+--+


[Control(0)Sum Second]

  9  8  7  6  5  4  3  2  1
+--+--+--+--+--+--+--+--+--+
| 0| 1| 1| 1| 2| 1| 2| 0| 1| a
+--+--+--+--+--+--+--+--+--+
| 2| 1| 3| 4| 4| 4| 3| 2| 1| b
+--+--+--+--+--+--+--+--+--+
| 2| 1| 1| 0| 0| 0| 2| 0| 3| c
+--+--+--+--+--+--+--+--+--+
| 1| 1| 1| 1| 1| 1| 1| 1| 1| d
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| e
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| f
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| g
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| h
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| i
+--+--+--+--+--+--+--+--+--+

# 利き再計算
control recalc 12

# 目視確認
control layer 12

[Control(12)TestRecalc l03.FIRST]

  9  8  7  6  5  4  3  2  1
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| a
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| b
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| c
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| d
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| e
+--+--+--+--+--+--+--+--+--+
| 1| 1| 1| 1| 1| 1| 1| 1| 1| f
+--+--+--+--+--+--+--+--+--+
| 3| 0| 2| 0| 0| 0| 1| 1| 2| g
+--+--+--+--+--+--+--+--+--+
| 1| 2| 3| 4| 4| 4| 3| 1| 2| h
+--+--+--+--+--+--+--+--+--+
| 1| 0| 2| 1| 2| 1| 1| 1| 0| i
+--+--+--+--+--+--+--+--+--+


[Control(12)TestRecalc Second]

  9  8  7  6  5  4  3  2  1
+--+--+--+--+--+--+--+--+--+
| 0| 1| 1| 1| 2| 1| 2| 0| 1| a
+--+--+--+--+--+--+--+--+--+
| 2| 1| 3| 4| 4| 4| 3| 2| 1| b
+--+--+--+--+--+--+--+--+--+
| 2| 1| 1| 0| 0| 0| 2| 0| 3| c
+--+--+--+--+--+--+--+--+--+
| 1| 1| 1| 1| 1| 1| 1| 1| 1| d
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| e
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| f
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| g
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| h
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| i
+--+--+--+--+--+--+--+--+--+

# 利きボード比較
control diff 0 12 10

# 違いをカウント
control sumabs 10
ControlTest: SumAbs=0,0

# 目視確認
control layer 0

[Control(0)Sum l03.FIRST]

  9  8  7  6  5  4  3  2  1
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| a
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| b
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| c
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| d
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| e
+--+--+--+--+--+--+--+--+--+
| 1| 1| 1| 1| 1| 1| 1| 1| 1| f
+--+--+--+--+--+--+--+--+--+
| 3| 0| 2| 0| 0| 0| 1| 1| 2| g
+--+--+--+--+--+--+--+--+--+
| 1| 2| 3| 4| 4| 4| 3| 1| 2| h
+--+--+--+--+--+--+--+--+--+
| 1| 0| 2| 1| 2| 1| 1| 1| 0| i
+--+--+--+--+--+--+--+--+--+


[Control(0)Sum Second]

  9  8  7  6  5  4  3  2  1
+--+--+--+--+--+--+--+--+--+
| 0| 1| 1| 1| 2| 1| 2| 0| 1| a
+--+--+--+--+--+--+--+--+--+
| 2| 1| 3| 4| 4| 4| 3| 2| 1| b
+--+--+--+--+--+--+--+--+--+
| 2| 1| 1| 0| 0| 0| 2| 0| 3| c
+--+--+--+--+--+--+--+--+--+
| 1| 1| 1| 1| 1| 1| 1| 1| 1| d
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| e
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| f
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| g
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| h
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| i
+--+--+--+--+--+--+--+--+--+

# 目視確認
control layer 10

[Control(10)TestCopy l03.FIRST]

  9  8  7  6  5  4  3  2  1
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| a
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| b
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| c
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| d
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| e
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| f
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| g
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| h
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| i
+--+--+--+--+--+--+--+--+--+


[Control(10)TestCopy Second]

  9  8  7  6  5  4  3  2  1
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| a
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| b
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| c
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| d
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| e
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| f
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| g
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| h
+--+--+--+--+--+--+--+--+--+
| 0| 0| 0| 0| 0| 0| 0| 0| 0| i
+--+--+--+--+--+--+--+--+--+

Documentation

Overview

駒の価値

利きボード

利きのテスト

Index

Constants

View Source
const (
	CONTROL_LAYER_SUM = iota
	CONTROL_LAYER_DIFF_ROOK_OFF
	CONTROL_LAYER_DIFF_BISHOP_OFF
	CONTROL_LAYER_DIFF_LANCE_OFF
	CONTROL_LAYER_DIFF_PUT // 打とか指すとか
	CONTROL_LAYER_DIFF_REMOVE
	CONTROL_LAYER_DIFF_CAPTURED
	CONTROL_LAYER_DIFF_LANCE_ON
	CONTROL_LAYER_DIFF_BISHOP_ON
	CONTROL_LAYER_DIFF_ROOK_ON
	CONTROL_LAYER_TEST_COPY          // テスト用
	CONTROL_LAYER_TEST_ERROR         // テスト用
	CONTROL_LAYER_TEST_RECALCULATION // テスト用 再計算
	CONTROL_LAYER_DIFF_START         = 1
	CONTROL_LAYER_DIFF_END           = 10 // この数を含まない。テスト用も含まない
	CONTROL_LAYER_ALL_SIZE           = 13 // この数を含まない
)
View Source
const RESIGN_MOVE_END = MoveEnd(0)

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

Variables

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

Convert hand index to piece

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

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

Functions

func CountAllPieces

func CountAllPieces(pPos *Position) [8]int

CountAllPieces - 駒の数を確認するぜ(^~^)

func CountErrorCountLists

func CountErrorCountLists(countList1 [8]int, countList2 [8]int) int

CountErrorCountLists - 数えた駒の枚数を比較します

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 GetControlLayerName

func GetControlLayerName(layer int) string

GetControlLayerName - 利きボードのレイヤーの名前

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

OnBoard - 盤上なら真

func OnHands

func OnHands(sq l03.Square) bool

OnHands - 持ち駒なら真

func Search(pPos *Position) l03.Move

Search - 探索部

func ShowAllPiecesCount

func ShowAllPiecesCount(pPos *Position)

ShowAllPiecesCount - 駒の枚数表示

func ShuffleBoard

func ShuffleBoard(pPos *Position)

ShuffleBoard - 盤上の駒、持ち駒をシャッフルします ゲーム中にはできない動きをするので、利きの計算は無視します。 最後に利きは再計算します

func SprintBoard

func SprintBoard(pPos *Position) string

Print - 局面出力(^q^)

func SquareFrom

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

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

func SumAbsControl

func SumAbsControl(pPos *Position, layer1 int) [2]int

SumAbsControl - 利きテーブルの各マスを絶対値にし、その総和を返します

func TestControl

func TestControl(pPos *Position) (bool, string)

TestControl

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]後手
	// [0] 利き
	// [1] 飛の利き引く(差分)
	// [2] 角の利き引く(差分)
	// [3] 香の利き引く(差分)
	// [4] ムーブ用(差分)
	// [5] ムーブ用(差分)
	// [6] ムーブ用(差分)
	// [7] 香の利き戻す(差分)
	// [8] 角の利き戻す(差分)
	// [9] 飛の利き戻す(差分)
	// [10] テスト用
	// [11] テスト用
	// [12] テスト用(再計算)
	ControlBoards [2][CONTROL_LAYER_ALL_SIZE][l03.BOARD_SIZE]int8

	// 持ち駒の数だぜ(^~^) R, B, G, S, N, L, P, r, b, g, s, n, l, p
	Hands []int

	// 開始局面の時点で何手目か(^~^)これは表示のための飾りのようなものだぜ(^~^)
	StartMovesNum int
	// 開始局面から数えて何手目か(^~^)0から始まるぜ(^~^)
	OffsetMovesIndex int
	// 指し手のリスト(^~^)
	// 1手目は[0]へ、512手目は[511]へ入れろだぜ(^~^)
	Moves [l02.MOVES_SIZE]l03.Move
	// 取った駒のリスト(^~^)アンドゥ ムーブするときに使うだけ(^~^)指し手のリストと同じ添え字を使うぜ(^~^)
	CapturedList [l02.MOVES_SIZE]l03.Piece
	// contains filtered or unexported fields
}

Position - 局面

func NewPosition

func NewPosition() *Position

func (*Position) AddControlBishop

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

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

func (*Position) AddControlDiff

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

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

func (*Position) AddControlLance

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

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

func (*Position) AddControlRook

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

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

func (*Position) ClearControlDiff

func (pPos *Position) ClearControlDiff()

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

func (*Position) ClearControlLayer

func (pPos *Position) ClearControlLayer(layer int)

func (*Position) DiffControl

func (pPos *Position) DiffControl(layer1 int, layer2 int, layer3 int)

DiffControl - 利きテーブルの差分計算

func (*Position) DoMove

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

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

func (*Position) Dump

func (pPos *Position) Dump() string

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

func (*Position) FlipPhase

func (pPos *Position) FlipPhase()

FlipPhase - フェーズをひっくり返すぜ(^~^)

func (*Position) GetLocationOfLongPiece

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

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

func (*Position) GetPhase

func (pPos *Position) GetPhase() l03.Phase

GetPhase - フェーズ

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) RecalculateControl

func (pPos *Position) RecalculateControl(layer1 int)

RecalculateControl - 利きの再計算

func (*Position) SprintControl

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

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

Parameters ---------- * `layer` - 利き数ボードのレイヤー番号(^~^)

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