Code vs Zombies - Feedback & Strategies

Merci Magus
Will try your advices. You were able to reach a very high rank using javascript so i hope to run all tests at least one time :wink:

The contest was a 24 hours contest. And in the code i used, performances was not required. Doing a contest in 24 hours is not the same as trying to do your best at the optimization puzzle :stuck_out_tongue:

Can a Zombie kill more than one human per turn?
Can Ash kill more than one human per turn?

No. But multiples zombies car try to kill the same human at the same time :smiley: But thereā€™s no effect. The human is still dead.

You are supposed to protect the humans :scream:

3 Likes

How did you decide the length of chromosome? I believe you used sequence of positions that Ash should move as chromosome. But the number of moves Ash should do till the end of game changes from test to test. Can you explain you Ga briefly, please?

1 Like

I suppose I could have gotten a higher score by implementing a simulation (I suppose this is where the optimization comes in?) and finally figuring out how to do something like a genetic algorithm, but just figuring out the difference in time between each zombie and I reaching each human and selecting the lowest difference above 0 was enough to get 100%. Maybe some day Iā€™ll come back to it and figure out how to get higher than 50,160 points.

1 Like

Funny, I did the eact same thing (If zombies get there faster than Ash mark human as dead, from alive humans pick closest one) and got 25250 points while trying to reach 40k. I wonder why.

How come the replay does not load? it always shows like 80% or 30% loaded but never shows me

Hi ,
I do not understand how you get the codingame ide to simulate each loop.
Did I missed a codingame functionality ??

1 Like

It is not a functionality; you have to write your own simulation code.

maybe just a bug, not working for me too :slight_smile:

When I run a simulation it always fails on rectangle and cross, because there are too many opportunities to kill Zombies in front of him and Ash forgets about the humans to save.

I wonder how I circumvent this.

EDIT: I made a manual check. I donā€™t start the simulation if all humans are targeted and Iā€™m more than 3000 units away. Iā€™m now at 6680 points.

Itā€™s likely that you donā€™t have enough simulation to find your best options. The easiest way would be to hard code some initial moves on this particular test cases. Otherwise you need to find a way to get more sim per turn (depending on the language it could be more or less hard)

1 Like

Thank you, yes Iā€™m using Javascript. I assume itā€™s not the best language. However Iā€™ve seen people up there with 700k points.

I have now a deterministic solution when all humans are targeted and Iā€™m more than 3k units away.

It fails sometimes, but thatā€™s how I got the record. Iā€™m trying to improve my sim now.

Also note that in case of js solutions that are the top of the leaderboard, it might be the result of offline training and hardcoded solutions against the submission validators. So it might be normal that in js you have a hard time reaching 700k (personally in c++ I only manage 400k but maybe my algo/sim sucks)

1 Like

Iā€™m now at 93k with a deterministic approach when my distance to closest Human is >3000 and a sim else.

I just do 3 random moves and pick the first move of the best strategy. Iā€™ve read in the post mortem that that @eldidou is killing all Zombies in random order, which I havenā€™t tried.

But heā€™s saying heā€™s doing 1 million strategies. I performance Checked mine, and itā€™s more like 3k. I could probably get out a bit more with some precalculations, but I think JS is just not the language for that. One day Iā€™ll pick up another language for that.

Whatā€™s the best language for these kind of games here?

A couple of optimization Iā€™ve done already

  • Not calculating root when comparing distances
  • Pre-calculating fibonacci
  • for loops instead of array methods
  • various loop improvements

There are a couple more, but the wins seem really nuanced and the result is anyway variance of the submit. Probably Iā€™m not at the JS limit, but not too far either.

Yep likely your issue comes from the fact that js is slow and your sim is not deep enough. Popular languages for high performance on CG could be C++, Rust and C.
For instance in C++ I have an 18-gene (plays 18 moves which is often the number of moves needed to end the game) ā€œGenetic algorithmā€ (I only apply mutations on a unique chromosome) and on big maps (with a lot of human/zombies) I would simulate about 90k mutations of the chromosome on the first turn (so 18 * 90k Asheā€™s moves in total)
Another thing you can try is to keep the best strategy you computed on the previous turn just in case you rng is not as good on the following one, this way you are guaranteed a minimum score instead of randomly trying something else (but the small depth of 3 moves ahead might be a blocker since you wonā€™t be able to spot great future combos).

1 Like

holy shit. Yeah thatā€™s quite a difference. I might try Rust.

btw: Iā€™m not sure if itā€™s a bug or not, but when I try to follow Zombies after simulation 1, Ash starts hiding behind the humans and I get terrible results. I donā€™t know why.

EDIT : 114k

Kind

Lol.

Now I learnt Rust and completely recoded my solution in Rust, just to realize that CG compiles rust in debug mode and not optimized, which makes it even slower than JSā€¦

Nvm. I learned some new stuff definitely

Oups. I thought that at some point rust was in release mode in the arena and debug in ide (I assumed it was the same for optimisation games due to the high rankings of dbdr and mikmak in optimization puzzles, unless they are hard coding).
Also according to post here: Languages update - #98 by _CG_Thibaud itā€™s now compiled with release libs all the time.

1 Like