Hello,
I would make sure I have the correct understanding of the ThreadedExecutor. I would have a small question concerning the GlobalDomain. In my case, the types GlobalState and State are both refering to the struct GameState. The Diff type refers to Option<GameState>.
Here are is my implementation of GlobalDomain for my struct GameDomain:
impl GlobalDomain for GameDomain {
type GlobalState = GameState;
fn derive_local_state(global_state: &Self::GlobalState, agent: AgentId) -> Self::State {
global_state.clone()
}
fn apply(global_state: &mut Self::GlobalState, local_state: &Self::State, diff: &Self::Diff) {
if let Some(diff_game_state) = diff {
*global_state = diff_game_state.clone();
}
}
Here would be some clues:
- I understood from the source code that when using the ThreadedExecutor, planning happens in parallel but modifications to the GlobalState happens sequentially.
- I understood that when it is time for an agent to plan, it is attributed a planning task which runs on another thread. The planning task has a pre-defined duration. At each step the exector looks at the terminated planning tasks and extract the best task from them. It insert them in the execution queue.
- The actual execution of the task happens only at the end of the task (tick it was inserted + duration of the task). Then, we try to execute the task if it is valid (as some other task might have invalidated it). The diff is modified and then is applied to the global state via the
apply function.
My first question would be to know if the above clues are correct and accurate. My second question would to know if given the clues (and if they are correct) that the implementation of the GlobalDomain is correct. In my case my Diff is an option of the main domain and thus I understood that if nothing changes (diff is None) then we shouldn't change the global domain. On the other hand, if something changed when executing the task, we can safely copy the diff into the global state (even if we actually copy a lots of untouched data).
Many thanks in advance for your help.
Best regards,
Quentin Guignard
Hello,
I would make sure I have the correct understanding of the ThreadedExecutor. I would have a small question concerning the GlobalDomain. In my case, the types
GlobalStateandStateare both refering to thestruct GameState. TheDifftype refers toOption<GameState>.Here are is my implementation of
GlobalDomainfor my structGameDomain:Here would be some clues:
applyfunction.My first question would be to know if the above clues are correct and accurate. My second question would to know if given the clues (and if they are correct) that the implementation of the GlobalDomain is correct. In my case my Diff is an option of the main domain and thus I understood that if nothing changes (diff is None) then we shouldn't change the global domain. On the other hand, if something changed when executing the task, we can safely copy the diff into the global state (even if we actually copy a lots of untouched data).
Many thanks in advance for your help.
Best regards,
Quentin Guignard