I have 1595 lines of code so it sometimes goes slow when I play you and some other people. Most of that code is commented out so I didn’t lose it if I tried a new code and it didn’t work as well. I just haven’t gotten around to deleting it all. I also have some tests just to see if I can build obstacles depending solely on where the ball is (it didn’t work so well). This is one of those:
`
hero.build(“hole”, 40, 65);
hero.build(“rock”, 35, 50);
hero.build(“rock”, 35, 80);
hero.build(“ice”, 30, 40);
hero.build(“ice”, 30, 90);
hero.build(“rock”, 45, 45);
hero.build(“rock”, 45, 85);
while (true) {
let defensePositions = [
{type: “rock”, x: 25, y: 35}, {type: “rock”, x: 25, y: 95},
{type: “ice”, x: 30, y: 30}, {type: “ice”, x: 30, y: 70},
{type: “hole”, x: 35, y: 40}, {type: “hole”, x: 35, y: 90},
{type: “rock”, x: 40, y: 55}, {type: “rock”, x: 35, y: 75},
{type: “ice”, x: 45, y: 35}, {type: “ice”, x: 45, y: 95},
{type: “rock”, x: 50, y: 30}, {type: “rock”, x: 50, y: 65},
{type: “ice”, x: 55, y: 40}, {type: “ice”, x: 55, y: 90}
];
for (let pos of defensePositions) {
if (hero.canBuild(pos.x, pos.y)) {
hero.build(pos.type, pos.x, pos.y);
}
}
if (hero.opponentBall && hero.opponentBall.x < 70) {
let blockX = hero.opponentBall.x - 10;
let blockY = hero.opponentBall.y < 90 ? hero.opponenBall.y + 8 : hero.opponentBall.y - 8;
if (hero.canBuild(blockX, blockY)) {
if (hero.random() > 0.5) {
hero.build(“ice”, blockX, blockY);
} else {
hero.build(“rock”, blockX, blockY);
}
}
}
}
`