So Greed is a topcoder Arena plugin that is very customizable (And I mean, very customizable).
When I started using these plugins I took advantage of its github to provide patches and suggestions. This helped shivawu implement some wonderful features that will make Greed 2.0 a plugin with unprecedented power (I think).
Custom templates
In the current stable version, there are 3 templates: source, tester and unit tests (optional for Java and C#). The 2-3 templates are used by Greed to generate the source and unit test files. The templates use a language of their own that is very powerful. So powerful that implementing python support almost didn't need much modification to the plugin itself, just the creation of templates for python and an update to make the plugin use them.
Why stop there, though? The new idea is that you can, define custom templates. Any template for any kind of file in addition to the source and test ones. The plugin will use its configuration to read a template and put the generated contents in some location that depends on contest name and problem name. Why is this important? Well, it adds plenty of options that weren't there before. After some tweaking I was able to customize greed to generate ACM-style input and output files and a source code file that takes input and generates output ACM style.
This is the input file generated for FoxAndGo3:
6 3 o.o .o. o.o 3 ... .o. ... 5 xxxxx xxoxx xo.ox xxoxx xxxxx 5 .xox. .o.ox x.o.o ox.ox .ox.. 5 o.o.o .ox.. oxxxo ..x.. o.o.o 3 ... ... ...
But I really didn't want these input/output files, I like my meta testers just fine. However, this feature is also helpful for other things. How about automatically creating a project XML file for your favorite IDE's ? Or a build file for whatever build system you have? Separating tester and source code. Whatever you need you can now do it.
Problem statement HTML
The first good use for the custom templates is that, just by adding some info from the problem statement to the template engine. The plugin can now generate problem statement HTML files from a template. Because it is a template, there is plenty of flexibility in regards to the format of the problem statement. The default looks like this:
There are plenty of uses for saving the problem statements in files. If the internet goes down during the contest, you can pretty much still work in the problem - You can read the problem and the source code is in an external file.
After generation hooks
My favorite new feature is, however, the "After Gen Hook" as it makes everything work great now. You can tweak configuration so, whenever Greed finishes generating a file from a specific template, it runs a custom command. Whatever command you need.
In my case, I tweaked Greed to make it automatically open source code files in jEdit, and opens the problem statement in Firefox. Manually opening the generated source code files in jEdit was an annoying bottleneck.
How to get the features
They are currently in a test branch and are still in development. But if you want to give them a try, just get the contents of the tmpl-seq branch from their github. The command to build a jar file from the new sourcecode is ./gradlew fatjar.
The new configuration options are not documented, so you will need to take a look to at the default.conf file in the source/main/resources folder and do some reverse engineering.
5 comments :
It would be really nice if the HTML problem statement supports images just as well as the arena does; because I have seen messages that say that the images may not be viewed properly outside the arena.
I have one more request. If possible, can you make the tester check the memory limit as well? It is not really important but it would be nice :)
Thanks a lot for your work on Greed, I wish I could help but I am new to programming.
I am currently using "Vexorian's c++ tester template for greed. Version 0.1".
I really like the new test case format and want to start using it. Since I don't really mind about the length of the problem-specific code, can you please merge testtemplate.cpp and tester.cpp into a single tester file? It will be really convenient for me.
Thanks a lot!
PS: I am using Greed 1.5.
The statement supports images, but it doesn't save them in disk (yet?).
At least in *n*x*'s case, the memory limit can/should be enforced from the OS.
My run script calls
ulimit -v 65536
Before running my program.
You can do it yourself.
Edit the template file from this blog post, replace:
#include "../tester.cpp"
With the contents of tester.cpp.
One more question, how exactly do I modify the file to make it work in Greed 1.5? It shows some error as of now.
This is my current tester file (http://pastebin.com/wkjAy24m) and I am able to successfully Reload configuration but when I click Regenerate code, I get the following error:
- Oops, something wrong! It says "Error while parsing 'p.Index' at location (345:48): Property 'Index' on object 'greed.model.Param@580a298b' can not be accessed: "java.lang.NoSuchFieldException: Index"!"
- Please see the logs for details.
Thanks for taking your time to build this plugin :)
Post a Comment