Exemplo n.º 1
0
 public object Clone()
 {
     NQueenGene ret = new NQueenGene(this.QueenLocation.Length);
     for (int i = 0; i < queen_location_.Length; i++) {
         ret.queen_location_[i] = queen_location_[i];
     }
     return ret;
 }
Exemplo n.º 2
0
 private void DrawQueens(NQueenGene top_gene)
 {
     BoardPicBox.Refresh();
     int[] queen_location = top_gene.QueenLocation;
     Graphics graphics = BoardPicBox.CreateGraphics();
     DrawBoard(graphics);
     Image queen = Properties.Resources.queen;
     int board_box_size = (int)(BoardPicBox.Width / size_);
     for (int i = 0; i < queen_location.Length; i++) {
         int x = i * board_box_size;
         int y = (queen_location[i] - 1) * board_box_size;
         graphics.DrawImage(queen, x, y, board_box_size, board_box_size);
     }
     graphics.Flush();
     fitnessTextBox.Text = String.Format("{0}", top_gene.Fitness());
 }