Math.floor in invader generation



  • https://github.com/screeps/backend-local/blob/master/lib/cronjobs.js#L443

    invaderGoal *= Math.floor( Math.random() > 0.5 ? 2 : 0.5 );

    is equivalent to

    invaderGoal *= Math.random() > 0.5 ? 2 : 0;

    surely this should be

    invaderGoal = Math.floor(invaderGoal * (Math.random() > 0.5 ? 2 : 0.5 ));

    ?

    ☝


  • Yes, some players already know this one. At another position is a check to set the invaderGoal to 100k if it is 0. It was surely not intended this way, but it also has never been fixed. I would also prefer to choose either invaderGoal *= Math.random() > 0.5 ? 2 : 0; to document clearly that the current behaviour is intended or to change it to invaderGoal = Math.floor(invaderGoal * (Math.random() > 0.5 ? 2 : 0.5 )); and announce that change.



  • The purist in me wants: invaderGoal = C.INVADERS_ENERGY_GOAL * Math.max(0.35, Math.min(2, 1 + cdf(Math.random())));

    A nice normal distribution mean at 100K between 35K and 200K.



  • Is anything happening about this issue?