public static DInput isHurt(ResourceFightDNCreature p_cre) { DActivationFunction activate = ActivationFactory.generateSigmoid(1, 1, false, true, true); return(() => { return activate(p_cre.m_health.Value / p_cre.m_health.Max); }); }
public static void activate(DActivationFunction activator, Matrix <float> p_matrix) { for (int i = 0; i < p_matrix.RowCount; i++) { for (int j = 0; j < p_matrix.ColumnCount; j++) { p_matrix[i, j] = activator(p_matrix[i, j]); } } }
//Resource public static DInput isHungry(ResourceFightDNCreature p_cre) { DActivationFunction activate = ActivationFactory.generateSigmoid(1, 1, false, true, true); return(() => { //Debug.Log(p_cre.m_energy.Value + " : " + activate(p_cre.m_energy.Value/p_cre.m_energy.Max)); return activate(p_cre.m_energy.Value / p_cre.m_energy.Max); }); }
public static DInput bulletsUpAhead(ResourceFightDNCreature p_cre) { DActivationFunction activate = ActivationFactory.generateSigmoid(5, 1, false, true, false); return(() => { GameObject[] bullets = p_cre.sense("BULLET"); // Debug.Log(bullets.Length + " : " + activate(bullets.Length)); return activate(bullets.Length); }); }
public void brainAction() { Matrix <float> current_matrix = getInputValueMatrix() * m_weights[0]; DActivationFunction activator = ActivationFactory.generateSigmoid(2, 2, true, false, false); MatrixCalc.activate(activator, current_matrix); for (int i = 1; i < m_weights.Length; i++) { current_matrix = current_matrix * m_weights[i]; MatrixCalc.activate(activator, current_matrix); } performOutputs(current_matrix); }
//Dodging public static DInput bulletCollisionImminent(ResourceFightDNCreature p_cre) { DActivationFunction prox_activate = ActivationFactory.generateSigmoid(1.5f, 2, false, true, true); DActivationFunction angle_activate = ActivationFactory.generateSigmoid(10f, 2, false, true, true); DActivationFunction full_activate = ActivationFactory.generateSigmoid(1, 1, false, true, false); return(() => { GameObject[] bullets = p_cre.sense("BULLET"); List <GameObject> bullets_close_and_coming_towards = new List <GameObject>(); foreach (GameObject bul in bullets) { if (Vector2Calc.proximity(bul.transform.position, p_cre.transform.position) < 2 && Vector2Calc.checkAngle(p_cre.transform.position - bul.transform.position, bul.GetComponent <Rigidbody2D>().velocity, 10)) { bullets_close_and_coming_towards.Add(bul); } } float activation = 0; foreach (GameObject bul in bullets_close_and_coming_towards) { float bul_prox = prox_activate(Vector2Calc.proximity(bul.transform.position, p_cre.transform.position) - 0.5f); float bul_angle = angle_activate(Mathf.Abs(Vector2Calc.getAngle(p_cre.transform.position - bul.transform.position, bul.GetComponent <Rigidbody2D>().velocity))); float bul_active = full_activate(bul_prox * bul_angle); if (bul_active > activation) { activation = bul_active; } } //if(activation >0 ) Debug.Log(activation); return activation; }); }
public static DInput isStronger(ResourceFightDNCreature p_cre) { DActivationFunction activate = ActivationFactory.generateSigmoid(1f, 1, false, true, false); return(() => { GameObject closest = p_cre.senseClosest("CREATURE"); if (closest == null) { return 0; } ResourceFightDNCreature enemy = closest.GetComponent <ResourceFightDNCreature>(); float strength_check = (p_cre.m_health.Value + (p_cre.m_damage * 5)) / (enemy.m_health.Value + (enemy.m_damage * 5)); //Debug.Log( "[" + strength_check +"] " + activate( strength_check-0.5f ) ); return activate(strength_check - 0.5f); //Your mesure of toughness/ enemy mesure of toughness set up so double enemy gives 0 and half enemy 1 }); }