examples/custom-breed-function-example.js
/* 

This example illustrates how to use a custom breed function

You have 10 cards numbered 1 to 10
You have to divide them into two piles so that:
The sum of the first pile is as close as possible to 36.
And the product of all in the second pile is as close as possible to 360.

*/
This example illustrates how to use a custom breed function
You have 10 cards numbered 1 to 10
You have to divide them into two piles so that:
The sum of the first pile is as close as possible to 36.
And the product of all in the second pile is as close as possible to 360.
This example illustrates how to use a custom breed function You have 10 cards numbered 1 to 10 You have to divide them into two piles so that : The sum of the first pile is as close as possible to 36 . And the product of all in the second pile is as close as possible to 360 .
function generateIndividual() {
	let array = [];
	let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
	for(var i = 0; i < numbers.length; i++) {
		let randIndex = Math.floor(Math.random() * numbers.length);
		while(array[randIndex] != undefined){
			randIndex = Math.floor(Math.random() * numbers.length);
		}
		array[randIndex] = numbers[i];
	}
	return array;
}
function generateIndividual ( ) { let array = [ ] ; let numbers = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ; for ( var i = 0 ; i < numbers . length ; i ++ ) { let randIndex = Math . floor ( Math . random ( ) * numbers . length ) ; while ( array [ randIndex ] != undefined ) { randIndex = Math . floor ( Math . random ( ) * numbers . length ) ; } array [ randIndex ] = numbers [ i ] ; } return array ; }
This example illustrates how to use a custom breed function
You have 10 cards numbered 1 to 10
You have to divide them into two piles so that:
The sum of the first pile is as close as possible to 36.
This example illustrates how to use a custom breed function You have 10 cards numbered 1 to 10 You have to divide them into two piles so that : The sum of the first pile is as close as possible to 36 .