private static void aggiungirob(IRobotManager robotManager, IBucketManager bucketManager) { if (!SimOpt.SimOpts.Specie.Any(s => CheckVegStatus(robotManager, s))) { return; } int r; do { r = ThreadSafeRandom.Local.Next(0, SimOpt.SimOpts.Specie.Count); // start randomly in the list of species } while (!CheckVegStatus(robotManager, SimOpt.SimOpts.Specie[r])); var x = ThreadSafeRandom.Local.Next(Robot.RobSize / 2, SimOpt.SimOpts.FieldWidth - Robot.RobSize / 2); var y = ThreadSafeRandom.Local.Next(Robot.RobSize / 2, SimOpt.SimOpts.FieldHeight - Robot.RobSize / 2); if (SimOpt.SimOpts.Specie[r].Name == "" || SimOpt.SimOpts.Specie[r].Path == "Invalid Path") { return; } var a = DnaManipulations.RobScriptLoad(robotManager, bucketManager, System.IO.Path.Join(SimOpt.SimOpts.Specie[r].Path, SimOpt.SimOpts.Specie[r].Name)); if (a == null) { SimOpt.SimOpts.Specie[r].Native = false; return; } //Check to see if we were able to load the bot. If we can't, the path may be wrong, the sim may have //come from another machine with a different install path. Set the species path to an empty string to //prevent endless looping of error dialogs. if (!a.Exists) { SimOpt.SimOpts.Specie[r].Path = "Invalid Path"; return; } a.IsVegetable = SimOpt.SimOpts.Specie[r].Veg; if (a.IsVegetable) { a.Chloroplasts = SimOptions.StartChlr; } a.IsFixed = SimOpt.SimOpts.Specie[r].Fixed; a.CantSee = SimOpt.SimOpts.Specie[r].CantSee; a.DnaDisabled = SimOpt.SimOpts.Specie[r].DisableDna; a.MovementSysvarsDisabled = SimOpt.SimOpts.Specie[r].DisableMovementSysvars; a.CantReproduce = SimOpt.SimOpts.Specie[r].CantReproduce; a.IsVirusImmune = SimOpt.SimOpts.Specie[r].VirusImmune; a.IsCorpse = false; a.IsDead = false; a.Body = 1000; a.Mutations = 0; a.OldMutations = 0; a.LastMutation = 0; a.SonNumber = 0; a.Parent = null; Array.Clear(a.Memory, 0, a.Memory.Length); if (a.IsFixed) { a.Memory[216] = 1; } a.Position = new DoubleVector(x, y); a.Aim = ThreadSafeRandom.Local.NextDouble() * Math.PI * 2; a.Memory[MemoryAddresses.SetAim] = (int)a.Aim * 200; //Bot is already in a bucket due to the prepare routine bucketManager.UpdateBotBucket(a); a.Energy = SimOpt.SimOpts.Specie[r].Stnrg; a.MutationProbabilities = SimOpt.SimOpts.Specie[r].Mutables; a.VirusTimer = 0; a.VirusShot = null; a.NumberOfGenes = DnaManipulations.CountGenes(a.Dna); a.GenMut = (double)a.Dna.Count / RobotsManager.GeneticSensitivity; a.Memory[MemoryAddresses.DnaLenSys] = a.Dna.Count; a.Memory[MemoryAddresses.GenesSys] = a.NumberOfGenes; a.ChloroplastsDisabled = SimOpt.SimOpts.Specie[r].NoChlr; for (var i = 0; i < 7; i++) { a.Skin[i] = SimOpt.SimOpts.Specie[r].Skin[i]; } a.Color = SimOpt.SimOpts.Specie[r].Color; Senses.MakeOccurrList(a); }