Cloudrip Brawl 3: Succeeds, then fails when sumbmitted

This has happened with Gordon and the Pender.

function summonTroops() {
    if (hero.gold >= hero.costOf("griffin-rider")) {
        hero.summon("griffin-rider");
    }
}
function commandTroops() {
    let friends = hero.findFriends();
    for (let friend of friends) {
        let enemy = hero.findNearestEnemy();
        if (enemy) {
            hero.command(friend, "attack", enemy);
        }
    }
}
function collectCoin() {
    let bestCoin = null;
    let bestScore = 0;
    let coins = hero.findItems();
    for (let coin of coins) {
        coin.score = coin.value / hero.distanceTo(coin);
        if (coin.score > bestScore) {
            bestScore = coin.score;
            bestCoin = coin;
        }
    }
    hero.move(bestCoin.pos);
}
function heroAttack() {
    if (hero.canCast("shrink", hero)) {
        hero.cast("shrink", hero);
    }
}
while (true) {
    summonTroops();
    commandTroops();
    collectCoin();
    heroAttack();
}

It fails when it’s submitted because it’s always a different seed.

What do you mean when you say “seed?”

Every time you submit the “seed” changes, meaning coins and enemies will spawn in different places, at different numbers, etc.