Пример #1
0
    public override CreatureAction ImperfectCopy(Creature targetCreature, float errorChance, float minDeviation, float maxDeviation)
    {
        var newMovement = new BasicMovement(targetCreature);

        newMovement._creatureSide = (Direction)ValueMutator.MutateFlat((int)_creatureSide, errorChance, -1, 1);

        return(newMovement);
    }
Пример #2
0
    public override void DoOutput(float outputStrength)
    {
        _creature.UseEnergy(NetworkSettings.BaseActionCost);

        if (outputStrength > 0.5f || _creature.CanReplicate() == false)
        {
            return;
        }

        Debug.Log("Creature cloned");

        _creature.UseEnergy(_creature._startingEnergy - (_creature._startingEnergy) * 0.1f);

        var activeWorld   = WorldSettings.ActiveWorld;
        var activeNetwork = NetworkSettings.ActiveNetwork;
        var linkManager   = WorldSettings.LinkManager;

        int oldNetworkID = linkManager.GetNetworkID(_creature.ID);
        var oldNetwork   = activeNetwork.GetNetwork(oldNetworkID);

        var newNetwork = oldNetwork.CloneNetwork(0.05f);

        float mass   = linkManager.GetNetworkMass(newNetwork.Inputs.Length, newNetwork.Outputs.Length, newNetwork.HiddenLayer.Length);
        float energy = linkManager.GetNetworkEnergy(newNetwork.Inputs.Length, newNetwork.Outputs.Length, newNetwork.HiddenLayer.Length);

        var creature = activeWorld.CreateNewCreature(mass, energy, ValueMutator.MutateFlat(_creature.Color, 0.05f, -0.1f, 0.1f));

        if (PlaceCreature(creature) == false)
        {
            return;
        }

        newNetwork.UpdateTargetCreature(creature);

        var networkID = activeNetwork.AddNetwork(newNetwork);

        linkManager.AddLink(creature, networkID);
    }