-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.go
38 lines (34 loc) · 961 Bytes
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package chessongo
import (
"fmt"
)
func PrintBitboard(bb Bitboard, title string) {
var shiftMask uint64 = 1
//bb.printB("pp2")
fmt.Printf("________________%s_______________________\n", title)
for r := 7; r >= 0; r-- {
for f := 7; f >= 0; f-- {
var squareIdx uint = uint(r*8 + f)
if bb&Bitboard(shiftMask<<squareIdx) > 0 {
fmt.Printf("%c%d: X ", file(Square(squareIdx)), rank(Square(squareIdx)))
} else {
fmt.Printf("%c%d: _ ", file(Square(squareIdx)), rank(Square(squareIdx)))
}
}
fmt.Println("")
}
}
func (b *Board) PrintBoard(title string) {
fmt.Printf("________________%s_______________________\n", title)
for i, v := range b.Squares {
if i%8 == 0 {
fmt.Println("")
}
if v.ToRune() == ' ' {
fmt.Printf(" %c%d:- ", file(Square(i)), rank(Square(i)))
} else {
fmt.Printf(" %c%d:%c ", file(Square(i)), rank(Square(i)), v.ToRune())
}
}
fmt.Printf("\n_______________________________________\n")
}