Skip to content

Commit ff3e15b

Browse files
committed
go-command and movegen
1 parent 4989c2f commit ff3e15b

File tree

5 files changed

+78
-5
lines changed

5 files changed

+78
-5
lines changed

uci_example.txt renamed to engine-interface.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ This is how the communication when the engine boots can look like:
436436

437437
uci
438438

439-
id name GoBit
439+
id name BinGo
440440
id author Carokanns
441441
option name Hash type spin default 1 min 1 max 128
442442
option name Style type combo default Normal var Solid var Normal var Risky

engine.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
11
package main
22

3-
import "fmt"
3+
import (
4+
"fmt"
5+
"math"
6+
)
47

8+
type searchLimits struct {
9+
depth int
10+
nodes uint64
11+
moveTime int // in milliseconds
12+
infinite bool
13+
}
14+
15+
var limits searchLimits
16+
17+
func (s *searchLimits) init() {
18+
s.depth = 9999
19+
s.nodes = math.MaxUint64
20+
s.moveTime = 99999999999
21+
s.infinite = false
22+
}
23+
24+
func (s *searchLimits) setDepth(d int) {
25+
s.depth = d
26+
}
27+
func (s *searchLimits) setMoveTime(m int) {
28+
s.moveTime = m
29+
}
530
func engine() (toEngine chan string, frEngine chan string) {
631
fmt.Println("info string Hello from engine")
732
frEngine = make(chan string)
@@ -12,6 +37,10 @@ func engine() (toEngine chan string, frEngine chan string) {
1237
switch cmd {
1338
case "stop":
1439
case "quit":
40+
case "go":
41+
tell("info string Im thinking")
42+
// TODO start the thinking process in the engine from "go"
43+
1544
}
1645
}
1746
}()

move.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package main
2+
3+
// directions
4+
const (
5+
E = +1
6+
W = -1
7+
N = 8
8+
S = -8
9+
NW = +7
10+
NE = +9
11+
SW = -NE
12+
SE = -NW
13+
)
14+
15+
var pieceRules[nP][]int // not pawns
16+
type moveList struct {
17+
mv []move
18+
}
19+
func init(){
20+
pieceRules[Rook] = append(pieceRules[Rook],E)
21+
pieceRules[Rook] = append(pieceRules[Rook],W)
22+
pieceRules[Rook] = append(pieceRules[Rook],N)
23+
pieceRules[Rook] = append(pieceRules[Rook],S)
24+
}
25+
26+
func (ml *moveList) add(mv move) {
27+
ml.mv = append(ml.mv, mv)
28+
}
29+
30+
type move uint64
31+
32+
var ml = moveList{}

position.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,17 @@ func (b *boardStruct) newGame() {
170170
b.clear()
171171
parseFEN(startpos)
172172
}
173+
func (b *boardStruct) genRookMoves() {
174+
sd := b.stm
175+
frBB := b.pieceBB[Rook] & b.wbBB[sd]
176+
p12 := pc2P12(Rook,sd)
177+
b.genFrMoves(p12,frBB,&ml)
178+
}
179+
180+
func (b *boardStruct) genFrMoves(p12 int, frBB bitBoard, ml *moveList){
181+
// TODO finish genRookMoves
182+
}
183+
173184

174185
//////////////////////////////////// my own commands - NOT UCI /////////////////////////////////////
175186
func (b *boardStruct) Print() {

uci.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var saveBm = ""
1616

1717
func uci(input chan string) {
1818
fmt.Println("info string Hello from uci")
19-
// TODO: Two non UCI-commands PB and PBB
19+
2020
toEng, frEng := engine()
2121
bInfinite := false
2222
var cmd string
@@ -153,9 +153,10 @@ func handleSetOption(words []string) {
153153
tell("info string setoption not implemented")
154154
}
155155

156-
// go searchmoves <move1-moveii>/ponder/wtime <ms>/ btime <ms>/winc <ms>/binc <ms>/movestogo <x>/depth <x>/nodes <x>/movetime <ms>/mate <x>/infinite
156+
// go searchmoves <move1-moveii>/ponder/wtime <ms>/ btime <ms>/winc <ms>/binc <ms>/movestogo <x>/
157+
// depth <x>/nodes <x>/movetime <ms>/mate <x>/infinite
157158
func handleGo(words []string) {
158-
// TODO: Start with the go-command
159+
// TODO: Start with moeveTime and infinite
159160
if len(words) > 1 {
160161
words[1] = trim(low(words[1]))
161162
switch words[1] {

0 commit comments

Comments
 (0)