Unable to move Peasant in Greed

I believe there seems to be a bug in the move command of the peasant. Please see below for a snippet illustrating the problem.

var peasants = base.getByType(‘peasant’);
for (var peasantIndex = 0; peasantIndex < peasants.length; peasantIndex++) {
var peasant = peasants[peasantIndex];
var xTarget = 0.0;
var yTarget = 0.0;
// I do my targetpos calculations here
base.say("x: " + xTarget + " y: " + yTarget); // This works, which means xTarget and yTarget are valid
base.command(peasant, ‘move’, new Vector(48, 48)); //This also works
base.command(peasant, ‘move’, new Vector(xTarget, yTarget)); // This gives an error saying:
// Cannot read property ‘x’ of null
}

I am filing it under bugs since I am reasonably certain there is nothing wrong with my code. Please re-categorize it if its something I am doing wrong and please point out my error.

I am also having troubles with the use of Vector. I am not entirely sure if it is related.

function getMeanPoint(units){
   return units.reduce(computeVectorSum, new Vector(0,0));
}

units will e.g. be all the items.

function computeVectorSum(a, b){
   return Vector.add(a.pos, b.pos); //this gives the error: cannot read property 'copy' of undefined
}

This will add all the vectors of the items. Or should.

I have the feeling something is queer with Vector, but maybe I’m just doing it wrong.

@Hannofcart Checked out the code. I think that xTarget and yTarget are getting NaNs at some point right before the error occurs:

Could this be what’s doing it?

@Kirstin Seems like the reduce is expecting the starting value to be an object with {pos: new Vector(0, 0)} instead of just the straight-up new Vector(0, 0). I tried out making the adjustments to be operating on wrapper objects instead and then pulling out the answer as the pos property and it seemed to work.