npc_engine_utils/global_domain.rs
1/*
2 * SPDX-License-Identifier: Apache-2.0 OR MIT
3 * © 2020-2022 ETH Zurich and other contributors, see AUTHORS.txt for details
4 */
5
6use npc_engine_core::{AgentId, Domain};
7
8/// A domain that provides a global state, out of which a local state for the planning can be derived.
9pub trait GlobalDomain: Domain {
10 /// Global state: all data that can change in the course of the simulation.
11 type GlobalState: std::fmt::Debug + Sized + 'static;
12
13 /// Derives a new local state for the given agent from the given global state.
14 fn derive_local_state(global_state: &Self::GlobalState, agent: AgentId) -> Self::State;
15
16 /// Applies a diff from a local state to the global state.
17 fn apply(global_state: &mut Self::GlobalState, local_state: &Self::State, diff: &Self::Diff);
18}