Skip to content

Commit

Permalink
engineOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
vinymeuh committed Jan 15, 2024
1 parent 885e3ab commit a809b73
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ import (
"github.com/vinymeuh/hifumi/shogi/movegen"
)

// ==================================== //
// ===== engineX global variables ===== //
// ==================================== //
const (
EngineName = "Hifumi"
EngineVersion = "0.0.0"
Expand Down Expand Up @@ -49,27 +46,28 @@ Use "d" to display current state of the game.
`
)

var engineOptions = struct {
options map[string]usiOption
}{
options: map[string]usiOption{
// ==================================== //
// ===== engineX global variables ===== //
// ==================================== //
var (
engineOptions = map[string]usiOption{
"USI_Variant": comboOption{
value: "shogi",
values: []string{"shogi"},
callback: noopStringCallback,
},
},
}
}

var engineStatus = struct {
stopRequested chan struct{}
pv principalVariation
}{
stopRequested: nil,
pv: principalVariation{line: [1]movegen.Move{0}},
}
engineStatus = struct {
stopRequested chan struct{}
pv principalVariation
}{
stopRequested: nil,
pv: principalVariation{line: [1]movegen.Move{0}},
}

var enginePosition *shogi.Position
enginePosition *shogi.Position
)

// ================================== //
// ============ Usi Loop ============ //
Expand Down Expand Up @@ -128,7 +126,7 @@ func UsiLoop() {
func usiHandler() {
fmt.Println("id name", EngineName, EngineVersion)
fmt.Println("id author", EngineAuthor)
for name, option := range engineOptions.options {
for name, option := range engineOptions {
fmt.Println("option name", name, option)
}
fmt.Println("usiok")
Expand All @@ -146,15 +144,15 @@ func setoptionHandler(args []string) {
switch {
case len(args) == 3 && args[1] == "name":
optionName := args[2]
if option, ok := engineOptions.options[optionName]; ok {
if option, ok := engineOptions[optionName]; ok {
option.set("")
} else {
fmt.Println("No such option:", optionName)
}
case len(args) == 5 && args[1] == "name" && args[3] == "value":
optionName := args[2]
optionValue := args[4]
if option, ok := engineOptions.options[optionName]; ok {
if option, ok := engineOptions[optionName]; ok {
if err := option.set(optionValue); err != nil {
fmt.Println("Invalid value:", err)
}
Expand Down

0 comments on commit a809b73

Please sign in to comment.