Anybody think of another way to do the robot levels without adding any state?
Variable to control the direction the robot moves, changed with the function phone.
var r = Math.random();
me.move(
r < 0.4 ? 'right' :
r<0.6 ? 'up' :
r < 0.8 ? 'down' :
'left'
);
Works eventually :)For level 13 I just used:
me.move(Math.random() > 0.5 ? 'right' : 'down');
And regenerated the map until I got to one that could be solved by moving only right and down.http://qiao.github.io/PathFinding.js/visual/
You'd just need to recalc the pathfinder each time.
The robot follows my player, unless it's green, in which case it goes 'down' (cause it wont pick up the key under remote control for some reason). I'm saving state in the color of the player.
The robot goes down unless its x-coordinate is between 20 and 33, in which case it goes up. Kinda cheesy, but it works...