const gridSize = {rows: Math.max(hero.getLavaMap().length, hero.getLavaMap()[0].length), cols: Math.min(hero.getLavaMap().length, hero.getLavaMap()[0].length)};
Math.mod = (n, m) => n - m * Math.floor(n / m);
hero.setDir = d => {
hero.dir = d;
switch (d) {
case 0:
return hero.moveUp();
case 1:
return hero.moveRight();
case 2:
return hero.moveDown();
case 3:
return hero.moveLeft();
}
}
hero.waitUntil = (t, n) => {
while (true) if (hero.getRowAndCol()[t] === n) break;
}
hero.getRowAndCol = (x, y, array) => (array ? [(x ? x : hero.x) * 0.5 - 1.5, (y ? y : hero.y) * 0.5 - 1.5] : {row: (x ? x : hero.x) * 0.5 - 1.5, col: (y ? y : hero.y) * 0.5 - 1.5})
hero.navigateTo = (row, col) => {
let pos = hero.getRowAndCol();
if (pos.row !== row) {
let n = pos.row < row ? 2 : 0;
hero.setDir(Math.abs(pos.row - row) > gridSize.rows * 0.5 ? Math.abs(n - 2) : n);
}
hero.waitUntil('row', row);
if (pos.col !== col) {
let n = pos.col < col ? 3 : 1;
hero.setDir(Math.abs(pos.col - col) > gridSize.cols * 0.5 ? Math.abs(n - 2) : n);
}
hero.waitUntil('col', col);
}
hero.left = () => (hero.setDir(Math.mod(hero.dir - 1, 4)));
hero.right = () => (hero.setDir(Math.mod(hero.dir + 1, 4)));
hero.navigateTo(1, 1);
hero.navigateTo
isn’t working for whatever reason, idk why…
1 Like
Hey, moonwatcher, sorry mabye i can not help but i will try my best, can you give me the screen shot?
1 Like
Is it returning an error? If so what does it say?
1 Like
Error or what?
(20 chars)
1 Like
It just goes up and then nothing
1 Like
I have an idea of what’s wrong… lemme see
1 Like
This may help:
Sorry if I used it wrong I don’t usually use that function
1 Like
He used javascript, you used python, a bit different mabye
1 Like
I defined it lol, so there is a method
1 Like
Yes, in Python you can’t give the hero extra methods without some difficulties
3 Likes
Ok, let’s see if what I just did fixes it
1 Like
Oh, yeah. Sorry.
As someone who doesn’t know anything about JS…
Ight imma head out
Me, who couldn’t be bothered to make a meme
1 Like
I need some help with simulating games tho, if you guys are finished…
Hi @PeterPalov , i’m sure i simulated about 800000 games, and i took a photo of it, but i am sure that i deleted the picture before cuz my space is too small.
1 Like
:< Um…
Oh, try putting something in the code so you know if things are even starting. Fire, dash, etc. (You of all people should know what etc means xd)
If those things happen, move them further into the method.
Maybe it’s an if loop that’s never being activated because the condition is always false.
3 Likes
My brain is tired owo how did I not think of that, I’ve done it so many times lol
3 Likes
yo in the magma mountain, I see opponents just jumping over my fire action every time I shoot at them, how can I do the same thing? Like please tell me the code