diff --git a/engines/engine.go b/engines/engine.go new file mode 100644 index 0000000..362b6ab --- /dev/null +++ b/engines/engine.go @@ -0,0 +1,9 @@ +package engines + +import ( + "github.com/notnil/chess" +) + +type Engine interface { + SuggestedMove(pos *chess.Position, maxPlayer bool) *chess.Move +} diff --git a/engine/minimax.go b/engines/minimax.go similarity index 95% rename from engine/minimax.go rename to engines/minimax.go index 0ccb408..321c7da 100644 --- a/engine/minimax.go +++ b/engines/minimax.go @@ -1,4 +1,4 @@ -package engine +package engines import ( "fmt" @@ -10,9 +10,11 @@ import ( "github.com/notnil/chess" ) +type MinimaxEngine struct {} + // SuggestedMove calculates the most advantageous move for the player. It currently works // synchronously, but can probably be made concurrent with goroutines. -func SuggestedMove(pos *chess.Position, maxPlayer bool) *chess.Move { +func (e *MinimaxEngine) SuggestedMove(pos *chess.Position, maxPlayer bool) *chess.Move { startingDepth := 3 return minimax(pos, startingDepth, maxPlayer).move } diff --git a/engine/minimax_test.go b/engines/minimax_test.go similarity index 99% rename from engine/minimax_test.go rename to engines/minimax_test.go index 89d6521..928be93 100644 --- a/engine/minimax_test.go +++ b/engines/minimax_test.go @@ -1,4 +1,4 @@ -package engine +package engines import ( "fmt" diff --git a/main.go b/main.go index 186c986..26e5be0 100644 --- a/main.go +++ b/main.go @@ -6,11 +6,12 @@ import ( "github.com/notnil/chess" - "github.com/jameshochadel/chess-bot/engine" + "github.com/jameshochadel/chess-bot/engines" ) func main() { game := chess.NewGame() + engine := engines.MinimaxEngine{} for game.Outcome() == chess.NoOutcome { // how to do context with timeout? basically want to go as far as possible until timeout.