level 2
loop { var yak = this.findNearestEnemy();
if (yak) {
var pos=yak.pos;
var yakX=pos.x;
var yakY=pos.y;
// A yak is above you if it's y is greater than your y.
// If the yak is above you, build a fence 10m below it.
// If the yak is below you, build a fence 10m above it.
var newX=this.pos.x;
var newY=this.pos.y;
if(yakY>newY){this.buildXY("fence",newX,newY+1);}
if(yakY<newY){this.buildXY("fence",newX,newY-1);}
} else
{
// Move right 10m towards the oasis.
var x=this.pos.x+10;
var y=this.pos.y;
this.moveXY(x,y);
}
}
2015年01月06日 09点01分

