From 48332dd39b0e95a40c4c2504f90898d42264a53e Mon Sep 17 00:00:00 2001 From: Daniel Axtens Date: Fri, 10 Sep 2010 11:59:04 +0800 Subject: [PATCH] More documentation; an agents directory for people to write there agents in, and an associated arena --- WELCOME.txt | 3 +++ src/README.txt | 4 +++- src/USINGPYTHON.txt | 42 ++++++++++++++++++++++++++++++++++++++++++ src/agents/__init__.py | 0 src/arenas/MyAgent.py | 17 +++++++++++++++++ 5 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 WELCOME.txt create mode 100644 src/USINGPYTHON.txt create mode 100644 src/agents/__init__.py create mode 100755 src/arenas/MyAgent.py diff --git a/WELCOME.txt b/WELCOME.txt new file mode 100644 index 0000000..f4a663e --- /dev/null +++ b/WELCOME.txt @@ -0,0 +1,3 @@ +Welcome! You've found the UCC::ProgComp 2010 kit. + +The full documentation is in the "doc" directory. Alternatively, if you want to dive straight into the code, see the "src" directory. \ No newline at end of file diff --git a/src/README.txt b/src/README.txt index 2dae87d..d59716c 100644 --- a/src/README.txt +++ b/src/README.txt @@ -11,7 +11,9 @@ The first thing you'll probably want to do is see it work. Try running: to see the sample agents duke it out. This is a brief overview of the included files and directories: - - SampleAgents.py : the sample agents. This is the bit you care about! + - USINGPYTHON.txt: A guide to writing an agent in Python. + - SampleAgents.py : the sample agents. + - agents/ : where you put your agent. - arenas/ : arenas define which agents play against which, and some other parameters. - link/ : Other languages belong here. - conf.py : has various useful things like the ability to turn on debug support. diff --git a/src/USINGPYTHON.txt b/src/USINGPYTHON.txt new file mode 100644 index 0000000..b11a686 --- /dev/null +++ b/src/USINGPYTHON.txt @@ -0,0 +1,42 @@ +USINGPYTHON.txt: A 10 step guide to writing an agent in Python. + +1. Pick a name for your agent. Make sure the name is a valid python identifier. Be original. + +2. Open SampleAgents.py. Pick a sample agent to copy-paste (so you don't have to type out the function definitions). + +3. Copy the sample agent code into a new file in the "agents" directory. Make sure the file has the same name as the agent. + +4. Modify the code to do your bidding. + +4a. If you wish to implement your own leaning agent based on BaseAgent, rather than use the limited functionality of LearningAgent, insert the following code snippet inside your class: + + def Results (self, foeName, wasAttacker, winner, attItem, defItem, bluffItem, pointDelta): + BaseAgent.Results (self, foeName, wasAttacker, winner, attItem, defItem, bluffItem, pointDelta) + # your own code goes here + + +5. Create an arena in which your agent can battle: + + 5.1. open arenas/MyArena.py + + 5.2. add "from agents. import " + + 5.3. modify the "Agents =" line to include your agent, and take out any agents you don't want to battle. + +6. Watch your agent in action: ./simulate -v -a MyArena + +7. Oh no, my agent dies very quickly: what's going on? + + 7.1 insert print statements in your python module. (Hint: prefix them with self.id so you can identify different agents) + + 7.2 Run "./simulate -v -n 1 -a MyArena" to start with only 1 of each agent. + + 7.3 Change the agents against which you're battling in MyArena.py so that you have a predictable opponent. + + 7.1 Edit conf.py, and set DEBUG=True. Don't forget to reset it when you're done. + +8. Once your agent works to your satisfaction, try it both on short and long durations (100 and 1000 rounds: see MAX_ITERATIONS in conf.py) + +9. If the rolling scoreboard has been opened on progcomp.ucc.asn.au/, submit it there! Otherwise, sit tight. + +10. Watch its progress on the scoreboard and adjust your strategy accordingly. \ No newline at end of file diff --git a/src/agents/__init__.py b/src/agents/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/arenas/MyAgent.py b/src/arenas/MyAgent.py new file mode 100755 index 0000000..9fe285d --- /dev/null +++ b/src/arenas/MyAgent.py @@ -0,0 +1,17 @@ +#!/usr/bin/python2.5 +'''PythonSampleAgents.py +An arena that runs the sample bots in python. +Written by Daniel Axtens for the UCC Programming Competition in 2010. + +Licensed under an MIT-style license: see the LICENSE file for details. +''' + +from SampleAgents import Angel, Lucifer, Dummy, Wash, Streetfighter + +# Import your agent here: +# e.g. from agents. import + +class arena: + # Add you agent here: + # e.g. Agents=[