Skip to content

Commit

Permalink
refactor: perft
Browse files Browse the repository at this point in the history
  • Loading branch information
leonhfr committed Jul 1, 2023
1 parent 1762174 commit ab778cc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ run:

.PHONY: perft
perft:
perftree ./perft.sh
perftree ./test/perft/perft.sh

.PHONY: gen
gen:
Expand Down
15 changes: 0 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,6 @@ var (
)

func main() {
if len(os.Args) > 1 {
r, err := perft(os.Args[1:])
if err != nil {
fmt.Println(err)
os.Exit(1)
}

fmt.Println(r)
return
}

run()
}

func run() {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
defer stop()

Expand Down
17 changes: 17 additions & 0 deletions perft.go → test/perft/perft.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
// This package provides the capability to run perft tests.
package main

import (
"errors"
"fmt"
"os"
"strconv"
"strings"

"github.com/leonhfr/orca/chess"
)

func main() {
if len(os.Args) < 1 {
fmt.Println("expected arguments to be provided")
os.Exit(1)
}

r, err := perft(os.Args[1:])
if err != nil {
fmt.Println(err)
os.Exit(1)
}

fmt.Println(r)
}

// perft expects the arguments to be depth, then fen,
// and finally an optional space-separated move list.
func perft(args []string) (chess.PerftResult, error) {
Expand Down
File renamed without changes.

0 comments on commit ab778cc

Please sign in to comment.