Added argument parsing to run the solver correctly
This commit is contained in:
@ -1,7 +1,30 @@
|
||||
package solver
|
||||
|
||||
import "maze-solver/maze"
|
||||
import (
|
||||
"fmt"
|
||||
"maze-solver/maze"
|
||||
)
|
||||
|
||||
type Solver interface {
|
||||
Solve(*maze.Maze) *maze.SolvedMaze
|
||||
}
|
||||
|
||||
type SolverFactory struct {
|
||||
Type *string
|
||||
}
|
||||
|
||||
const (
|
||||
_TURN_LEFT = "turn-left"
|
||||
)
|
||||
|
||||
var TYPES = []string{
|
||||
_TURN_LEFT,
|
||||
}
|
||||
|
||||
func (f *SolverFactory) Get() Solver {
|
||||
switch *f.Type {
|
||||
case _TURN_LEFT:
|
||||
return &TurnLeftSolver{}
|
||||
}
|
||||
panic(fmt.Sprintf("Unrecognized solver type %q", *f.Type))
|
||||
}
|
||||
|
Reference in New Issue
Block a user