Not my code, originally on http://attacklab.net/showdown/ then http://wayback.archive.org/web/20091217093631/http://attacklab.net/showdown/