private Creature CreateCreature(int numSensors, int numActions) { var creature = _activeWorld.CreateNewCreature(10, 30000); int xPos = Random.Range(0, WorldSettings.WorldWidth); int yPos = Random.Range(0, WorldSettings.WorldHeight); do { xPos = Random.Range(0, WorldSettings.WorldWidth); yPos = Random.Range(0, WorldSettings.WorldHeight); } while (_activeWorld.GetTileAt(xPos, yPos).ContainsCreature()); creature.MoveTo(xPos, yPos); _activeWorld.AddCreatureToWorld(creature); var sensors = new CreatureSensor[numSensors]; var actions = new CreatureAction[numActions]; actions[0] = new DNACloner(creature); for (int i = 0; i < numSensors; i++) { var random = Random.Range(0, _creatureSensors.Length); sensors[i] = _creatureSensors[random].PerfectCopy(creature); sensors[i].RandomizeVariables(); } for (int i = 1; i < numActions; i++) { var random = Random.Range(0, _creatureActions.Length); actions[i] = _creatureActions[random].PerfectCopy(creature); actions[i].RandomizeVariables(); } int networkID = _networkManager.AddNetwork(sensors, actions, 50); _linkManager.AddLink(creature, networkID); return(creature); }
private void SpawnTestCreature() { var creature = _activeWorld.CreateNewCreature(10, 30000, Color.black); creature.MoveTo(Camera.main.ScreenToWorldPoint(Input.mousePosition)); _activeWorld.AddCreatureToWorld(creature); var sensors = new CreatureSensor[] { new RandomizeSensor(creature) }; var actions = new CreatureAction[] { new Mouth(creature) }; int networkID = _networkManager.AddNetwork(sensors, actions, 50); _linkManager.AddLink(creature, networkID); }