Frozen Fortress/Equinox tips, tricks, and chat

@mercurym Congrats! Proud of you!

2 Likes

Ahh I lost to Durbination

1 Like

Hey guys. Hero.mana says that it’s defined, but is not being used for some reason. Was working in previous updates.

Is this an error?
@Venneth
@nick
Sorry for pinging you, but urgent as competition ends in few days.

1 Like

Hello, can you provide a screenshot or a match link?

2 Likes

well #1 worldwide means number #1 in your age bracket too .-.

2 Likes

yeah lol but Im #3 now

compare that to what happend here :rofl::
Screenshot 2023-04-17 3.11.55 PM

1 Like

Hey @MarmiteOnToast try translating this:

const allsquares = 'abcdefgh';
const possibleTowers = hero.availableTowerTypes; // better than calling it again and again
const tower = {
    a: {name: 'none', level: 0}, 
    b: {name: 'none', level: 0}, 
    c: {name: 'none', level: 0}, 
    d: {name: 'none', level: 0}, 
    e: {name: 'none', level: 0}, 
    f: {name: 'none', level: 0}, 
    g: {name: 'none', level: 0}, 
    h: {name: 'none', level: 0}
};
for (let p of Object.keys(tower)) tower[p]._squares = p;
const towerArray = [];
(function () {let keys = Object.keys(tower); for (let key of keys) towerArray.push(tower[key]);})();
const verify = (val, def) => (val === undefined ? def : val);
function randint (min, max) {
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min;
}
function sell (...args) {
    if (possibleTowers.indexOf(args[0]) !== -1) {
        if (JSON.stringify(args[1])[0] === '{') {
            let amount = verify(args[1].amount, howMany(args[0]));
            let startFromEnd = verify(args[1].startFromEnd, false);
            let lowest = verify(args[1].lowest, true);
            let squares;
            if (amount > 0) {
                let sl = Math[lowest ? 'min' : 'max'](... towerArray.filter(t => t.name === args[0]).map(t => t.level));
                squares = allsquares.split('').filter(s => tower[s].name === args[0] && tower[s].level === sl);
            } else return;
            let already = [];
            let v = [startFromEnd ? 0 : squares.length, startFromEnd ? squares.length : -1];
            let i = v[0];
            let pm=startFromEnd?(function(val){return val++;}):(function(val){return val--;});
            mainloop: while (true) {
                if (startFromEnd ? (i >= v[1]) : (i < v[1])) break;
                if (Math.abs(i - v[0]) > amount) break;
                if (args[1].random) {
                    let r = randint(0, squares.length - 1);
                    while (true) {
                        if (already.length === amount) break mainloop;
                        if (already.indexOf(r) === -1) break;
                        r = randint(0, squares.length - 1);
                    }
                    already.push(r);
                    build(squares[r]);
                    i = pm(i);
                    continue;
                }
                sell(squares[i]);
                i = pm(i);
            }
            return;
        }
        if (args.length > 1) args = args.length > 1 ? args : args[0].split('');
        for (let s of Object.keys(tower)) {
            if (tower[s].name === args[0] && args.indexOf(s) === -1) {
                hero.sell(s);
                tower[s] = {name: 'none', level: 0};
            }
        }
        return;
    }
    args = args.length > 1 ? args : args[0].split('');
    for (let s of args){
        hero.sell(s);
        tower[s] = {name: 'none', level: 0};
    }
}
const find = tt => towerArray.filter(t => t.name === tt);
const howMany = t => find(t).length;
const build = (t, s) => {
    if (s.length > 1) {
        let letters = s.split('');
        for (let letter of letters) build(t, letter);
        return;
    }
    if (tower[s].name !== t && tower[s].level !== 0) sell(s);
    hero.build(t, s);
    tower[s].name = t;
    tower[s].level = tower[s].level + 1;
};
const towers = (start, end) => {
    start = (start + 0 === start + '0') ? allsquares.indexOf(start) : start;
    end = (end + 0 === end + '0') ? (allsquares.indexOf(end) + 2) : end;
    let returnVar = [];
    for (let i = start; i < end; i++) returnVar.push(tower[allsquares.charAt(i)]);
    return returnVar;
}
const squares = (start, end) => {
    start = (start + 0 === start + '0') ? allsquares.indexOf(start) : start;
    end = (end + 0 === end + '0') ? (allsquares.indexOf(end) + 2) : end;
    return allsquares.substring(start, end - start);
};
function upgrade (...args) {
    if (args.length === 0) return upgrade(allsquares);
    if (possibleTowers.indexOf(args[0]) !== -1) {
        if (JSON.stringify(args[1])[0] === '{') {
            let amount = verify(args[1].amount, howMany(args[0]));
            let startFromEnd = verify(args[1].startFromEnd, false);
            let lowest = verify(args[1].lowest, true);
            let squares;
            if (amount > 0) {
                let sl = Math[lowest ? 'min' : 'max'](... towerArray.filter(t => t.name === args[0]).map(t => t.level));
                squares = allsquares.split('').filter(s => tower[s].name === args[0] && tower[s].level === sl);
            } else return;
            let already = [];
            let v = [startFromEnd ? 0 : squares.length, startFromEnd ? squares.length : -1];
            let i = v[0];
            let pm=startFromEnd?(function(val){return val++;}):(function(val){return val--;});
            mainloop: while (true) {
                if (startFromEnd ? (i >= v[1]) : (i < v[1])) break;
                if (Math.abs(i - v[0]) > amount) break;
                if (args[1].random) {
                    let r = randint(0, squares.length - 1);
                    while (true) {
                        if (already.length === amount) break mainloop;
                        if (already.indexOf(r) === -1) break;
                        r = randint(0, squares.length - 1);
                    }
                    already.push(r);
                    build(tower[squares[r]].name, squares[r]);
                    i = pm(i);
                    continue;
                }
                build(tower[squares[i]].name, squares[i]);
                i = pm(i);
            }
            return;
        }
        if (args.length > 1) args = args.length > 1 ? args : args[0].split('');
        for (let s of Object.keys(tower)) {
            if (tower[s].name === args[0] && args.indexOf(s) === -1) {
                build(tower[s].name, s);
            }
        }
        return;
    }
    args = args.length > 1 ? args : args[0].split('');
    for (let s of args) build(tower[s].name, s);
}

lol, omg that’s actually so long tho

1 Like

Now my functions have the capability of doing this:
upgrade(typeOfBuilding, {random: true, amount: 8})
random makes it just upgrade a random tower of that type that is at the lowest level, amount makes it upgrade… well, a certain amount of times, and it also has:
upgrade(typeOfBuilding, {startFromEnd: true, lowest: true})
I don’t remember what lowest does, but I think it makes it start from the lowest level and if it’s false then it starts from the highest? startFromEnd makes it start from h if random is false and if startFromEnd is false it starts from a

Default values: startFromEnd: false, random: false, lowest: true, amount: 1

2 Likes

I could make them with even more features but I feel like that would make the functions obnoxiously long and it’s not really useful, like, if you can’t deal with any upgrading strategy with the code I gave you, like, dude, like, how, like, what? Like the amount of capabilities this code gives your building strategy-

2 Likes

When I was #1, I didn’t use rage and haste lol

1 Like

how many lines is this code?

I found that a good way to deal good collective damage with the mage is to find the enemy that has the most enemies within 10 meters of it and have the mage target that enemy.

2 Likes

Sure Venneth.

Here is the match link.
[CodeCombat - Coding games to learn Python and JavaScript](https://Match Link)

hero.ability("summon", hero.mana)

Quite messy code, sorry. Just a work in progress. :smiley:

1 Like

Thank you for the match link, however your code ran just fine without any errors against that opponent

1 Like

Thank you for the advice, I’m currently ranked 10th in my class, a good place to be honest, but I want to move up since it beat 1st and 3rd place but I can’t beat 7th and 6th, because I don’t do the enough points, and I wanted to see how I can upload that, also where I can put my code for improvements

1 Like

Ah, okay then. It seems fixed, although now some games on home-ranking show lots of defeat when victory on a loaded game scene. Very annoying and the ranking falls from that.

1 Like

Also noticed that VennethCC & Durbination’s codes cannot be rendered fully, and this makes it a tie, when by looking at the match on while true loop detection, seems like vennethCC wins.

We really need to limit the while true loops & sensors in our codes so ranking really balances out strongly.

1 Like

Use this button to upload code:
Screenshot 2023-04-19 8.27.52 PM
The this will show up:
Screenshot 2023-04-19 8.41.11 PM
The copy and paste your code, and post. Once you do that, we can figure out how to improve your code and I can give you even more advice.

143

2 Likes