|
Page 3 of 4 This tutorial will assume that you want to create an agent named <myNewAgent>. In reality, you probably want a different name, so just substitute your name wherever you see <myNewAgent>. Create the files Create a new agent by copying the existing random Python agent:
$>cd agents
#Now, make a copy of this agent $>cp -R randomAgentPython <myNewAgent> Change the appropriate file names$>cd <myNewAgent> $>cd src
#Now, rename the source java file $>cd <myNewAgent> $>mv RandomAgent.py <myNewAgent>.py
Edit the source file$>emacs <myNewAgent>.py #Use your favorite editor
Now, you can either find-and-replace RandomAgent with <myNewAgent> or make the change mentioned below:
Look for the class declaration: class RandomAgent(Agent):
Change it to: class <myNewAgent>(Agent):
Save the file.
Edit the MakefileGo back up to the main directory for your new agent: $>cd ../../
Edit the run.bash script with your favorite editor: $>emacs run.bash
The only line is: PYTHONPATH=../../system/RL-Glue/RL-Glue/Python:./src python -c "import rlglue.agent.AgentLoader" RandomAgent
Change this to: PYTHONPATH=../../system/RL-Glue/RL-Glue/Python:./src python -c "import rlglue.agent.AgentLoader" <myNewAgent>
Save the file.
Note: If you wanted to move your agent folder to a new location, even outside of the rl-competition distribution, all you need to do is update one line of the run.bash script. Find the section: PYTHONPATH=../../system/RL-Glue/RL-Glue/Python:./src python
Change this to: PYTHONPATH=<path_to_rl-competition_directory>/system/RL-Glue/RL-Glue/Python:./src python Save this file. Try it outIn one terminal window, go run the graphical Java trainer: $>cd trainers/guiTrainerJava $>bash run.bash
In another terminal window, run your new agent: $>cd agents/<myNewAgent> $>bash run.bash
With any luck at all, you should be able to load and start an experiment and your agent will be running! Congratulations!
|