public NPCNest(NPCNestDNA dna, double radius, World world, Map map, KeepItems2D keepItems2D, MaterialIDs materialIDs, Viewport3D viewport, EditorOptions editorOptions, ItemOptionsArco itemOptions, IGravityField gravity, DragHitShape dragPlane) { // Store stuff _world = world; _map = map; _keepItems2D = keepItems2D; _materialIDs = materialIDs; _viewport = viewport; _editorOptions = editorOptions; _itemOptions = itemOptions; _gravity = gravity; _dragPlane = dragPlane; // DNA NPCNestDNA fixedDNA = GetFinalDNA(dna); _shellColors = fixedDNA.ShellColors; _botDNA = fixedDNA.BotDNA; _weaponDNA = fixedDNA.WeaponDNA; //TODO: Hand this a winner list, and filter criteria _dreamer = new EvolutionDreamer(_itemOptions, _shellColors, 4); //TODO: Num bots should come from item options _dreamer.WeaponDNA = EvolutionDreamer.GetRandomDNA().Item2; #region WPF Model var models = GetModel(_shellColors, radius); this.Model = models.Item1; _eggModels = models.Item2; _rotateTransform = new QuaternionRotation3D(); _translateTransform = new TranslateTransform3D(); Transform3DGroup transform = new Transform3DGroup(); transform.Children.Add(new RotateTransform3D(_rotateTransform)); transform.Children.Add(_translateTransform); ModelVisual3D visual = new ModelVisual3D(); visual.Transform = transform; visual.Content = this.Model; this.Visuals3D = new Visual3D[] { visual }; #endregion // Energy tank _energy = new Container(); _energy.QuantityMax = _itemOptions.Nest_Energy_Max * radius; _energy.QuantityCurrent = _energy.QuantityMax * .5d; // Finish this.Token = TokenGenerator.NextToken(); this.Radius = radius; this.CreationTime = DateTime.UtcNow; }
private NPCNestDNA GetFinalDNA(NPCNestDNA dna) { // Main instance NPCNestDNA retVal; if (dna == null) { retVal = new NPCNestDNA(); } else { retVal = UtilityCore.Clone(dna); } // Colors if (retVal.ShellColors == null) { retVal.ShellColors = BotShellColorsDNA.GetRandomColors(); } //if (retVal.BotDNA == null) //{ // //TODO: don't hardcode so much // retVal.BotDNA = new BotDNA() // { // ShellColors = retVal.ShellColors, // DraggingMaxVelocity = StaticRandom.NextPercent(5, .25), // DraggingMultiplier = StaticRandom.NextPercent(20, .25), // Parts = new PartDNA[] // { // new PartDNA() { PartType = SensorVision.PARTTYPE, Position = new Point3D(0, 0, 1.5), Orientation = Quaternion.Identity, Scale = new Vector3D(1, 1, 1) }, // new PartDNA() { PartType = Brain.PARTTYPE, Position = new Point3D(0, 0, 0), Orientation = Quaternion.Identity, Scale = new Vector3D(1, 1, 1) }, // new PartDNA() { PartType = MotionController_Linear.PARTTYPE, Position = new Point3D(0, 0, -1.5), Orientation = Quaternion.Identity, Scale = new Vector3D(1, 1, 1) }, // } // }; // //NOTE: Letting the bot create random neural links. Once this nest has a few winners, it won't need to be creating new random ones anymore //} //if (retVal.WeaponDNA == null) //{ // WeaponHandleMaterial[] weaponMaterials = new WeaponHandleMaterial[] { WeaponHandleMaterial.Soft_Wood, WeaponHandleMaterial.Hard_Wood }; // retVal.WeaponDNA = WeaponHandleDNA.GetRandomDNA(weaponMaterials[StaticRandom.Next(weaponMaterials.Length)]); //} return retVal; }