6 # Written by Daniel Axtens <
[email protected]> for the UCC Programming Competition in 2010.
7 # Licensed under an MIT-style license: see the LICENSE file for details.
9 # a candidate for porting to python.
11 # put ourselves in SRCROOT - src/
12 # this assumes we are in the src/link directory.
17 This script takes the code that you have written for UCC::ProgComp 2010 and
18 bundles it up as an agent that you can test. This script is not needed for code
26 while ([ $lang != 1 ] && [ $lang != 2 ]) do {
29 Is your agent written in:
31 (2) another language (UNSUPPORTED)
34 read -p "Enter 1 or 2: " lang
39 if ([ $lang == 1 ]) then
41 echo "Preparing a C bot."
44 echo "Where is your .c file?"
45 echo "Provide the full path, including the agent file and the .c"
46 echo "Give paths relative to the src/ directory."
47 echo "WARNING: will overwrite \'agent name\'.py if it exists"
51 location=`dirname $path`
52 name=`basename $path .c`
54 cat > ${location}/${name}.py << __EOF__
55 # ${name}.py - a C bot shell generated by `basename $0` for UCC::ProgComp 2010
57 from link.cAgent import cAgent
59 class ${name} (cAgent):
61 cAgent.__init__(self, "${location}/${name}")
67 elif ([ $lang == 2 ]) then
69 echo "Preparing a custom bot."
72 echo "What is the name of your bot?"
77 echo "Enter the command required to spawn your bot."
78 echo "Give paths relative to the src/ directory."
80 read -p "Command: " cmd
83 echo "Into which directory should I put the resultant python module?"
84 echo "(again, give paths relative to src/)"
85 echo "WARNING: will overwrite ${name}.py if it exists"
87 read -p "Location: " location
89 cat > ${location}/${name}.py << __EOF__
90 # ${name}.py - a custom bot shell generated by `basename $0` for UCC::ProgComp 2010
91 # calls "${cmd}" to invoke the bot
93 from link.externAgent import externAgent
95 class ${name} (externAgent):
97 externAgent.__init__(self, "${cmd}")
105 echo "${name}.py created."
107 echo "Include your bot with:"
109 #there must be a nicer way to do this. possibly by using python
110 #part of the horror is trying to deal with location possibly having a trailing
111 #slash, and possibly not having one. *sigh*
112 pythonpath=`sed 's:/:.:g' << __EOF__
113 $(dirname ${location}/${name}).${name}
117 echo " from ${pythonpath} import ${name}"
118 echo "Then make sure the Agents list includes ${name}"