"Mini" Challenge

There have some been some fun challenge topics with different scenarios. I was recently playing around and decided to try and make the smallest (in lines of code) algo possible. So that’s the challenge (just for fun), see how small you can make your algo.

It obviously will not be very good, but it has to at least build a base and run attacks in a non-random order. In other words, don’t just have a vegetable, it has to be capable of winning against weak bots.

I am counting lines of code as every single line of code in your zip file, regardless of whether you wrote or use it (eg include gamelib library, etc). The exceptions are things which are used for the server to run your algo, and not by you, like:

  • algo.json
  • run.sh

I’m curious to see how small people can get it :). My best attempt is 16 lines of code, 19 if you count every single line (including algo.json and run.sh). It is currently ranked as 1974, but will probably change since it hasn’t been up very long.

Share your best attempts, and I’d be really interested if you could make a very successful one :). After a little while, I’ll share my attempt, and anyone else is welcome to also do so.

Happy coding :).


Hey, I’ve just wanted to try it and found quite interesting bug in this game.

Moreover, maybe I don’t understand what do you mean exactly by line of code. But I think I can make algo, which will keep around rating 2000 using only 10 lines of code.

1 Like

When I say lines of code, I mean in your file the number of lines, for all the files that you use in your zip folder.

So, for example, if you go to the default algo strategy, I would count that single file as having 231 lines of code (I know technically there are comments and newlines, but for simplicity). You would then also need to count the number of lines in every file in the gamelib folder, etc.

If you can do it in just 10 lines of code then I am very impressed!

OK, you can check it here: https://terminal.c1games.com/api/game/algo/68140/matches. It should be soon around 2000 and is only 8 lines of code + 3 lines in run.sh

EDIT: I was actually printing state string to debug console, so it’s only 6 lines :slight_smile:

Nice! Naturally, I had to try and compete… I was able to get it down to 5 while sacrificing basically everything that matters, lol :).

1 Like

Haha, I’m at 4 now :smiley:

1 Like

Got to 2 :), amazing what a little competition can do :grin:. I was so happy with 16 before, lol.

1 Like

many of the cool & weird algos like rusty have all suddenly improved and entered into the top 10…getting pushed to page 2 has def had me more interested in perfecting A* pathfinding than I have previously been at any point in the last decade.

Short code algo competition… the number of lines inside the on_turn() function and functions called from there would make sense? Would be good motivation to learn advanced list comprehensions & functional coding style for sure, take out all the for & while loops and i += 1 sort of filler.

Hey, I’ve got it to one-liner :slight_smile:. I don’t think there is anything better :grin:

I officially did it, got to -5 lines of code… Just kidding :). I also got mine to 1 line of code for a grand total of 959 characters. I’m honestly quite surprised that it’s even possible. I still remember looking at my 16 lines and thinking hmmm, no real way to get it down any further, lol. Thanks for giving me goals so I was forced to write some of the worst code ever written :grin:.

If anyone else looks at this I still encourage you to give it a shot, since as @Scott-Hanpa points out it forces you to get familiar with python in an important way. I would add that it forces you to understand the engine a lot better as well, since you really can’t use the code written for your convenience. Could be a useful exercise.

As I mentioned above, I’ll post my code in a little while but I want to wait in case other people want to try for themselves. I’d also love to see @paprikadobi’s implementation as well (later, as well) if he’s willing, since I’d imagine we have an extremely similar line, but it’d be cool if we didn’t :).


Interesting, I might give it a shot.
Now the real question is which one liner algo is better? Has the higher ELO?

1 Like

No problem, I will share it :slight_smile:

Sounds like another challenge :slight_smile: One character used would be valued -1 ELO. My code takes actually 481 characters and has ELO 2085, so I would have total score: 1604 :slight_smile:

EDIT: Anyway, thank you @Isaac for the challenge. I’ve just totally cleaned my code, because of things I’ve learned during this challenge :slight_smile:


Alright, it’s now been a week since I first posted this, so I’m going to share my solution. Please keep in mind I didn’t start with this, it began very legibly and then I just kept removing/replacing stuff. If you actually want to look at what it’s doing I highly recommend copying it into a text editor where you can separate it out.

Show Code
while True:cmd=input();(print(('{}'.format([["FF",14-e,e+1] for e in range(13)]+[["DF",x,y] for (x,y) in [[26,13],[27,13],[26,12],[22,8],[12,5],[14,5],[15,5],[14,4]]]+[["FF",x,y] for (x,y) in [[25,11],[24,10],[7,9],[8,9],[9,9],[10,9],[11,9],[23,9],[11,8],[11,7],[21,7],[12,6],[14,6],[15,6],[16,6],[17,6],[18,6],[19,6],[20,6]]]+[["EF",x,y] for (x,y) in [[8,8],[9,8],[10,8],[9,7],[10,7],[10,6],[11,6],[11,5],[14,2]]])).strip()+"\n"+('[]' if int(float(cmd[cmd.find(',',cmd.find(',',cmd.find('p1Stats'))+1)+1:cmd.find(',',cmd.find(',',cmd.find(',',cmd.find('p1Stats'))+1)+1)]))<11 else '{}'.format([["PI",14,0] for _ in range(int(float(cmd[cmd.find(',',cmd.find(',',cmd.find('p1Stats'))+1)+1:cmd.find(',',cmd.find(',',cmd.find(',',cmd.find('p1Stats'))+1)+1)]))-3)]+[["SI",5,8] for _ in range(3)])).strip()+"\n",end='',flush=True) if int(float(cmd[cmd.find('[',cmd.find('turnInfo'))+1:cmd.find(',',cmd.find('turnInfo'))]))==0 else '') if "debug" not in cmd else ''

OK, there is my solution:

Show Code
[print('[[FF,0,13],[FF,27,13],[FF,1,12],[FF,26,12],[FF,2,11],[FF,5,11],[FF,22,11],[FF,25,11],[FF,3,10],[FF,4,10],[FF,6,10],[FF,21,10],[FF,23,10],[FF,24,10],[FF,7,9],[FF,20,9],[DF,5,10],[DF,22,10],[DF,6,9],[DF,21,9],[EF,11,10],[EF,12,10],[EF,11,9],[EF,12,9],[EF,9,8],[EF,10,8],[EF,11,8],[EF,9,7],[EF,10,7],[EF,8,6],[EF,9,6],[EF,8,5],[EF,9,5],[EF,10,6],[EF,11,7],[EF,12,8]]\n[[EI,4,9],[EI,4,9],[EI,4,9],[EI,4,9],[EI,4,9],[SI,5,8],[SI,5,8],[SI,5,8]]') for _ in range(100000) if 'Info":[0' in input()]
1 Like