-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (47 loc) · 1.12 KB
/
main.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
45
46
47
48
49
50
51
52
53
package main
import (
"bufio"
"flag"
"fmt"
"log"
"macsmol/magog/engine"
"os"
"strings"
)
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
func main() {
printWelcome()
// ---------- runtime profiling stuff ---------------
flag.Parse()
if *cpuprofile != "" {
fmt.Println("created file for profile.....", *cpuprofile)
var f *os.File
var err error
f, err = os.Create(*cpuprofile)
if err != nil {
log.Fatal(err)
}
engine.ProfileFile = f
}
// ---------- runtime profiling stuff -end- ---------
scanner := bufio.NewScanner(os.Stdin)
for !engine.Quit {
scanner.Scan()
engine.ParseInputLine(scanner.Text())
}
}
func printWelcome() {
var banner string =
` _ __ ____ ____ ___ ____
| ' \/ _ / _ / _ \/ _ |
|_|_|_\__,_\__, \___/\__, |
v. . . . . |___/ . . |___/
. . UCI chess engine . .
`
mutableBanner := []rune(banner)
verPrefixStr := "v."
i := strings.Index(banner, verPrefixStr) + len(verPrefixStr)
copy(mutableBanner[i:], []rune(engine.VERSION_STRING + " "))
fmt.Println(string(mutableBanner))
fmt.Println("Welcome! Please input a UCI command or type 'help'.")
}