DIUF Programming Contest :: Snake

See the new programmation contest: DIUF Evil Snake

Photos of the award ceremony

The final ranks relealed Happy winners Happy winners Happy winners Happy winners Happy winners Strategic discussions ;-) Piloting a snake was easier ;-)

Ranking

Final ranking (39600 matches played, 13200 per Strategy). The intervals are +/-2sigma around the average score over all matches.
                         BuergyStrategy2: [ 12365 -  12605]
        IvoBloechligerCornerHideStrategy: [ 10131 -  10388]
                         IliyaStrategy15: [  5276 -   5448]
            MariusSchwalbeSecondStrategy: [  4895 -   5051]
            JocelynThodeBeepBoopStrategy: [  3454 -   3575]
            SimonBrulhartAnotherStrategy: [  3417 -   3541]
               AliyaIbragimovaMyStrategy: [  2726 -   2834]
   GianlucaDemartiniShySnake3500Strategy: [  1952 -   2007]
  DjelleleddineDifallahScavengerStrategy: [   934 -    987]
        UlrichUltesNitscheWeiredStrategy: [   843 -    883]
         MariamDembeleCalibratorStrategy: [   147 -    161]
                  MarcUldryFirstStrategy: [   138 -    151]
    
On each playing field, the scores look a little bit different.

Standard field (empty)

                         BuergyStrategy2: [ 17363 -  17909]
        IvoBloechligerCornerHideStrategy: [ 14733 -  15407]
                         IliyaStrategy15: [  7253 -   7785]
            JocelynThodeBeepBoopStrategy: [  6364 -   6723]
            MariusSchwalbeSecondStrategy: [  6098 -   6546]
            SimonBrulhartAnotherStrategy: [  5411 -   5792]
               AliyaIbragimovaMyStrategy: [  4650 -   4987]
  DjelleleddineDifallahScavengerStrategy: [  2204 -   2388]
   GianlucaDemartiniShySnake3500Strategy: [  1459 -   1577]
        UlrichUltesNitscheWeiredStrategy: [   971 -   1074]
         MariamDembeleCalibratorStrategy: [   574 -    626]
                  MarcUldryFirstStrategy: [   540 -    588]

    

Cross

                         BuergyStrategy2: [ 15196 -  15738]
        IvoBloechligerCornerHideStrategy: [ 12166 -  12803]
                         IliyaStrategy15: [  6465 -   6952]
            MariusSchwalbeSecondStrategy: [  5604 -   5990]
            SimonBrulhartAnotherStrategy: [  4608 -   4912]
            JocelynThodeBeepBoopStrategy: [  4522 -   4810]
               AliyaIbragimovaMyStrategy: [  3469 -   3737]                                                                                                                                  
   GianlucaDemartiniShySnake3500Strategy: [  1574 -   1695]                                                                                                                                  
  DjelleleddineDifallahScavengerStrategy: [   923 -   1026]                                                                                                                                  
        UlrichUltesNitscheWeiredStrategy: [   675 -    741]                                                                                                                                  
         MariamDembeleCalibratorStrategy: [    90 -    109]                                                                                                                                  
                  MarcUldryFirstStrategy: [    87 -    106]                                                                                                                                  
    

Rooms

                         BuergyStrategy2: [ 12089 -  12508]                                                                                                                                  
        IvoBloechligerCornerHideStrategy: [  9070 -   9552]                                                                                                                                  
            MariusSchwalbeSecondStrategy: [  4891 -   5231]                                                                                                                                  
                         IliyaStrategy15: [  3695 -   3869]
            SimonBrulhartAnotherStrategy: [  2178 -   2321]
   GianlucaDemartiniShySnake3500Strategy: [  2141 -   2260]
            JocelynThodeBeepBoopStrategy: [  1980 -   2105]
               AliyaIbragimovaMyStrategy: [  1715 -   1836]
        UlrichUltesNitscheWeiredStrategy: [   806 -    893]
  DjelleleddineDifallahScavengerStrategy: [   686 -    754]
         MariamDembeleCalibratorStrategy: [    43 -     55]
                  MarcUldryFirstStrategy: [    37 -     48]

    

Turning

                         BuergyStrategy2: [ 10918 -  11315]
        IvoBloechligerCornerHideStrategy: [  8026 -   8448]
                         IliyaStrategy15: [  5164 -   5455]
            MariusSchwalbeSecondStrategy: [  4686 -   4969]
            SimonBrulhartAnotherStrategy: [  3247 -   3450]
            JocelynThodeBeepBoopStrategy: [  2786 -   2944]
               AliyaIbragimovaMyStrategy: [  2505 -   2665]
   GianlucaDemartiniShySnake3500Strategy: [  2261 -   2379]
        UlrichUltesNitscheWeiredStrategy: [   840 -    924]
  DjelleleddineDifallahScavengerStrategy: [   650 -    719]
                  MarcUldryFirstStrategy: [    14 -     21]
         MariamDembeleCalibratorStrategy: [    12 -     19]

    

DIUF

        IvoBloechligerCornerHideStrategy: [  6050 -   6342]
                         BuergyStrategy2: [  5819 -   5998]
                         IliyaStrategy15: [  3406 -   3576]
            MariusSchwalbeSecondStrategy: [  2777 -   2935]
   GianlucaDemartiniShySnake3500Strategy: [  2162 -   2289]
            JocelynThodeBeepBoopStrategy: [  1399 -   1510]
            SimonBrulhartAnotherStrategy: [  1384 -   1487]
               AliyaIbragimovaMyStrategy: [  1071 -   1165]
        UlrichUltesNitscheWeiredStrategy: [   804 -    899]
  DjelleleddineDifallahScavengerStrategy: [   113 -    142]
         MariamDembeleCalibratorStrategy: [     5 -     10]
                  MarcUldryFirstStrategy: [     3 -      6]

    

Animations

Every strategy plays agains four instances of itself. Click on the graphics to make it run (and then again).
Note: this may play very slowly outside the university...

AliyaIbragimovaMyStrategy
BuergyStrategy2
DjelleleddineDifallahScavengerStrategy
GianlucaDemartiniShySnake3500Strategy
IliyaStrategy15
IvoBloechligerCornerHideStrategy
JocelynThodeBeepBoopStrategy
MarcUldryFirstStrategy
MariamDembeleCalibratorStrategy
MariusSchwalbeSecondStrategy
SimonBrulhartAnotherStrategy
UlrichUltesNitscheWeiredStrategy

News

FAQ

Can a strategy know on which field it plays?

Not directly. There might be additional fields to the 5 fields provided (although the probability for this is low). Best you can do is compute a string representing the field in the constructor and comparing that string to stored strings to reliably identify individual fields. This allows you to tune your strategy to different field.

Is it possible / authorized to add variables in our strategy class, but outside the computeNextStep method?

Yes, of course, you may add any variable you please. I recommend initializing as much as possible in the constructor of the strategy. I recommend static memory structures to enhance speed.

Goal

The goal of this contest is twofold:

Task for contestants

Write a Java-Method which pilots a snake. At every time step your method will be called and your method will return the direction in which the snake shall advance in the next step. This method will have a complete access to a copy of the playing field.

To get started download the Source Code, which contains a very basic strategy, called SimpleStrategy. Also generate the JavaDoc for more information.

Who can enter the contest?

A contestant can submit several strategies, which might be tested already prior to the contest (details to be announced). However, for the final ranking, only the last submitted strategy will enter the contest.

What are the deadlines? (no pun intended)

Deadline for the submission of your code has been prolonged to Wednesday March 20 2013 23:59 local time. Later submissions will not participate at the contest.

The Awards-Ceremony will take place Wednesday March 27 2013 at 18:15 in A230 and will be followed by an Apéro.

Questions?

Ask them by e-mail to Ivo Blöchliger or in person at office C320. I will update this page accordingly.

Submission and Filename

Name your class FirstnameSurnameXXXXXXStrategy, like, for instance, IvoBloechligerSuperDuperStrategy.java. Send the Java-File by e-mail to Ivo Blöchliger. Also indicate, if your Strategy shall already be tested. Intermediate test results will be online publicly (scores and some selected gif-Files showing the last 20 iterations before your snake died). Your source code will not be published, of course.

You may also use another programming language that compiles for the JVM. However, I will not be able to spend much time getting your code to work. I recommend to send a dummy strategy to me, so I can test it. For the final submission provide a single jar-File containing everything your strategy needs to run. You must also provide the source code with instructions how to build your project.

Tournament rules

If possible (time-wise), for every possible combination of four strategies and for every field (may be more than 5) 4 rounds will be played, with a cyclic permutation of the starting position. Otherwise, teams of fours strategies will be randomly sampled. For the ranking the mean number of points over all matches/combinations/fields is calculated. I hope to get enough computing power to get statistically sound data. If some scores are too close, further, smaller tournaments may be executed to break ties.

The following rules are specified in Parameters.java:
Field size 40x30
Number of goodies on field 1
Number of goodies until game over 100
Number of steps until game over 3000
Points for a goodie 300
Points for surviving until game over 500
Points for "killing" another snake 1000
Points for bumping into another snake or a wall -500
Points for suicide -1000
Length increase per goodie 5
Points earned per step 1

At each step, every snake advances exactly one step in the direction computed by the method "computeNextStep()". If one cannot walk on the next field-element, the snake dies. Its tail continues to retract until the snake has vanished from the field.

A snake must move at each step (it cannot stand still), and it should not move backwards (it dies immediately since it crushes into itsself).

A snake starts at 0 points with length 5.

Each snake-element on the field has a counter, for how many more steps it remains on the field (you can see this value with Element.getTimer()) That means, if a snake dies, its head stops to advance and its tail follows up until the whole snake disapears.

If a snake eats a goodie, the tail continues to advance until the position of the goodie, where it stays for 5 steps.

A snake A is "killed" by another snake B, if snake A bumps into the body of snake B.

If a snake bumps into itself, it is considered suicide.

If two snakes bump into each other head to head, both loose points and do not get points rewarded for killing another snake.

At each step, computeNextStep() is called once. No more than 20ms real time shall be spent! If a Strategy exceeds this time limit, its snake may die. Here is the exact procedure:

If unsure, you may measure time with

        // at the beginning of your method
        long timeStarted = System.nanoTime();
        // do something
        // check available time
        if (System.nanoTime() - timeUsed > 1e6*19) {
          // time is up, terminate as quickly as possible!
        }
      

Strategies being caught in endless loops (i.e. not terminating for more than several seconds) will be permanently disqualified.

A snake dies if the next position is neither empty nor a goodie or if the next position would be occupied by two heads simultanously. Then both snakes die, of course.

A SecurityManager will be used to execute your methods. This SecurityManager does not allow anything, save for loading of an inner class. (So accessing private fields using reflection or any other funny business should be off the table now).

You are not allowed to create Threads. If you know of any practical way to enforce this or detect transgression, please let me know.

Origins

Almost the same code base has been used for the 1st-year course "Object oriented programming". This gives a little advantage to some talented 1st-year students. This is intended ;-)

Prizes

Basically stuff you've always wanted but you never dared to buy (most items include LEDs or remote controls, possibly both). I will keep posting pictures here as the stuff arrives. The fish is to be filled with Helium, it then can be piloted through the air. The helicopter still flies, despite my crashes.

This website is awful

You are more than welcome to improve it. Come by at C320 and share your ideas. The language best understood is html and css ;-)