Skip to content

Instantly share code, notes, and snippets.

@daveray
Created August 2, 2011 12:33
Show Gist options
  • Save daveray/1120095 to your computer and use it in GitHub Desktop.
Save daveray/1120095 to your computer and use it in GitHub Desktop.
Emulating CSoar's 'cmd' function in JSoar
# Emulating CSoar's cmd function in JSoar
# Install a fake "cmd" RHS function.
script javascript {
soar.rhsFunction({
name: "cmd",
execute: function(context, args) {
var cmd = "";
for(var i = 0; i < args.length; i++) {
cmd = cmd + args[i] + " ";
}
return soar.print(soar.agent.getInterpreter().eval(cmd));
}
});
}
# Test printing a state
sp {test
(state <s> ^superstate nil)
-->
(cmd |print --depth 2 | <s>)
}
# Test printing RL. Won't do anything unless RL is enabled, etc.
sp {test2
(state <s> ^superstate nil)
-->
(cmd |print --rl|)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment