Thread: Selection Method

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    85

    Selection Method

    Code:
    void crossover(int mum, int dad)
    {
      int mumfirst, mumlast, dadfirst, dadlast;
      struct prog *mump = &population[mum];
      struct prog *dadp = &population[dad];
      int worst1, worst2;
    
      do worst1 = select_worst();
      while (worst1 == mum || worst1 == dad || worst1 == best_prog);
    
      do worst2 = select_worst();
      while (worst2 == mum || worst2 == dad || worst2 == worst1 ||
             worst2 == best_prog);
    
      mumfirst = find_first(mump);
      mumlast  = subtree_end(mump->code, mumfirst);
      dadfirst = find_first(dadp);
      dadlast  = subtree_end(dadp->code, dadfirst);
    
      create_child(worst1, mump, mumfirst, mumlast, dadp, dadfirst, dadlast);
      if (!correct)
         create_child(worst2, dadp, dadfirst, dadlast, mump, mumfirst, mumlast);
    
    }
    hi everybody, this is a script to select direction for an object

    Any body have any idea, how can i improve the program?
    thanks

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    That's not a program, it's a function. Without definitions of struct prog and the myriad functions you are calling, it's nearly impossible to comment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem on - Selection on which item to purchase
    By karipap in forum C Programming
    Replies: 5
    Last Post: 04-07-2009, 06:19 AM
  2. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  3. on method pointers and inheritance
    By BrownB in forum C++ Programming
    Replies: 2
    Last Post: 03-02-2009, 07:50 PM
  4. selection problem
    By Ken JS in forum C Programming
    Replies: 3
    Last Post: 08-04-2007, 09:47 PM
  5. problem with selection code
    By DavidP in forum Game Programming
    Replies: 1
    Last Post: 06-14-2004, 01:05 PM