//treat 0 as none even though its technically shield. private byte GetMutatedAttack(byte oldAttackId, EnemyObject enemy) { //likely that an attack with no associated animation will soft lock the game if (oldAttackId == 0 || oldAttackId == 255) { return(oldAttackId); } var doMutation = Agent.Rng.NextDouble(); if (doMutation > Agent.Probabilities.EnemyAttackMutationRate) { return(oldAttackId); } var attackTier = AttackTierList.GetAttackTier(oldAttackId); var newTier = RandomFunctions.GenerateGaussianByte(Agent.Rng, attackTier, 1, (byte)(AttackTierList.TieredAtpIds.Count - 1)); var changeType = Agent.Rng.NextDouble(); var oldType = AttackTierList.GetAttackType(oldAttackId); if (oldType == "") { return(oldAttackId); } var newType = GetNewType(oldType, Agent.Probabilities.EnemyAttackTypeMutationRate, newTier); List <int> attackList = AttackTierList.GetTierList(newType, newTier); var attackIndex = Agent.Rng.Next(0, attackList.Count); return((byte)attackList[attackIndex]); }
private string GetNewType(string oldType, double mutationRate, int tier) { var changeType = Agent.Rng.NextDouble(); if (changeType > mutationRate && AttackTierList.GetTierList(oldType, tier).Count > 0) { return(oldType); } double coinFlip = Agent.Rng.NextDouble(); var type = FlipType(oldType, coinFlip > 0.5); if (AttackTierList.GetTierList(type, tier).Count > 0) { return(type); } type = FlipType(oldType, coinFlip <= 0.5); if (AttackTierList.GetTierList(type, tier).Count > 0) { return(type); } return(oldType); }