Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

binary-breeder

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

binary-breeder - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

lib/random-wrapper.js

8

lib/binary-breeder.js
'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 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc