public void setRadius(float r) { if (r > minRadius) { radius = r; } else { radius = minRadius; } radius2 = radius * radius; //oomph has a max, burden has a min, both dependent on radius^2 burden = naiveBurden; maxOomph = CScommon.maxOomph(radius); minBurden = naiveBurden * minBurdenMultiplier; }
public void bless(Node target) { if (this.org == target.org) { return; //don't bless self--decreaseOomph below increases effect of decreaseHunger } float thisSends = Mathf.Min(target.hunger(), this.oomph / 2); //donate half of what you've got float targetReceives = thisSends * linkEfficiency(this, target); this.oomph -= thisSends; target.oomph += targetReceives; if (CScommon.testBit(target.dna, CScommon.goalBit) && target.teamNumber == this.teamNumber) { Score.addToProductivity(this.id, targetReceives); //I only get credit for what they receive } }
//the oomph that this particular muscle can actually put to work (some is wasted in inefficiency) // units: is oomp is d*b public float strength() { return(demand * CScommon.efficiency(length2(), source.radius2)); }
public float efficiency() { return(CScommon.efficiency(source.distance2(target), source.radius2)); }
//cuts links from this organism to loser organism // private void cutOrgsMusclesToOrg(Org org){ // foreach (var memb in org.members) memb.cutMusclesTargetingOrg(org); // } public bool isEater() { return(CScommon.testBit(dna, CScommon.eaterBit) && !org.isServant()); }
// the efficiency of a link between the two nodes. // public, and not a link method, so that bots can determine which potential muscles would be most efficient // This is independent of metabolicOutput--the node's ability to supply the link with oomph. // It is wholly a function of link length AND the source's radius--so linkEfficiency is NOT symmetric public static float linkEfficiency(Node source, Node target) { return(CScommon.efficiency(distance2(source, target), source.radius2)); }