pub trait Environment: Send + Sync {
// Required methods
fn step(&self, worker_id: WorkerId, action: &Action) -> WorkResult;
fn reset(&self);
fn name(&self) -> &str;
}Expand description
Required Methods§
Sourcefn step(&self, worker_id: WorkerId, action: &Action) -> WorkResult
fn step(&self, worker_id: WorkerId, action: &Action) -> WorkResult
アクション実行
すべてのアクション(移動、観察、待機等)をこのメソッドで処理する。
§Arguments
worker_id- 実行する Worker の IDaction- 実行するアクション
§Returns
WorkResult - 実行結果を直接返す
WorkResult::Acted- 通常のアクション結果WorkResult::Done- タスク完了WorkResult::env_success()/WorkResult::env_failure()等のヘルパーを使用
§Example
ⓘ
// 移動アクション
let action = Action::new("Move").with_arg("target", "north");
let result = env.step(worker_id, &action);
// 観察アクション
let action = Action::new("Look");
let result = env.step(worker_id, &action);
// ActionResult.output に JSON データ