Hugi Coding Compo: Retrospective

Written by Adok

Introduction

The Hugi Size Coding Competition Series, short Hugi Coding Compo or just Hugi Compo, was held 29 times in the years 1998 and 2009. It was an international programming contest which focused on size optimizing in the Assembly language, with MS-DOS as the primary target platform. Talented coders from all over the world participated in it. The number of participants in individual competitions varied from just a handful to over eighty. I was the main organizer of most of these compos, with a few compos being organized by Ben Lunt (Sniper), and I will tell you a bit more about the history of the Hugi Compo in this article.

The Beginning

The first Hugi Compo started in April 1998, and the submission deadline was in June 1998. My primary inspiration was a similar contest hosted by the diskmag Pain, organized by Dake of Calodox. I had participated in that contest myself and even won first place, shared with Shabby, a coder from the UK. I had enjoyed it so much that I decided to spend some time working on a similar task just for fun. This task was a sort of snake game, in which you start with a tiny snake sized one pixel at the center of the screen, and in each moment the snake would grow by one more pixel. With the cursor keys it was possible to control the direction into which the snake grew, and the objective of the game was to grow as long as possible without biting oneself into one's tail. I implemented this game in Assembler and tried to reduce its size. Within a couple of hours, I had an executable of about 83 bytes. Now I was wondering how small this could eventually get. Then I had the idea that this could be given as a compo assignment - let coders from all around the world work on it instead of me alone. This was how the Hugi Compo was born.

After writing up an info file and creating a little webpage, I announced the competition on IRC and at various newsgroups, both demoscene related and general Assembler related ones. I was hardly known in the demoscene back then, it was the time when I was just beginning to make Hugi an international magazine, and so I feared that I would not attract many people to the competition. I thought that except a few German speaking guys I was in contact with, nobody would participate. But I was wrong. I soon received compo entries from all around the world, and at the end of the deadline, more than eighty persons had submitted entries. I was far more successful than I had anticipated.

The first entries were far larger than my own solution, but this changed within a couple of days and soon there were entries smaller than my own one. Since I allowed everybody to submit a new entry as often as they wanted, I was able to observe how people gradually managed to get their solutions smaller and smaller. In the end, Altair from Finland won the compo, with an entry sized only 48 bytes! The second best entry was three bytes larger. With my original entry of 83 bytes, I would have got only 57th place.

After the compo was over, I released all the entries. Then it turned out that some entries were not exactly following the rules: in some entries, the snake was starting at the wrong position, and other entries did not return to text mode. This led to a discussion what to do with those entries. In the end it was decided to disqualify them. In case a person who had submitted a disqualified entries had submitted several entries, I checked the older entries of this person, and if one of them matched the rules, this entry was accepted instead. Rule breaks became a common problem in further editions of the compo; we (the competitors and me) soon agreed on the following procedure: After the official deadline, I would release all the entries. But the compo would not end yet. First there would be a week of "public judgement", in which everybody would be able to thoroughly test all the entries and post objections to them to the compo mailinglist hosted by Yahoogroups. These objections would then be discussed by everybody subscribed to the mailinglist, and if a consent was found, the entry would either be accepted, disqualified or get a penalty.

So everything was done in a very democratic manner. Penalty meant that a couple of bytes were added to the size of the

entry, so that the entry would not be listed in the results table at the position that matched its actual size but at a slightly lower position. We found this to be a fair procedure and in most cases, we made use of penalities instead of completely disqualifying entries.

How it developed

In compo #2, the idea that became the task of the compo was proposed by Nop, a participant from Germany. He also developed an example program that demonstrated the intended behaviour of the program. These example programs were usually written in some higher level language, such as C, so that it would not be possible to create a compo entry by simply copying the code. It became common that various participants proposed task ideas, and sometimes the task that was actually used was chosen by popular vote.

Many participants took part in more than just one compo, and for this reason I came up with the idea of making a "world league table" in which the scores obtained in several editions of the compo would be added together. Each edition of the world league table would cover a period of a year.

Some of the people who proved to be very successful at several editions of the Hugi Compo were INT-E, Picard, st0ne, Ruud van Gessel, Guillermo Sais, Lawrence E. Boothby, Boreal, Alexione, Sergo Polsky, G3, Digimind, GreenGhost, MetalBrain, Jibz, Chut, Bonz, Jeff, TAD and Boiled Brain. Also Chris Dragan, who developed the new engine of the Hugi Magazine ever used since issue 18, was a regular participant in Hugi Compos.

Here is a list of all 29 compos, with tasks, who had the idea, and the top three participants.


Hugi Compo #1 (1998)
The "Nibbles" Compo

Idea by Adok, Hosted by Adok
1. Altair / ODDS, Finland (48)
2. Maxx, Sweden (51)
2. Mode 19 (group), Singapore (51)


Hugi Compo #2 (1998)
The "Text Compression" Compo

Idea by Nop, Hosted by Adok
1. Picard / Hydrogen, Hungary (501)
2. Petschy and TomCat / Abaddon, Hungary (521)
3. INT-E, Germany (535)


Hugi Compo #3 (1998)
The "Pong" Compo

Idea by Kombat, Hosted by Adok
1. Guillermo Sais, Mexico (142)
2. Bubulle - Krick - Stone, France, Sweden (145)
3. Maxx, Sweden (147)
3. INT-E, Germany (147)



Hugi Compo #4 (1998)
The "Expression Evaluator" Compo

Idea by IOPL, Hosted by Adok
1. stone, France (117)
1. INT-E, Germany (117)
3. Carsten and Klaus, Germany (121)


Hugi Compo #5 (1998)
The "SORT" Compo

Idea by IOPL, Hosted by Adok
1. Picard / Rhyme, Hungary (46)
2. INT-E, Germany (47)
2. Blue, Germany (47)
2. Stefan, Germany (47)


Hugi Compo #6 (1999)
The "Brainf*** Interpreter" Compo

Idea by Stefan, Hosted by Adok
1. INT-E, Germany (98)
2. TAD, United Kingdom (100)
3. Ruud v. Gessel, The Netherlands (102)



Hugi Compo #7 (1999)
The "Image Compression" Compo

Idea by unknown, Hosted by Adok
1. st0ne, France (6207)
2. Chut, Hungary (6390)
3. INT-E, Germany (6556)


Hugi Compo #8 (1999)
The "Morse" Compo

Idea by unknown, Hosted by Adok
1. Lawrence E. Boothby, United States (173)
2. Vlado Nikoforov, Bulgaria (175)
2. Ruud v. Gessel, The Netherlands (175)


Hugi Compo #9 (1999)
The "SPEW Emulator" Compo

Idea by TAD, Hosted by Adok
1. Ruud v. Gessel, The Netherlands (179)
2. claw, Germany (192)
3. Fabled and Buddha / LtE, Finland (195)



Hugi Compo #10 (2000)
The "Taquin" Compo

Idea by TAD, Hosted by Adok
1. INT-E, Germany (273)
1. Ruud, The Netherlands (273)
3. claw, Germany (281)


Hugi Compo #11 (2000)
The "Maze Pathfinder" Compo

Idea by unknown, Hosted by Adok
1. Eldar, Estonia (83)
2. Lawrence E. Boothby, United States (85)
3. Fred, France (88)


Hugi Compo #12 (2000)
The "Prime Finder" Compo

Idea by unknown, Hosted by Adok
1. Picard, Hungary (76)
2. INT-E, Germany (78)
3. Guillermo Sais, Mexico (80)



Hugi Compo #13 (2000)
The "Soko Ban" Compo

Idea by unknown, Hosted by Adok
1. Guillermo Sais, Mexico (189)
2. Boreal, United States (198)
3. Kees Willem van der Meer, Netherlands (215)


Hugi Compo #14 (2001)
The "SPEW Assembler" Compo

Idea by unknown, Hosted by Adok
1. Boreal, United States (298)
2. Jeff, United States (300)
3. Kees Willem van der Meer, Netherlands (301)


Hugi Compo #15 (2001)
The "Image Manipulation" Compo

Idea by TAD, Hosted by Adok
1. Alexione, Yugoslavia (126)
2. claw, Germany (128)
3. Bonz, Italy (136)
3. Jeff, United States (136)



Hugi Compo #16 (2002)
The "Hexagon" Compo

Idea by TAD, Hosted by Adok
1. Ruud, Netherlands (151)
2. Alexione, Yugoslavia (159)
3. gbm, Poland (163)


Hugi Compo #17 (2002)
The "Dump" Compo

Idea by Sniper, Hosted by Adok
1. Ruud, Netherlands (96)
2. Boiled Brain, Belarus (102)
3. Aphex, Romania (105)


Hugi Compo #18 (2002)
The "Roman-Decimal Converter" Compo

Idea by Vinicius Fortuna, Hosted by Adok
1. TFx, Italy (99)
2. Ruud, Netherlands (102)
3. Sergo Polsky, Russia (106)



Hugi Compo #19 (2002)
The "Cellular Texture Generator" Compo

Idea by unknown, Hosted by Adok
1. Ruud, The Netherlands (116)
2. Alexione, Yugoslavia (128)
3. Sergo Polsky, Russia (129)
3. Boiled Brain, Belarus (129)
3. Boreal, United States (129)


Hugi Compo #20 (2002)
The "Date of Easter" Compo

Idea by unknown, Hosted by Sniper
1. Ruud, The Netherlands (125)
2. Sergo Polsky, Russia (130)
2. meph, Germany (130)


Hugi Compo #21 (2003)
The "Tic Tac Toe" Compo

Idea by unknown, Hosted by Sniper
1. Sergo Polsky, Russia (213)
2. Boiled Brain, Belarus (214)
3. Stewart, UK (216)



Hugi Compo #22 (2003)
The "Dropping Game" Compo

Idea by unknown, Hosted by Sniper
1. G3, Russia (363)
1. ATV, Finland (363)
3. Stewart, UK (367)


Hugi Compo #23 (2004)
The "Knight's Tour" Compo

Idea by G3, Hosted by Adok
1. G3, Russia (46)
1. Shur, Russia (46)
3. Espineter, Spain (47)


Hugi Compo #24 (2005)
The "Turtle Drawing Machine" Compo

Idea by unknown, Hosted by Sniper
1. Hannes, Sweden (323)
2. ATV, Finland (323 + penalty)
3. ankh, Russia (325)



Hugi Compo #25 (2006)
The "Sudoku" Compo

Idea by unknown, Hosted by Sniper
1. G3, Russia (67)
1. Digimind, Russia (67)
3. TFx, Italy (69)


Hugi Compo #26 (2006)
The "Golden Ratio" Compo

Idea by unknown, Hosted by Sniper
1. Digimind, Russia (61)
2. TAD, United Kingdom (67)
3. claw, Germany (69)


Hugi Compo #27 (2006)
The "Resurrection" Compo

Idea by unknown, Hosted by Adok
1. Mentor, Denmark (566)
2. Chut, Hungary (576)
3. Espineter, Spain (591)



Hugi Compo #28 (2009)
The "Hugi USB" Compo

Idea by Sniper, Hosted by Sniper
1. Tapani, Sweden (233)
(2.) Sniper, USA (352) - hosted compo
2. Boreal, USA (438)


Hugi Compo #29 (2009)
The "Random Maze Builer" Compo

Idea by Boreal, Hosted by Sniper
1. Aphex, Romania (122)
1. Espineter, Spain (122)
3. Tapani, Sweden (128)


Links Related To This Article

The Hugi Compo Website has not been updated for a long time, but it can be found at http://www.hugi.scene.org/compo/. There you can also find links to download all the entries from past compos, including source code, rules, test suites and results.

What follows is a report by a former participant of the Hugi Compos, Krick.

Adok

Hugi Size Coding Competition

Written by Krick

The Hugi Size Coding Competition is a competition where people measure their skills in optimizing Intel processor (x86) Assembly code for size. There are around four competitions per year, each one stretching over some 6-9 weeks. At the end of the year a world league table is compiled based on the results people have had in the individual competitions. The rules of the competitions are very well defined, but rather loose. They incourage creativeness, and given the many obsolete and weird instructions available in Intel processors this makes the code produced really interesting and twisted.

During my time working for IBM Research in New York I lived in a 4 bedroom apartment at 123rd street on Manhattan. Two of the roommates I (krick) shared the apartment with for a while were Fred Perriot (Bubulle) and Pierre Almeras (st0ne). The three of us shared a strong interest in electronics, programming and anything other relating to mathematics and logics, and the topics of discussion in the household always revolved around such subjects. In the summer and autumn of 1998 the three of us got involved with the Hugi Size Coding Competition.

Me, Bubulle and st0ne participated in two competitions out of the five there were in 1998. We missed the others because we didn't know of Hugi when they were being held. The competition I liked the most was the 'Pong' contest where we were supposed to produce the smallest possible executable that would let the user play a two player game of Pong according to certain rules. For this contribution the three of us each wrote a program to compete with. We then honed and optimized these programs as much as we could, trying out different approaches and technique for a few weeks. After we all felt we wouldn't be going much further on our own we read each others code and tried to incorporate good ideas from the other programs into our own code. This led to us writing a new program using the best combination of approaches we could imagine. It is amazing how we on our own could go from programs around 300 bytes to programs around 150 bytes, and then reach 145 together. At the very end of development we got rid of a few bytes through st0ne's ingenious idea to identify small portions of the program with clear input and output and letting a computer test all possible combinations of opcodes using less bytes than the code we already had, trying to find some weird sequence... There is such a sequence in the Pong program.

As you can see from the code we kept meticulous control over exactly what result in terms of executable size each and every instruction of the program would give. We spent almost a week trying to figure out some smart way of making the size impact of the 'Player X has won.$' string smaller, but we didn't find anything to do with it, despite the massive number of ideas we tried. Sections that we did succeed with doing something with after trying for a long time were the beginning, integrating the 0A000h address used to address screen space, the vertical retrace delay routine and the super-cryptic 'aam 05h; add ah,bh; sahf' sequence.

As I said we competed in two competitions of 1998. We won one (where we competed individually, and Bubulle's contribution won) and ended up at second place for the other (the Pong contest). Even though we only participated in two out of five competitions we ended up at the third place of the 1998 world league table.

If you think tinkering with assembler code is one of lives many sources of joy, then participating in this competition is something you should do straight away. The people that try it out are probably the best Intel assembler size optimizers in the world (which might not be very useful outside of the competing crowd, but... ... I suppose there is no 'but' for that statement :)).

St0ne participated in a few competitions in 1999 as well, and managed to snatch the 3rd place in the World League Table that year too.

Krick