protected override bool DidTrainingUnitComplete(ref bool wasUnitSuccessful) { float tolerance = TSHints[ERROR_TOLERANCE]; float sin = RelativeSin(m_target.GetGeometry().Location, m_agent.GetGeometry().Location); float cos = RelativeCos(m_target.GetGeometry().Location, m_agent.GetGeometry().Location); //Console.WriteLine(sin); //Console.WriteLine(cos); sin = (sin + 1) / 2; cos = (cos + 1) / 2; //Console.WriteLine(sin); //Console.WriteLine(cos); if ((sin - tolerance <= WrappedWorld.Controls.Host[0] && WrappedWorld.Controls.Host[0] <= sin + tolerance) && (cos - tolerance <= WrappedWorld.Controls.Host[1] && WrappedWorld.Controls.Host[1] <= cos + tolerance)) { wasUnitSuccessful = true; } else { wasUnitSuccessful = false; } // TODO: Partial reward //Console.WriteLine(wasUnitSuccessful); return(true); }
public override void PresentNewTrainingUnit() { m_stepCount = 0; // Scale the noise in the world base on randomness_level { float randomness = TSHints[RANDOMNESS_LEVEL]; WrappedWorld.ImageNoiseStandardDeviation = 7 * randomness * randomness; } int noObjects = (int)TSHints[TSHintAttributes.NUMBER_OF_DIFFERENT_OBJECTS]; // Generate an artificial invisible agent m_agent = WrappedWorld.CreateNonVisibleAgent(); PointF agentPos = m_agent.GetGeometry().Location; m_agent.GameObjectStyle = GameObjectStyleType.None; // Prevent reseting movement vector when colliding with something from the top (default style is Platformer) // Generate shapes around the agent CreateTargets(noObjects, agentPos); // Pick one target and duplicate it in the pow center m_pickIdx = m_rndGen.Next(noObjects); var pick = m_targets[m_pickIdx]; Color color = TSHints[TSHintAttributes.IS_VARIABLE_COLOR] > 0 ? LearningTaskHelpers.RandomVisibleColor(m_rndGen) : pick.ColorMask; m_question = WrappedWorld.CreateShape((Shape.Shapes)m_shapeIdcs[m_pickIdx], color, agentPos, pick.Size); }