summaryrefslogtreecommitdiff
path: root/src/uci.c
diff options
context:
space:
mode:
authorAargh Rai <aargh.rai+git@gmail.com>2026-07-07 14:30:21 +0530
committerAargh Rai <aargh.rai+git@gmail.com>2026-07-07 14:30:21 +0530
commit965bf81879b22a25fd9b0d17ce6defd3d51c6173 (patch)
treeeeadd04afb52e950a3345c7fa4bc51d94446a658 /src/uci.c
parent3c540db464f4034d0a393b076c79a26851f68f47 (diff)
engine can now send updates to uci
Diffstat (limited to 'src/uci.c')
-rw-r--r--src/uci.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/src/uci.c b/src/uci.c
index 3bfd8d3..9e3c8c7 100644
--- a/src/uci.c
+++ b/src/uci.c
@@ -34,69 +34,68 @@ void load_from_message(ucicmd* cmd, const char* message) {
ucicmd_add(cmd, token);
}
-int uci(comms *com) {
- printf("%d\n", com->uci_message_ready);
-
+void *uci(void *_com) {
+ comms *com = (comms*)_com;
// https://stackoverflow.com/a/41559081
fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK);
- uci_state state = {0};
- strncpy(state.name, "Gacrux", 32);
- strncpy(state.author, "Aargh Rai <aarghrai.com>", 32);
+ com->state = (uci_state) {0};
+ strncpy(com->state.name, "Gacrux", 32);
+ strncpy(com->state.author, "Aargh Rai <aarghrai.com>", 32);
int k = 0;
- state.option_settings[k++] = option_setting_spin(
+ com->state.option_settings[k++] = option_setting_spin(
"Threads",
1, 5, 1,
- &state.threads
+ &com->state.threads
);
- state.option_settings[k++] = option_setting_spin(
+ com->state.option_settings[k++] = option_setting_spin(
"Hash",
0, 512, 256,
- &state.hash
+ &com->state.hash
);
- state.option_settings[k++] = option_setting_button(
+ com->state.option_settings[k++] = option_setting_button(
"Clear Hash",
- &state.clear_hash
+ &com->state.clear_hash
);
- state.option_settings[k++] = option_setting_check(
+ com->state.option_settings[k++] = option_setting_check(
"UCI_ShowCurrLine",
false,
- &state.uci_showcurrline
+ &com->state.uci_showcurrline
);
- state.option_settings[k++] = option_setting_check(
+ com->state.option_settings[k++] = option_setting_check(
"UCI_ShowRefutations",
false,
- &state.uci_showrefutations
+ &com->state.uci_showrefutations
);
- state.option_settings[k++] = option_setting_check(
+ com->state.option_settings[k++] = option_setting_check(
"UCI_LimitStrength",
false,
- &state.uci_limitstrength
+ &com->state.uci_limitstrength
);
- state.option_settings[k++] = option_setting_spin(
+ com->state.option_settings[k++] = option_setting_spin(
"UCI_Elo",
100, 3500, 800,
- &state.uci_elo
+ &com->state.uci_elo
);
- state.option_settings[k++] = option_setting_check(
+ com->state.option_settings[k++] = option_setting_check(
"UCI_AnalyseMode",
false,
- &state.uci_analysemode
+ &com->state.uci_analysemode
);
- state.option_settings[k++] = option_setting_string(
+ com->state.option_settings[k++] = option_setting_string(
"UCI_Opponent",
"<empty>",
- &state.uci_opponent
+ &com->state.uci_opponent
);
- state.option_settings[k++] = option_setting_string(
+ com->state.option_settings[k++] = option_setting_string(
"UCI_EngineAbout",
"Gacrux by Aargh Rai, Checkout https://git.aarghrai.com/gacrux",
- &state.uci_engineabout
+ &com->state.uci_engineabout
);
- state.option_settings[k++] = option_setting_string(
+ com->state.option_settings[k++] = option_setting_string(
"UCI_SetPositionValue",
"<empty>",
- &state.uci_setpositionvalue
+ &com->state.uci_setpositionvalue
);
ucicmd cmd = ucicmd_init();
@@ -110,7 +109,11 @@ int uci(comms *com) {
if (n > 0) {
load_from_message(&cmd, buf);
}
- handle_uci(&state, cmd);
+ handle_uci(
+ &com->state,
+ com->engine_messages,
+ cmd
+ );
}
}