pacosako
pacosako copied to clipboard
Web AI should be able to submit multiple actions at once
This is relevant when pulling actions out of the opening book. We currently submit moves one by one:
// TODO: Submit all actions at once, no need to stagger them.
// Requires changes on Elm side and maybe also in the protocol over websocket.
for action in &best_move.actions {
let action = serde_json::to_string(&vec![*action]).map_err(|e| e.to_string())?;
forwardToMq("aiMoveDetermined", &action);
}
The Elm limitation is:
-- TODO: This can't deal with two actions comming in at once!
AiMoveResponse actions ->
let
action =
List.head actions |> Maybe.withDefault (Sako.Promote Sako.Queen)
in
updateActionInputStep shared action model
And the underlying issue is, that every move needs to be send to the server over websocket.
- The websocket only accepts moves one at a time.
- Elm does not guarantee order of
Cmd
execution.
This means we need to rely on "one by one" for now.
This isn't bad in practice, but it would be nice to clean this up.