kreibaum / pacosako

This code drives the pacoplay.com website where you can play Paco Ŝako.
http://pacoplay.com
MIT License
23 stars 3 forks source link

Web AI should be able to submit multiple actions at once #123

Open kreibaum opened 5 months ago

kreibaum commented 5 months ago

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.

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.