Skip to content

Commit

Permalink
Fix temperature value
Browse files Browse the repository at this point in the history
Thanks to @jalava, who posted issue #1.
  • Loading branch information
parmentf committed Sep 9, 2013
1 parent 59b05df commit 95f64c7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/random-weighted-choice.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var debug = require('debug')('rwc');
var RandomWeightedChoice = function (table, temperature, randomFunction, influence) {
influence = influence || 2; // Seems fine, difficult to tune
if (typeof(temperature)=="undefined") temperature = 50; // in [0,100], 50 is neutral
temperature = temperature | 50;
temperature = isNaN(temperature) ? 50 : temperature;
debug('temperature', temperature);
var T = (temperature - 50) / 50;
if (typeof(randomFunction)=="undefined") randomFunction = Math.random;
Expand Down Expand Up @@ -62,4 +62,4 @@ var RandomWeightedChoice = function (table, temperature, randomFunction, influen
}
};

module.exports = RandomWeightedChoice;
module.exports = RandomWeightedChoice;

0 comments on commit 95f64c7

Please sign in to comment.