From 965bf81879b22a25fd9b0d17ce6defd3d51c6173 Mon Sep 17 00:00:00 2001 From: Aargh Rai Date: Tue, 7 Jul 2026 14:30:21 +0530 Subject: engine can now send updates to uci --- src/uci.c | 61 ++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 29 deletions(-) (limited to 'src/uci.c') 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 ", 32); + com->state = (uci_state) {0}; + strncpy(com->state.name, "Gacrux", 32); + strncpy(com->state.author, "Aargh Rai ", 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", "", - &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", "", - &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 + ); } } -- cgit v1.2.3