using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Crossover
{
    public partial class Form1 : Form
    {
        Individual parentA, parentB, theChild;
        Individual[] population;
        int size = 90;
        int parentAIndex, parentBIndex;
        public Form1()
        {
            InitializeComponent();
            //testing v1 and v2 and v4
            /*parentA = new Individual(parent1.Width, parent1.Height);
            parent1.Image = parentA.TheImage;

            parentB = new Individual(parent2.Width, parent2.Height);
            parent2.Image = parentB.TheImage;

            theChild = new Individual(child.Width, child.Height);*/

            //testing v3 and v5
            population = new Individual[size];
            for(int i = 0; i < size; i++)
            {
                population[i] = new Individual(parent1.Width, parent1.Height);
            }
            parentAIndex = RndNumGen.Next(0, size);
            parentBIndex = RndNumGen.Next(0, size);
            while(parentBIndex == parentAIndex)
                parentBIndex = RndNumGen.Next(0, size);
            Console.WriteLine("parentA index: " + parentAIndex);
            Console.WriteLine("parentB index: " + parentBIndex);
            parentA = new Individual(population[parentAIndex], parent1.Width, parent1.Height);
            parentB = new Individual(population[parentBIndex], parent2.Width, parent2.Height);

            theChild = new Individual(child.Width, child.Height);

            parent1.Image = parentA.TheImage;
            parent2.Image = parentB.TheImage;
        }
        private void btnClick(object sender, EventArgs e)
        {
            Console.WriteLine("entering btnClick");
            //theChild.crossoverV1(parentA, parentB);
            //theChild.crossoverV2(parentA, parentB);

            theChild.crossoverIndividual(parentA, parentB);
            child.Image = theChild.TheImage;
            Console.WriteLine("leaving btnClick");
        }
    }
}
