Fixes
This commit is contained in:
@@ -80,7 +80,6 @@ pub struct RhaiAgent<R: Rng + 'static> {
|
||||
|
||||
engine: Engine,
|
||||
script: AST,
|
||||
scope: Scope<'static>,
|
||||
print_callback: Arc<dyn Fn(&str) + 'static>,
|
||||
}
|
||||
|
||||
@@ -118,7 +117,6 @@ impl<R: Rng + 'static> RhaiAgent<R> {
|
||||
|
||||
// Do not use FULL, rand_* functions are not pure
|
||||
engine.set_optimization_level(OptimizationLevel::Simple);
|
||||
|
||||
engine.disable_symbol("eval");
|
||||
engine.set_max_expr_depths(100, 100);
|
||||
engine.set_max_strings_interned(1024);
|
||||
@@ -201,13 +199,11 @@ impl<R: Rng + 'static> RhaiAgent<R> {
|
||||
};
|
||||
|
||||
let script = engine.compile(script)?;
|
||||
let scope = Scope::new(); // Not used
|
||||
|
||||
Ok(Self {
|
||||
rng,
|
||||
engine,
|
||||
script,
|
||||
scope,
|
||||
print_callback,
|
||||
})
|
||||
}
|
||||
@@ -227,7 +223,7 @@ impl<R: Rng + 'static> Agent for RhaiAgent<R> {
|
||||
fn step_min(&mut self, board: &Board) -> Result<PlayerAction, Self::ErrorType> {
|
||||
let res = self.engine.call_fn_with_options::<PlayerAction>(
|
||||
CallFnOptions::new().eval_ast(false),
|
||||
&mut self.scope,
|
||||
&mut Scope::new(),
|
||||
&self.script,
|
||||
"step_min",
|
||||
(board.clone(),),
|
||||
@@ -242,7 +238,7 @@ impl<R: Rng + 'static> Agent for RhaiAgent<R> {
|
||||
fn step_max(&mut self, board: &Board) -> Result<PlayerAction, Self::ErrorType> {
|
||||
let res = self.engine.call_fn_with_options::<PlayerAction>(
|
||||
CallFnOptions::new().eval_ast(false),
|
||||
&mut self.scope,
|
||||
&mut Scope::new(),
|
||||
&self.script,
|
||||
"step_max",
|
||||
(board.clone(),),
|
||||
|
||||
Reference in New Issue
Block a user