function Score(score, maxPerTurn, stopPoint) {
  if ((typeof score != 'number' && typeof score != 'object') || score === undefined) {
    throw new Error('BadParam', 'score value must be a number or another score object.');
  }

  this.hugeNum = 1000000;
  if (!maxPerTurn) maxPerTurn = this.hugeNum;
  this.maxPerTurn = maxPerTurn;

  var turns = Math.floor(score / this.hugeNum);
  var extraWeight = score % this.hugeNum;

  if (typeof maxPerTurn == 'object') {
    var firstTurnMax = maxPerTurn[0];
    var futureTurnsMax = maxPerTurn[0];
    if (maxPerTurn.length > 1) {
      var futureTurnsMax = maxPerTurn.slice(1);
    }

    if (extraWeight > firstTurnMax) {
      // can spend entire first turn on the extra weight available
      extraWeight -= firstTurnMax;
      turns += 1;
      var value = this.valueOf(turns, extraWeight);
      var newScore = new Score(value, futureTurnsMax, stopPoint);
      this.setValues(newScore.turns, newScore.extraWeight, futureTurnsMax);
      return;

    } else {
      if (stopPoint && extraWeight < firstTurnMax) extraWeight = firstTurnMax;
      this.setValues(turns, extraWeight, maxPerTurn);
      return;
    }

    // otherwise, build score object as normal
  } else if (typeof maxPerTurn == 'number') {
    var addedTurns = Math.max(Math.ceil(extraWeight / maxPerTurn), 1) - 1;
    turns += addedTurns;
    extraWeight = extraWeight - addedTurns * maxPerTurn;
    if (stopPoint && extraWeight < maxPerTurn) extraWeight = maxPerTurn;
    this.setValues(turns, extraWeight, this.maxPerTurn);
  } else {
    throw new Error('BadParam', 'maxPerTurn must be an array or a number.');
  }

}
/*
 * An object that stores information about the number of required turns for a
 * given move, as well as the number of extra spaces that would be traversed
 * before getting there.
 * Score objects use a large number to calculate their values. A higher turn
 * value always means a higher score, meaning that the path is less optimal.
 * Extra spaces required (extraWeight) are treated as tiebreakers.
 *
 * Eg. the score (1, 3) represents 1 turn and 3 extra spaces to move there.
 * (1, 3) < (2, 1) < (2, 4)
 *
 * Specifically, (3, 5) evaluates to 3 * largeNumber + 5
 * If the large number is 1 million, then (3, 5) evaluates to 3000005 when
 * using valueOf() or comparison operators.
 * NOTE: Equality still represents object equality, not Score value equality.
 * So (1, 3) != (1, 3), even though they evaluate to the same number.
 * Always use valueOf() when comparing scores to values for equality.
 *
 * A maxPerTurn of 0 implies that there is no maxPerTurn, ie. treat the
 * pathing task as normal (without turns or stopPoints).
 *
 * maxPerTurn can be an array, eg. [3, 5], which represents movement limits
 * on different turns. The last value is used for any turns for which no
 * maxPerTurn value was provided. Eg. one could move 3, then 5, then 5, 5,...
 *
 * See README for more information.
 */
An object that stores information about the number of required turns for a
given move, as well as the number of extra spaces that would be traversed
before getting there.
Score objects use a large number to calculate their values. A higher turn
value always means a higher score, meaning that the path is less optimal.
Extra spaces required (extraWeight) are treated as tiebreakers.

Eg. the score (1, 3) represents 1 turn and 3 extra spaces to move there.

Specifically, (3, 5) evaluates to 3 * largeNumber + 5
If the large number is 1 million, then (3, 5) evaluates to 3000005 when
using valueOf() or comparison operators.
NOTE: Equality still represents object equality, not Score value equality.
So (1, 3) != (1, 3), even though they evaluate to the same number.
Always use valueOf() when comparing scores to values for equality.

A maxPerTurn of 0 implies that there is no maxPerTurn, ie. treat the
pathing task as normal (without turns or stopPoints).

maxPerTurn can be an array, eg. [3, 5], which represents movement limits
on different turns. The last value is used for any turns for which no
maxPerTurn value was provided. Eg.

See README for more information.
An object that stores information about the number of required turns for a given move as well as the number of extra spaces that would be traversed before getting there . Score objects use a large number to calculate their values . A higher turn value always means a higher score meaning that the path is less optimal . Extra spaces required ( extraWeight ) are treated as tiebreakers . Eg . the score ( 1 3 ) represents 1 turn and 3 extra spaces to move there . Specifically ( 3 5 ) evaluates to 3 * largeNumber + 5 If the large number is 1 million then ( 3 5 ) evaluates to 3000005 when using valueOf () or comparison operators . NOTE : Equality still represents object equality not Score value equality . So ( 1 3 ) ! = ( 1 3 ) even though they evaluate to the same number . Always use valueOf () when comparing scores to values for equality . A maxPerTurn of 0 implies that there is no maxPerTurn ie . treat the pathing task as normal ( without turns or stopPoints ) . maxPerTurn can be an array eg . [ 3 5 ] which represents movement limits on different turns . The last value is used for any turns for which no maxPerTurn value was provided . Eg . See README for more information .
function Score(score, maxPerTurn, stopPoint) {
  if ((typeof score != 'number' && typeof score != 'object') || score === undefined) {
    throw new Error('BadParam', 'score value must be a number or another score object.');
  }
  this.hugeNum = 1000000;
  if (!maxPerTurn) maxPerTurn = this.hugeNum;
  this.maxPerTurn = maxPerTurn;
  var turns = Math.floor(score / this.hugeNum);
  var extraWeight = score % this.hugeNum;
  if (typeof maxPerTurn == 'object') {
    var firstTurnMax = maxPerTurn[0];
    var futureTurnsMax = maxPerTurn[0];
    if (maxPerTurn.length > 1) {
      var futureTurnsMax = maxPerTurn.slice(1);
    }
    if (extraWeight > firstTurnMax) {
      extraWeight -= firstTurnMax;
      turns += 1;
      var value = this.valueOf(turns, extraWeight);
      var newScore = new Score(value, futureTurnsMax, stopPoint);
      this.setValues(newScore.turns, newScore.extraWeight, futureTurnsMax);
      return;
    } else {
      if (stopPoint && extraWeight < firstTurnMax) extraWeight = firstTurnMax;
      this.setValues(turns, extraWeight, maxPerTurn);
      return;
    }
  } else if (typeof maxPerTurn == 'number') {
    var addedTurns = Math.max(Math.ceil(extraWeight / maxPerTurn), 1) - 1;
    turns += addedTurns;
    extraWeight = extraWeight - addedTurns * maxPerTurn;
    if (stopPoint && extraWeight < maxPerTurn) extraWeight = maxPerTurn;
    this.setValues(turns, extraWeight, this.maxPerTurn);
  } else {
    throw new Error('BadParam', 'maxPerTurn must be an array or a number.');
  }
}
function Score ( score , maxPerTurn , stopPoint ) { if ( ( typeof score != 'number' && typeof score != 'object' ) || score === undefined ) { throw new Error ( 'BadParam' , 'score value must be a number or another score object.' ) ; } this . hugeNum = 1000000 ; if ( ! maxPerTurn ) maxPerTurn = this . hugeNum ; this . maxPerTurn = maxPerTurn ; var turns = Math . floor ( score / this . hugeNum ) ; var extraWeight = score % this . hugeNum ; if ( typeof maxPerTurn == 'object' ) { var firstTurnMax = maxPerTurn [ 0 ] ; var futureTurnsMax = maxPerTurn [ 0 ] ; if ( maxPerTurn . length > 1 ) { var futureTurnsMax = maxPerTurn . slice ( 1 ) ; } if ( extraWeight > firstTurnMax ) { extraWeight -= firstTurnMax ; turns += 1 ; var value = this . valueOf ( turns , extraWeight ) ; var newScore = new Score ( value , futureTurnsMax , stopPoint ) ; this . setValues ( newScore . turns , newScore . extraWeight , futureTurnsMax ) ; return ; } else { if ( stopPoint && extraWeight < firstTurnMax ) extraWeight = firstTurnMax ; this . setValues ( turns , extraWeight , maxPerTurn ) ; return ; } } else if ( typeof maxPerTurn == 'number' ) { var addedTurns = Math . max ( Math . ceil ( extraWeight / maxPerTurn ) , 1 ) - 1 ; turns += addedTurns ; extraWeight = extraWeight - addedTurns * maxPerTurn ; if ( stopPoint && extraWeight < maxPerTurn ) extraWeight = maxPerTurn ; this . setValues ( turns , extraWeight , this . maxPerTurn ) ; } else { throw new Error ( 'BadParam' , 'maxPerTurn must be an array or a number.' ) ; } }
An object that stores information about the number of required turns for a
 given move, as well as the number of extra spaces that would be traversed
 before getting there.
An object that stores information about the number of required turns for a given move as well as the number of extra spaces that would be traversed before getting there .
// can spend entire first turn on the extra weight available // otherwise, build score object as normal