Show HN: A competition game to write bots for the most efficient algo
github.comI had an idea on a competition in a highly constrained environment: 32x32 matrix, with bots running code you write! The live site is https://kingofthegrid.com/.
Each bot emulates Z80 CPU and they all get equal execution time, so the most efficient algorithm wins.
Bots can move, eat, clone themselves, and most importantly, survive the competition.
Each submission, leaderboard is re-calculated, such that each participant has a match against each other, and the bot that makes the most wins gets to the top.
It includes includes an online in-browser IDE: https://kingofthegrid.com/ide/ that way you don't even have to download anything to spitball ideas. After compiling, you can test your code in browser as well.
I am also hoping for submitters to come up with ingenious ideas that would force others to re-think the strategy, etc.
In 2006, Symantec ran a programming competition of sorts for University students, where you had to write code for a tiny bot that was trying to collect as many resources as possible from the game map. What made it particularly interesting was that one of the features of the instruction set was a peek/poke operation that would let you modify the memory of other bots, letting you try to break them and take control of them to help your cause.
https://web.archive.org/web/20060224022835/http://www.symant...
Ah looks interesting. Perhaps this is inspired by Core War?
https://en.wikipedia.org/wiki/Core_War
Actually, I've been referenced to this already, but I have completely missed it.
I have been messing around with Z80 processor for some time and given how it's slow and simple I had to do some really dirtry tricks to make game code efficient, and that made me thinking "hey, this has potential as a benchmark, what if I make a competition where speed of decision making is key". Since Z80 Emulators allow for precise tick control, every bot gets equal chance.
And because of Z80 simplicity I was able to go 100% deterministic route: every game has a seed and it's guaranteed that games with the same seed and players end up the same, so players can debug what happened after they've lost, etc.
There are C compilers for it, but I am also curious if somebody with enough Rust-fu just provides a binding for it, since this is technically not about C, but about machine code.
At lease there's a difference: Core War uses fictional CPU architecture, while this one uses Z80. BTW, the first GameBoy is also a Z80 device, yes?
Something to have fun with on weekend :)
Reminds me (in spirit) of screeps https://screeps.com/ - any inspiration?
Yes, however I do not see screeps as constrained environment – AFAIK you can allow yourself to write sloppy code and get your task done.
Here I focus instead on sheer performance of your code. You 64k of ram is all you get, every move you do blocks you and you get an equal chance to execute your program – e.g. everyone gets a slice of 10'000 T-states per game iteration. For context, on ZX spectum machine, you get 70'000 T-states between frames. So this, potentially, creates a competitive environment, where a bot that takes 500 T-states less to take decision to move and does so earlier, eats you, it wins.
I've been a witness of competitions when people would take "who can make this problem solved the cheapest" and it's fun. So I figured I should try and take it to extreme.
Isn't it just a case of cloning yourself as many time as possible until you encounter an enemy, and then you have superior number even with a lesser good algorithm?
When you clone yourself you spend energy – and you must specify how much energy you sacrifice. With explosive cloning you will die fast. At least that's my assumption, this is all being refined as we speak.