예제 #1
0
        /// <summary>
        /// Mutates the genome. Bases the values on the winning genome
        /// </summary>
        public void MutateGenome()
        {
            //Base Random Genome off of the winning Genome with slight random modifications
            WinningGenome winningGenome = WinningGenome.GetWinningGenomeInstance();

            this.KingDangerValueGene = winningGenome.KingDangerValueGene + rng.Next(-3, 3);
            this.KingWorthGene       = winningGenome.KingWorthGene + rng.Next(-3, 3);
            this.PawnDangerValueGene = winningGenome.PawnDangerValueGene + rng.Next(-3, 3);
            this.PawnWorthGene       = winningGenome.PawnWorthGene + rng.Next(-3, 3);
        }
예제 #2
0
        /// <summary>
        /// Gets the winning genome instance.
        /// </summary>
        /// <returns>Return the winning genome instance</returns>
        public static WinningGenome GetWinningGenomeInstance()
        {
            if (instance == null)
            {
                lock (Lock)
                {
                    if (instance == null)
                    {
                        if (File.Exists(filepath))
                        {
                            instance = XmlSerializationHelper.Deserialize <WinningGenome>(filepath);
                        }
                        else
                        {
                            //create new file and save it
                            instance = new WinningGenome();
                            instance.Serialize(filepath);
                        }
                    }
                }
            }

            return(instance);
        }