void Start() { dnas = new ArrayList(1); fitness_data = new ArrayList(1); float[] valores = new float[14]; valores[(int)ProjectileDNANames.PROJECTILE_TIME] = 3.0f; valores[(int)ProjectileDNANames.PROJECTILE_SPEED] = 5; valores[(int)ProjectileDNANames.X_EXTRA_ACCELERATION] = 0; valores[(int)ProjectileDNANames.X_OFFSET] = 0; valores[(int)ProjectileDNANames.X_SIZE] = 2; valores[(int)ProjectileDNANames.X_TELEGUIDING] = 0; valores[(int)ProjectileDNANames.Y_EXTRA_ACCELERATION] = 0; valores[(int)ProjectileDNANames.Y_OFFSET] = 0; valores[(int)ProjectileDNANames.Y_SIZE] = 2; valores[(int)ProjectileDNANames.Y_TELEGUIDING] = 0; valores[(int)ProjectileDNANames.Z_EXTRA_ACCELERATION] = 0; valores[(int)ProjectileDNANames.Z_OFFSET] = 0; valores[(int)ProjectileDNANames.Z_SIZE] = 2; valores[(int)ProjectileDNANames.Z_TELEGUIDING] = 0; AnvilProjectileDNA starter_dna = new AnvilProjectileDNA(valores); dnas.Add(starter_dna); fitness_data.Add(new AnvilProjectileFitnessData()); }
AnvilProjectileDNA SwapValues() { float position_1; float position_2; position_1 = Random.Range(0, 14); if (position_1 > 13) { position_1 = 13; } do { position_2 = Random.Range(0, 14); if (position_1 > 13) { position_1 = 13; } } while ((int)position_1 == (int)position_2); AnvilProjectileDNA new_dna = (AnvilProjectileDNA) GetComponent <AnvilBrainResults>().dnas[GetComponent <AnvilBrainResults>().best_dna]; float change = new_dna.projectile_DNA[(int)position_1]; new_dna.projectile_DNA[(int)position_1] = new_dna.projectile_DNA[(int)position_2]; new_dna.projectile_DNA[(int)position_2] = change; return(new_dna); }
AnvilProjectileDNA AddValueToDNA() { float random_result = Random.Range(0, 1); if (random_result <= plus_randomization_change) { max_or_min = 1; } else { max_or_min = -1; } random_result = Random.Range(0, max_value_to_add); float value_to_add = random_result; value_to_add *= max_or_min; random_result = Random.Range(0, 14); if (random_result > 13) { random_result = 13; } int wheres_the_best_dna = GetComponent <AnvilBrainResults>().best_dna; AnvilProjectileDNA new_dna = (AnvilProjectileDNA) GetComponent <AnvilBrainResults>().dnas[wheres_the_best_dna]; new_dna.projectile_DNA[(int)random_result] += value_to_add; return(new_dna); }
public void ShootsProjectile(AnvilProjectileDNA dna) { GameObject new_projectile = (GameObject)Resources.Load("Prefabs/Anvil Projectile"); new_projectile.GetComponent <AnvilProjectileDNA>().projectile_DNA = dna.projectile_DNA; Instantiate(new_projectile); new_projectile.GetComponent <AnvilProjectileDestructionData>().how_many_seconds_it_should_exist = dna.projectile_DNA[(int)Support.ProjectileDNANames.PROJECTILE_TIME]; }
public void TrimLists() { AnvilProjectileDNA dna = (AnvilProjectileDNA)dnas[best_dna]; float fitness = best_fitness; if (fitness > ((AnvilProjectileFitnessData)fitness_data[best_dna]).fitness) { fitness = ((AnvilProjectileFitnessData)fitness_data[best_dna]).fitness; } dnas = new ArrayList(1); dnas.Add(dna); best_dna = 0; best_fitness = fitness; }
// Use this for initialization void Start() { Vector3 scale = new Vector3(0, 0, 0); player = GameObject.FindGameObjectWithTag("Player"); dna = GetComponent <AnvilProjectileDNA>(); target_initial_position = player.transform.position; target_initial_distance = target_initial_position - transform.position; target_step = target_initial_distance / Mathf.Sqrt(target_initial_distance.x * target_initial_distance.x + target_initial_distance.y * target_initial_distance.y + target_initial_distance.z * target_initial_distance.z); scale.x = dna.projectile_DNA[(int)ProjectileDNANames.X_SIZE]; scale.y = dna.projectile_DNA[(int)ProjectileDNANames.Y_SIZE]; scale.z = dna.projectile_DNA[(int)ProjectileDNANames.Z_SIZE]; transform.localScale = scale; acceleration = new Vector3(0, 0, 0); }