Our Project/geneticV1/geneticV1.cpp
// generates a program with random instructions
generates a program with random instructions
generates a program with random instructions
void generate_program(memory_cell prog[MAX_PROGRAM_LENGTH])
{
  int i;
  for(i=0;i<MAX_PROGRAM_LENGTH;i++){
    prog[i].code = (instruction) (rand() % N_OPERATIONS);
    prog[i].arg_A = rand() % MEMORY_SIZE;
    prog[i].mode_A = (addressing) (rand() % N_MODES);
    prog[i].arg_B = rand() % MEMORY_SIZE;
    prog[i].mode_B = (addressing) (rand() % N_MODES);
  }
}
void generate_program ( memory_cell prog [ MAX_PROGRAM_LENGTH ] ) { int i ; for ( i = 0 ; i < MAX_PROGRAM_LENGTH ; i ++ ) { prog [ i ] . code = ( instruction ) ( rand ( ) % N_OPERATIONS ) ; prog [ i ] . arg_A = rand ( ) % MEMORY_SIZE ; prog [ i ] . mode_A = ( addressing ) ( rand ( ) % N_MODES ) ; prog [ i ] . arg_B = rand ( ) % MEMORY_SIZE ; prog [ i ] . mode_B = ( addressing ) ( rand ( ) % N_MODES ) ; } }
generates a program with random instructions
generates a program with random instructions