Exemplo n.º 1
0
 private void Mutation()
 {
     for (int i = _selectCount; i < _chromosomes.Count; i++)
     {
         Chromosome chr   = _chromosomes[i];
         int        index = _random.Next(0, _maxBit);
         chr.Value[index] = (chr.Value[index] + 1) % 2;
         OnMutationEvent?.Invoke(index, chr.Value);
     }
 }
Exemplo n.º 2
0
    private void ApplyMutation(Mutation mutation)
    {
        if (mutation.type == MutationType.WeaponMutationType)
        {
            WeaponMutation weaponMutation = mutation as WeaponMutation;
            SetWeaponType(weaponMutation.weapon);
        }
        else if (mutation.type == MutationType.StatsMutationType)
        {
            OnMutationEvent?.Invoke(mutation);
            StatsMutation statsMutation = mutation as StatsMutation;
            ApplyDeltaStats(statsMutation.modifiers);
        }

        Debug.Log($"Applied mutation: ${mutation.name}");
    }