public void test_vector() { _log.enterScope(); UtilityVector vec1 = new UtilityVector(0, 1, 2, 3, 4, 5); float mag = vec1.magnitude; _log.logDebug("mag: " + mag); Verify.VerifyTrue("verify mag gte 0", true, mag >= 0); Verify.VerifyTrue("norm is not null", true, vec1.normalize() != null); UtilityVector vec2 = new UtilityVector(5, 4, 3, 2, 1, 0); float dot = vec1.dot(vec2); _log.logDebug("dot: " + dot); Verify.VerifyTrue("dot between 1 and -1", true, (dot <= 1) && (dot >= -1)); dot = vec1.dot(vec1); _log.logDebug("self dot: " + dot); Verify.VerifyTrue("dot with itself should be 1", true, dot == 1); _log.exitScope(); }
public void test_vector(){ _log.enterScope (); UtilityVector vec1 = new UtilityVector (0, 1, 2, 3, 4, 5); float mag = vec1.magnitude; _log.logDebug ("mag: " + mag); Verify.VerifyTrue ("verify mag gte 0", true, mag >= 0); Verify.VerifyTrue ("norm is not null", true, vec1.normalize () != null); UtilityVector vec2 = new UtilityVector (5, 4, 3, 2, 1, 0); float dot = vec1.dot (vec2); _log.logDebug ("dot: " + dot); Verify.VerifyTrue ("dot between 1 and -1", true, (dot <= 1) && (dot >= -1)); dot = vec1.dot (vec1); _log.logDebug ("self dot: " + dot); Verify.VerifyTrue ("dot with itself should be 1", true, dot == 1); _log.exitScope (); }
public BehaviorReturnCode Behave(Entity entity) { try{ UtilityVector func_vector = this._utility_function(); float min = -2.0f; UtilityPair best_match = null; //find max pair match foreach (UtilityPair pair in this._utility_pairs) { float val = func_vector.dot(pair.vector); if (val > min) { min = val; best_match = pair; } } //make sure we found a match if (best_match == null) { #if DEBUG Console.WriteLine("best_match not defined..."); #endif this.ReturnCode = BehaviorReturnCode.Failure; return(this.ReturnCode); } //execute best pair match and return result this.ReturnCode = best_match.behavior.Behave(entity); return(this.ReturnCode); }catch (Exception e) { #if DEBUG Console.WriteLine(e.ToString()); #endif this.ReturnCode = BehaviorReturnCode.Failure; return(BehaviorReturnCode.Failure); } }