evolve4src/src/evolve_simulator/kforth_mutate.cpp
KFORTH_PROGRAM *kforth_merge_rnd(EVOLVE_RANDOM *er, KFORTH_PROGRAM *kfp1, KFORTH_PROGRAM *kfp2)
{
	int mask;

	ASSERT( er != NULL );
	ASSERT( kfp1 != NULL );
	ASSERT( kfp2 != NULL );
	ASSERT( kfp1->kfops == kfp2->kfops );

	mask = CHOOSE(er, 0x0000, 0xFFFF);

	return kforth_merge_with_mask(mask, kfp1, kfp2);
}
/***********************************************************************
 * Randomized Merge operation.
 *
 * Uses a random 16-bit pattern, which merges
 * using the each bit of the pattern. When
 *
 *	PROGRAM 1	PROGRAM 2	RESULT
 *	---------	---------	----------
 *	ABBA		BLAG		ABBA
 *	JUNK		CRAP		CRAP
 *	FOOBAR		GREPLINUX	FOOBAR
 *	STUFF		XXYYZZ		XXYYZZ
 *	SUPERDUPER	FOOFOOFOO	SUPERDUPER
 *	FOO12h		FOO666		FOO666
 *			HHIIGG		HHIIGG
 *			HHUUPP		HHUUPP
 *			JJJJJJ		JJJJJJ
 *
 * Create a new program from 'kfp1' and 'kfp2'. 
 *
 * When the bit is 0, program 1's code block is donated. When
 * the bit is 1 then program 2's code block gets donated.
 *
 * The bit pattern is repeated as needed to cover all code blocks.
 *
 * If programs have different number of code blocks, then
 * extra code blocks from the longer program are appended
 * to the new program.
 *
 * NOTE: kforth_merge(x, x) is allowed, and will return a copy of 'x'
 *
 */
Randomized Merge operation.
Uses a random 16-bit pattern, which merges
using the each bit of the pattern. When



Create a new program from 'kfp1' and 'kfp2'.

When the bit is 0, program 1's code block is donated. When
the bit is 1 then program 2's code block gets donated.

The bit pattern is repeated as needed to cover all code blocks.

If programs have different number of code blocks, then
extra code blocks from the longer program are appended
to the new program.

kforth_merge(x, x) is allowed, and will return a copy of 'x'
Randomized Merge operation . Uses a random 16 - bit pattern which merges using the each bit of the pattern . When Create a new program from ' kfp1 ' and ' kfp2 ' . When the bit is 0 program 1 ' s code block is donated . When the bit is 1 then program 2 ' s code block gets donated . The bit pattern is repeated as needed to cover all code blocks . If programs have different number of code blocks then extra code blocks from the longer program are appended to the new program . kforth_merge ( x x ) is allowed and will return a copy of ' x '
KFORTH_PROGRAM *kforth_merge_rnd(EVOLVE_RANDOM *er, KFORTH_PROGRAM *kfp1, KFORTH_PROGRAM *kfp2)
{
	int mask;
	ASSERT( er != NULL );
	ASSERT( kfp1 != NULL );
	ASSERT( kfp2 != NULL );
	ASSERT( kfp1->kfops == kfp2->kfops );
	mask = CHOOSE(er, 0x0000, 0xFFFF);
	return kforth_merge_with_mask(mask, kfp1, kfp2);
}
KFORTH_PROGRAM * kforth_merge_rnd ( EVOLVE_RANDOM * er , KFORTH_PROGRAM * kfp1 , KFORTH_PROGRAM * kfp2 ) { int mask ; ASSERT ( er != NULL ) ; ASSERT ( kfp1 != NULL ) ; ASSERT ( kfp2 != NULL ) ; ASSERT ( kfp1 -> kfops == kfp2 -> kfops ) ; mask = CHOOSE ( er , 0x0000 , 0xFFFF ) ; return kforth_merge_with_mask ( mask , kfp1 , kfp2 ) ; }
Randomized Merge operation.
Randomized Merge operation .