-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchallenge_self.go
44 lines (36 loc) · 886 Bytes
/
challenge_self.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
39
40
41
42
43
44
package main
import (
"math"
"github.com/0hq/chess"
)
func challenge_self(white Engine, black Engine, game *chess.Game) {
max_moves := math.MaxInt
// game.UseNotation(global_AlgebraicNotation)
out("Self challenge started.")
out("Engine 1 (white):", white.Name())
out("Engine 2 (black):", black.Name())
out("Game:", game.String())
out(game.Position().Board().Draw())
out()
for game.Outcome() == chess.NoOutcome && len(game.Moves()) < max_moves {
var move *chess.Move
var eval int
if game.Position().Turn() == chess.White {
move, eval = white.Run_Engine_Game(game)
} else {
move, eval = black.Run_Engine_Game(game)
}
if move == nil {
panic("NO MOVE")
}
err := game.Move(move)
if err != nil {
panic(err)
}
out(game.Position().Turn(), move, eval)
out(game.FEN())
out(game.String())
out(game.Position().Board().Draw())
out()
}
}