Apocalypse, work in progress


Hello there,

I’m working on a no-flag Apocalypse code. I have a nice and working code that does the following :

  1. Checks all the enemy missiles and for each i in missiles, I record the position (x_i,y_i) and time (t_i) of the explosion.
  2. Checks if my current position is safe, considering my (x, y) at the current time (t = this.now() )
  3. If the position is unsafe, I check all the positions in the area, and check which one is the closest safe-position.

It works fine. It’s unefficient on several levels, but I don’t want to optimize yet because it’s not fully functionning. The main flaw comes from the walk from one unsafe place to a safe one. If my hero were teleporting, this algorithm would be enough, but it’s not.

I need to check how safe is the walk toward the safe place, and in order to achieve this, I think I need to create a function with a similar structure to

 this.isPathClear(pos1, pos2)

but in my case, I need .isPathSafe.

I’m unsure of the proper way to code it. Is there better way to do it than get the equation of the line between pos1 and pos2, and for every X coordinate ( increasing 1 by 1 from pos1.x to pos2.x ), compute the associated Y closest to the line and check for each if the path is clear / safe.

Any tip ?


Nice approach. I solved it in a slightly different way, but I don’t want to give you any hints, as this one is a bit of an interesting challenge that not many players have taken up yet. Good luck!


I know from experience that you can get the xy of the x’s but I can’t seem to remember the code

Anyways good luck


I have trouble finding the travel time of an artillery shell (written delayFireBoom in the code below). In the thang editor, I’ve found the CD of artillery is 3.6sec, but I had better results with 3.55. I thinkI’m close to solving this level with a clever algorithm, but I have some inaccuracy in the way I determine the position and time of explosions because there is a slight delay between the shot being fired and me catching the new missile. It leads to a 1 or 2 pixel inaccuracy (far away from the artillery) that kills my hero because of the crazy damage the shells do, even on a slight error on time or position.

I tried to catch the targetPos of the enemies for a better accuracy, but it seems I can’t catch all of the shell being fired. With no better debug than this.say, I struggle in this preliminary task. Maybe a better (and much easier) way to do is to catch the red-cross thangs, but I don’t know how to do that. So here is my bandaid code to determine a set of positions and time of explosions. I would love some tips on how to do it better.

Maybe the red X mark thang page could help ?

var missiles = [] , missile = null , nMissiles = 0 , iMissile = 0 ;
var shells ={} , nshells = 0 , shell;
var delayFireBoom = 3.55;

loop {
    missiles = this.findEnemyMissiles();
    nMissiles = missiles.length ;
    now = this.now();

    for(iMissile = 0 ; iMissile < nMissiles ; iMissile++){
        // Record shell info (only once) for every shell being shot.
        if (!shells[missile.id]) {
            shells[missile.id] = {
                "x":missile.pos.x +missile.velocity.x*delayFireBoom ,
                "y":missile.pos.y +missile.velocity.y*delayFireBoom ,
                "t":now +delayFireBoom 
    for(shell in shells){
        // Delete already exploded shells from the shells to consider
        if(now - shells[shell].t > delayFireBoom){
            delete shells[shell];


I think if you considered the red X’s it would be more benificial


Yea, that’s my point. How ?


I don’t know ask @nick


You can’t see where the red X markers are, but you can just read the targetPos attribute of the shell to see where it’s going to land.


i got the correct coding but my problem is speed
here is my code:



Draz. We have told you three times to properly format your code, and yet you seemingly refuse to do it. Why is this? You say you have read the FAQ “71 times”, and how to post your code is clearly stated.

Please do not give out correct code, as it gives an easy solution without letting the player put effort into it.


in the messege is not properly formed i can’t make it proprely formed in the messege


Yes, you can. The FAQ specifically tells you how to “post your code with radiant, harmonious formatting.”


help! my code doesnt work, can someone help me?
enemyMissiles = self.findEnemyMissiles()
for enemyMissle in enemyMissiles:
if enemyMissle:
self.moveXY(enemyMissle.pos.x - 10, enemyMissle.pos.y - 10)