# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # $Revision: 617 $ # $Date: 2009-02-05 04:24:12 -0500 (Thu, 05 Feb 2009) $ # $Author: gabalz $ # $HeadURL: http://rl-glue-ext.googlecode.com/svn/trunk/projects/codecs/Python/src/tests/test_sanity_experiment.py $ import sys import rlglue.RLGlue as RLGlue from glue_test import glue_test tester = glue_test("test_sanity") taskSpec = RLGlue.RL_init() tester.check_fail(taskSpec != "sample task spec") print tester.get_summary() sys.exit(tester.getFailCount())
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # $Revision$ # $Date$ # $Author$ # $HeadURL$ import sys import rlglue.RLGlue as RLGlue from glue_test import glue_test tester = glue_test("test_rl_episode") task_spec = RLGlue.RL_init() isTerminal = RLGlue.RL_episode(0) tester.check_fail(isTerminal != 1) tester.check_fail(RLGlue.RL_num_steps() != 5) isTerminal = RLGlue.RL_episode(1) tester.check_fail(isTerminal != 0) tester.check_fail(RLGlue.RL_num_steps() != 1) isTerminal = RLGlue.RL_episode(2) tester.check_fail(isTerminal != 0) tester.check_fail(RLGlue.RL_num_steps() != 2)
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # $Revision$ # $Date$ # $Author$ # $HeadURL$ import sys import rlglue.RLGlue as RLGlue from glue_test import glue_test tester = glue_test("test_message") task_spec = RLGlue.RL_init() tester.check_fail("empty" != RLGlue.RL_env_message(None)) tester.check_fail("empty" != RLGlue.RL_env_message("")) tester.check_fail("empty" != RLGlue.RL_agent_message(None)) tester.check_fail("empty" != RLGlue.RL_agent_message("")) tester.check_fail("" != RLGlue.RL_env_message("empty")) tester.check_fail("" != RLGlue.RL_agent_message("empty"))
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # $Revision: 617 $ # $Date: 2009-02-05 10:24:12 +0100 (Thu, 05 Feb 2009) $ # $Author: gabalz $ # $HeadURL: http://rl-glue-ext.googlecode.com/svn/trunk/projects/codecs/Python/src/tests/test_1_experiment.py $ import sys import rlglue.RLGlue as RLGlue from glue_test import glue_test tester=glue_test("test_1") task_spec=RLGlue.RL_init(); RLGlue.RL_start(); roat=RLGlue.RL_step(); tester.check_fail(b"one|1.|one"!=RLGlue.RL_env_message("one")); tester.check_fail(b"one|1.|one"!=RLGlue.RL_agent_message("one")); tester.check_fail(roat.terminal!=0); tester.check_fail(roat.r!=1.0); tester.check_fail(len(roat.o.intArray)!=1); tester.check_fail(len(roat.o. doubleArray)!=0); tester.check_fail(len(roat.o. charArray)!=0); tester.check_fail(roat.o.intArray[0]!=0);
#http://rl-glue-ext.googlecode.com/ # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # $Revision: 617 $ # $Date: 2009-02-05 11:24:12 +0200 (Thu, 05 Feb 2009) $ # $Author: gabalz $ # $HeadURL: http://rl-glue-ext.googlecode.com/svn/trunk/projects/codecs/Python/src/tests/test_sanity_experiment.py $ import sys import rlglue.RLGlue as RLGlue from glue_test import glue_test tester = glue_test("test_sanity") taskSpec = RLGlue.RL_init() tester.check_fail(taskSpec != "sample task spec") print tester.get_summary() sys.exit(tester.getFailCount())
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # $Revision: 617 $ # $Date: 2009-02-05 11:24:12 +0200 (Thu, 05 Feb 2009) $ # $Author: gabalz $ # $HeadURL: http://rl-glue-ext.googlecode.com/svn/trunk/projects/codecs/Python/src/tests/test_empty_experiment.py $ import sys import rlglue.RLGlue as RLGlue from glue_test import glue_test tester = glue_test("test_empty") task_spec = RLGlue.RL_init() for whichEpisode in range(1, 5): startTuple = RLGlue.RL_start() if (whichEpisode % 2 == 0): tester.check_fail(len(startTuple.a.intArray) != 0) tester.check_fail(len(startTuple.a.doubleArray) != 0) tester.check_fail(len(startTuple.a.charArray) != 0) tester.check_fail(len(startTuple.o.intArray) != 0) tester.check_fail(len(startTuple.o.doubleArray) != 0) tester.check_fail(len(startTuple.o.charArray) != 0) else:
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # $Revision: 617 $ # $Date: 2009-02-05 11:24:12 +0200 (Thu, 05 Feb 2009) $ # $Author: gabalz $ # $HeadURL: http://rl-glue-ext.googlecode.com/svn/trunk/projects/codecs/Python/src/tests/test_1_experiment.py $ import sys import rlglue.RLGlue as RLGlue from glue_test import glue_test tester = glue_test("test_1") task_spec = RLGlue.RL_init() RLGlue.RL_start() roat = RLGlue.RL_step() tester.check_fail("one|1.|one" != RLGlue.RL_env_message("one")) tester.check_fail("one|1.|one" != RLGlue.RL_agent_message("one")) tester.check_fail(roat.terminal != 0) tester.check_fail(roat.r != 1.0) tester.check_fail(len(roat.o.intArray) != 1) tester.check_fail(len(roat.o.doubleArray) != 0) tester.check_fail(len(roat.o.charArray) != 0) tester.check_fail(roat.o.intArray[0] != 0)
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # $Revision$ # $Date$ # $Author$ # $HeadURL$ import sys import rlglue.RLGlue as RLGlue from glue_test import glue_test tester =glue_test("test_empty") task_spec=RLGlue.RL_init() for whichEpisode in range(1, 5): startTuple=RLGlue.RL_start() if(whichEpisode%2==0): tester.check_fail(len(startTuple.a.intArray)!=0) tester.check_fail(len(startTuple.a.doubleArray)!=0) tester.check_fail(len(startTuple.a.charArray)!=0) tester.check_fail(len(startTuple.o.intArray)!=0) tester.check_fail(len(startTuple.o.doubleArray)!=0)
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # $Revision: 617 $ # $Date: 2009-02-05 02:24:12 -0700 (Thu, 05 Feb 2009) $ # $Author: gabalz $ # $HeadURL: http://rl-glue-ext.googlecode.com/svn/trunk/projects/codecs/Python/src/tests/test_message_experiment.py $ import sys import rlglue.RLGlue as RLGlue from glue_test import glue_test tester =glue_test("test_message") task_spec=RLGlue.RL_init() tester.check_fail("empty"!=RLGlue.RL_env_message(None)); tester.check_fail("empty"!=RLGlue.RL_env_message("")); tester.check_fail("empty"!=RLGlue.RL_agent_message(None)); tester.check_fail("empty"!=RLGlue.RL_agent_message("")); tester.check_fail(""!=RLGlue.RL_env_message("empty")); tester.check_fail(""!=RLGlue.RL_agent_message("empty"));
# See the License for the specific language governing permissions and # limitations under the License. # # Last modifed 22-1-2009 by Jose Antonio Martin H. # Improving the test processTaskSpec # $Revision: 617 $ # $Date: 2009-02-05 04:24:12 -0500 (Thu, 05 Feb 2009) $ # $Author: gabalz $ # $HeadURL: http://rl-glue-ext.googlecode.com/svn/trunk/projects/codecs/Python/src/tests/test_taskspec.py $ import sys from rlglue.utils import TaskSpecVRLGLUE3 from glue_test import glue_test tester = glue_test("test_taskspec") def processTaskSpec(ts): # you can cut the taskspec by the main words with new line # ts= """VERSION RL-Glue-3.0 PROBLEMTYPE episodic DISCOUNTFACTOR 1 OBSERVATIONS INTS (3 0 1) DOUBLES (2 -1.2 0.5) (-.07 .07) CHARCOUNT 1024 # ACTIONS INTS (2 0 4) CHARCOUNT 1024 REWARDS (-5.0 UNSPEC) EXTRA some other stuff goes here""" print print print "=======================================================================================================" print ts print print TaskSpec = TaskSpecVRLGLUE3.TaskSpecParser(ts) if TaskSpec.valid: print "======================================================================================================="
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # $Revision$ # $Date$ # $Author$ # $HeadURL$ import sys import rlglue.RLGlue as RLGlue from glue_test import glue_test tester =glue_test("test_rl_episode") task_spec=RLGlue.RL_init() isTerminal = RLGlue.RL_episode(0); tester.check_fail(isTerminal!=1); tester.check_fail(RLGlue.RL_num_steps()!=5); isTerminal = RLGlue.RL_episode(1); tester.check_fail(isTerminal!=0); tester.check_fail(RLGlue.RL_num_steps()!=1); isTerminal = RLGlue.RL_episode(2); tester.check_fail(isTerminal!=0); tester.check_fail(RLGlue.RL_num_steps()!=2);
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Last modifed 22-1-2009 by Jose Antonio Martin H. # Improving the test processTaskSpec # $Revision: 617 $ # $Date: 2009-02-05 10:24:12 +0100 (Thu, 05 Feb 2009) $ # $Author: gabalz $ # $HeadURL: http://rl-glue-ext.googlecode.com/svn/trunk/projects/codecs/Python/src/tests/test_taskspec.py $ import sys from rlglue.utils import TaskSpecVRLGLUE3 from glue_test import glue_test tester = glue_test("test_taskspec") def processTaskSpec(ts): # you can cut the taskspec by the main words with new line #ts= """VERSION RL-Glue-3.0 PROBLEMTYPE episodic DISCOUNTFACTOR 1 OBSERVATIONS INTS (3 0 1) DOUBLES (2 -1.2 0.5) (-.07 .07) CHARCOUNT 1024 # ACTIONS INTS (2 0 4) CHARCOUNT 1024 REWARDS (-5.0 UNSPEC) EXTRA some other stuff goes here""" print() print() print( "=======================================================================================================" ) print(ts) print() print() TaskSpec = TaskSpecVRLGLUE3.TaskSpecParser(ts)