Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Saturday, February 26, 2011

Icy Projectile Challenge Results

The Icy Projectile Challenge programming competition is finished!

Here you can see the complete tournament results
http://queue.acm.org/challenge/2011/tournament/tournament.html

You can click on each dot on the tournament tree to launch a Java applet to watch that particular match play out.

I made it to the "Elite Eight" ;-)

One advanced technique that I wish I had come up with was the ability to throw a snowball at a competitor from a crouched position.  Repeatedly doing that allowed people to keep their opponents immobilized (potentially forever, if the opponent was pinned down and couldn't be pushed away by the snowball impact force and the thrower wasn't immobilized himself.)

For posterity's sake, I've decided to share the development of my player here: https://github.com/jratke/ICPC
The majority of my player development took place in the file python_example/player.py  

I started out basing the code on the python hunter.py and gradually adding capabilities.  My final basic strategy, as you can probably tell from the matches, was to have three players go out and throw snowballs at the other team, while one player would plant snowmen at four points designed to have my snowman domain covering much of the field.  The "planter" player also tries to convert all of the other team's snowmen to my team if he sees any as he goes on his way to the next point.  Once he successfully completes the fourth snowman, he can keep going around the points to try and convert more snowmen, or (if I haven't seen any snowmen of the opposite team at all) he can join in and throw snowballs like the other three.

Congratulations to Kamran for winning and congratulations to the other finalists.  And thanks again to the organizers.

Tuesday, February 8, 2011

Icy Projectile Challenge

Queue magazine, the magazine of The Association for Computing Machinery (ACM), is holding a programming competition called The Icy Projectile Challenge.  The competition is based on the Challenge problem from ACM's 2010 International Collegiate Programming Competition. The contest is to write a program to control a team of virtual children in a snowball fight.  One nice thing about it is that you can write your program in C++, C#, Java, or Python.

I've entered the contest, and I'm writing my program in Python.  So far it is over 1000 lines.

You can see the preliminary standings here.

I wish I would have entered sooner!  I hope there is enough time for me to improve my player even more. I'm looking forward to the final tournament!!  Their web site says that the challenge is run by David Sturgill at the University of North Carolina at Greensboro with help from Matt Slaybaugh at ACM.  So thanks to them for putting this on.  It's a great idea, great fun, and I hope they do something like it next year as well!

Thursday, December 16, 2010

Learning Python

One thing I'm working on right now is learning Python.

Why Python?  Well, a few reasons, really.  It is a "clear and powerful object-oriented programming language". Also from the Python page, "Data types are strongly and dynamically typed. Mixing incompatible types (e.g. attempting to add a string and a number) causes an exception to be raised, so errors are caught sooner."

It can be used for all sorts of things like web development, database access, graphics, game development, or even to control two huge robot grappling arms.  I plan to use it to interface with twitter, for one thing.

I had done a bit of Ruby programming a while back, and there's nothing wrong with it, but I think I prefer the overall Python philosophy.   For a good comparison of Python and Ruby, see Gary Bernhardt's presentation: Python vs. Ruby: A Battle to The Death.  One thing Gary laments though, is the difference in the testing community/philosophy, where he notes that the Ruby testing community is more developed, or advanced, shall we say.  Ruby's extreme flexibility allows for it to be easily used for some pretty innovative testing approaches.   But I'm okay with these differences, for now at least.

There are many ways to learn Python, but I'm doing it mostly by using Greg Malcolm's Python Koans.  The idea is to learn the language by getting a series of failing test cases to pass by filling in the missing details in the test assertions. It is essentially using Test Driven Development to learn a programming language, which is a pretty great idea.  Instead of just randomly playing around, the Koans provide you with a guided series of steps needed to learn.  You know exactly how many tests you have fixed, and how many you have remaining to be fixed.  It's great to see the progress you make as you fix the test cases and learn more things as a side effect.  And the tests don't limit you because you can easily add more tests to play around and explore any area you like.

By the way, this is a pretty cool visualization of the commit history of the Python project.  It kind of shows how software is like a living, growing thing.

So, anyway, I'll let you know once I'm finished with the Koans, and if/when I create anything cool using Python.