Created
August 2, 2011 12:33
-
-
Save daveray/1120095 to your computer and use it in GitHub Desktop.
Emulating CSoar's 'cmd' function in JSoar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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