binary-breeder
Advanced tools
Comparing version 0.1.3 to 0.1.4
'use strict'; | ||
var Random = require('random-js'); | ||
var Random = require('./random-wrapper.js'); | ||
@@ -52,3 +52,3 @@ module.exports = function(parentChromosomes, numOffspring, mutationChance) { | ||
for(var i = 0; i < numGenerated - numRequestedChildren; ++i) { | ||
var randomIndexToKill = Random.integer(0, newChildren.length - 1)(Random.engines.nativeMath); | ||
var randomIndexToKill = Random.integer(0, newChildren.length - 1); | ||
newChildren.splice(randomIndexToKill, 1); | ||
@@ -62,3 +62,3 @@ } | ||
for(var i = 0; i < chromosome.length; ++i) { | ||
if(Random.real(0, 0.999999)(Random.engines.nativeMath) < mutationChance) { | ||
if(Random.real(0, 0.999999) < mutationChance) { | ||
mutatedChromosome += chromosome[i] === '0' ? '1' : '0'; | ||
@@ -73,3 +73,3 @@ } else { | ||
function crossover(chromosome1, chromosome2) { | ||
var crossoverStartIndex = Random.integer(1, chromosome1.length - 1)(Random.engines.nativeMath); | ||
var crossoverStartIndex = Random.integer(1, chromosome1.length - 1); | ||
var newChromosome1 = ''; | ||
@@ -76,0 +76,0 @@ var newChromosome2 = ''; |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"main": "lib/binary-breeder.js", | ||
@@ -21,5 +21,2 @@ "description": "Breeds the specified number of offspring from two parent strings of binary digits with the possibility of random mutation.", | ||
}, | ||
"dependencies": { | ||
"random-js": "^1.0.4" | ||
}, | ||
"keywords": [ | ||
@@ -26,0 +23,0 @@ "genetic", |
@@ -37,3 +37,3 @@ 'use strict'; | ||
mockery.registerMock('random-js', mockRandom); | ||
mockery.registerMock('./random-wrapper.js', mockRandom); | ||
@@ -56,3 +56,3 @@ var expectedChildrenChromosomes = ['0101', '1110']; | ||
mockery.registerMock('random-js', mockRandom); | ||
mockery.registerMock('./random-wrapper.js', mockRandom); | ||
@@ -75,13 +75,6 @@ var expectedChildrenChromosomes = ['1111', '0100']; | ||
integer: function(min, max) { | ||
return function(maths) { | ||
return randomMock.integerResult; | ||
} | ||
return randomMock.integerResult; | ||
}, | ||
real: function(min, max) { | ||
return function(maths) { | ||
return MUTATION_CHANCE; | ||
} | ||
}, | ||
engines: { | ||
nativeMath: 'whatever' | ||
return MUTATION_CHANCE; | ||
} | ||
@@ -88,0 +81,0 @@ }; |
@@ -36,3 +36,3 @@ 'use strict'; | ||
mockery.registerMock('random-js', mockRandom); | ||
mockery.registerMock('./random-wrapper.js', mockRandom); | ||
@@ -55,3 +55,3 @@ var reproduce = require('../lib/binary-breeder.js'); | ||
mockery.registerMock('random-js', mockRandom); | ||
mockery.registerMock('./random-wrapper.js', mockRandom); | ||
@@ -73,13 +73,6 @@ var reproduce = require('../lib/binary-breeder.js'); | ||
integer: function(min, max) { | ||
return function(maths) { | ||
return randomMock.integerResult; | ||
} | ||
return randomMock.integerResult; | ||
}, | ||
real: function(min, max) { | ||
return function(maths) { | ||
return 0.0; | ||
} | ||
}, | ||
engines: { | ||
nativeMath: 'whatever' | ||
return 0.0; | ||
} | ||
@@ -86,0 +79,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
11
15983
280
- Removedrandom-js@^1.0.4
- Removedrandom-js@1.0.8(transitive)