New basic signs model
This commit is contained in:
committed by
Jelle De Geest
parent
06aa9206ac
commit
43887af670
@@ -354,108 +354,9 @@ public partial class SpellingBeeController : AbstractMinigameController
|
||||
private float GetTresholdPercentage(string sign)
|
||||
{
|
||||
Learnable letter = fingerspelling.learnables.Find(l => l.name == sign);
|
||||
return letter.thresholdPercentage;
|
||||
return letter.thresholdDistance;
|
||||
}
|
||||
/*
|
||||
/// <summary>
|
||||
/// The updateFunction that is called when new probabilities become available
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected override IEnumerator UpdateFeedback()
|
||||
{
|
||||
// Get current sign
|
||||
string currentSign = GetSign();
|
||||
// Get the predicted sign
|
||||
if (signPredictor != null && signPredictor.learnableProbabilities != null &&
|
||||
currentSign != null && signPredictor.learnableProbabilities.ContainsKey(currentSign) && gameIsActive)
|
||||
{
|
||||
float accCurrentSign = signPredictor.learnableProbabilities[currentSign];
|
||||
float thresholdCurrentSign = GetTresholdPercentage(currentSign);
|
||||
|
||||
// Get highest predicted sign
|
||||
string predictedSign = signPredictor.learnableProbabilities.Aggregate((a, b) => a.Value > b.Value ? a : b).Key;
|
||||
float accPredictSign = signPredictor.learnableProbabilities[predictedSign];
|
||||
float thresholdPredictedSign = GetTresholdPercentage(predictedSign);
|
||||
|
||||
if (feedbackText != null && feedbackProgressImage != null)
|
||||
{
|
||||
Color col;
|
||||
if (accCurrentSign > thresholdCurrentSign)
|
||||
{
|
||||
feedbackText.text = "Goed";
|
||||
col = new Color(0x8b / 255.0f, 0xd4 / 255.0f, 0x5e / 255.0f);
|
||||
}
|
||||
else if (accCurrentSign > 0.9 * thresholdCurrentSign)
|
||||
{
|
||||
feedbackText.text = "Bijna...";
|
||||
col = new Color(0xf2 / 255.0f, 0x7f / 255.0f, 0x0c / 255.0f);
|
||||
}
|
||||
else if (accPredictSign > thresholdPredictedSign)
|
||||
{
|
||||
feedbackText.text = $"Verkeerde gebaar: '{predictedSign}'";
|
||||
col = new Color(0xf5 / 255.0f, 0x49 / 255.0f, 0x3d / 255.0f);
|
||||
accCurrentSign = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
feedbackText.text = "Detecteren...";
|
||||
col = new Color(0xf5 / 255.0f, 0x49 / 255.0f, 0x3d / 255.0f);
|
||||
}
|
||||
|
||||
feedbackText.color = col;
|
||||
feedbackProgressImage.color = col;
|
||||
|
||||
float oldValue = feedbackProgress.value;
|
||||
// use an exponential scale
|
||||
float newValue = Mathf.Exp(4 * (Mathf.Clamp(accCurrentSign / thresholdCurrentSign, 0.0f, 1.0f) - 1.0f));
|
||||
feedbackProgress.gameObject.Tween("FeedbackUpdate", oldValue, newValue, 0.2f, TweenScaleFunctions.CubicEaseInOut, (t) =>
|
||||
{
|
||||
if (feedbackProgress != null)
|
||||
{
|
||||
feedbackProgress.value = t.CurrentValue;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (accPredictSign > thresholdPredictedSign)
|
||||
{
|
||||
// Correct sign
|
||||
if (predictedSign == currentSign)
|
||||
{
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
PredictSign(predictedSign);
|
||||
timer = DateTime.Now;
|
||||
predictedSign = null;
|
||||
previousIncorrectSign = null;
|
||||
}
|
||||
// Incorrect sign
|
||||
else
|
||||
{
|
||||
if (previousIncorrectSign != predictedSign)
|
||||
{
|
||||
timer = DateTime.Now;
|
||||
previousIncorrectSign = predictedSign;
|
||||
}
|
||||
else if (DateTime.Now - timer > TimeSpan.FromSeconds(2.0f))
|
||||
{
|
||||
PredictSign(predictedSign);
|
||||
timer = DateTime.Now;
|
||||
predictedSign = null;
|
||||
previousIncorrectSign = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if (feedbackProgress != null)
|
||||
{
|
||||
|
||||
feedbackProgress.value = 0.0f;
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Function to get the current letter that needs to be signed
|
||||
/// </summary>
|
||||
@@ -487,11 +388,11 @@ public partial class SpellingBeeController : AbstractMinigameController
|
||||
/// </summary>
|
||||
/// <param name="accuracy">The accuracy of the passed sign</param>
|
||||
/// <param name="predictedSign">The name of the passed sign</param>
|
||||
protected override void ProcessMostProbableSign(float accuracy, string predictedSign)
|
||||
protected override void ProcessMostProbableSign(float distance, string predictedSign)
|
||||
{
|
||||
string currentSign = GetSign();
|
||||
float accPredictSign = accuracy;
|
||||
float accCurrentSign = signPredictor.learnableProbabilities[currentSign];
|
||||
float distPredictSign = distance;
|
||||
float distCurrentSign = signPredictor.learnableProbabilities[currentSign];
|
||||
float thresholdCurrentSign = GetTresholdPercentage(currentSign);
|
||||
float thresholdPredictedSign = GetTresholdPercentage(predictedSign);
|
||||
|
||||
@@ -499,21 +400,20 @@ public partial class SpellingBeeController : AbstractMinigameController
|
||||
if (feedbackText != null && feedbackProgressImage != null)
|
||||
{
|
||||
Color col;
|
||||
if (accPredictSign > thresholdCurrentSign)
|
||||
if (distCurrentSign < thresholdCurrentSign)
|
||||
{
|
||||
feedbackText.text = "Goed";
|
||||
col = new Color(0x8b / 255.0f, 0xd4 / 255.0f, 0x5e / 255.0f);
|
||||
}
|
||||
else if (accCurrentSign > 0.9 * thresholdCurrentSign)
|
||||
else if (distCurrentSign < 1.5 * thresholdCurrentSign)
|
||||
{
|
||||
feedbackText.text = "Bijna...";
|
||||
col = new Color(0xf2 / 255.0f, 0x7f / 255.0f, 0x0c / 255.0f);
|
||||
}
|
||||
else if (accPredictSign > thresholdPredictedSign)
|
||||
else if (distPredictSign < thresholdPredictedSign)
|
||||
{
|
||||
feedbackText.text = $"Verkeerde gebaar: '{predictedSign}'";
|
||||
col = new Color(0xf5 / 255.0f, 0x49 / 255.0f, 0x3d / 255.0f);
|
||||
accCurrentSign = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -526,7 +426,7 @@ public partial class SpellingBeeController : AbstractMinigameController
|
||||
|
||||
float oldValue = feedbackProgress.value;
|
||||
// use an exponential scale
|
||||
float newValue = Mathf.Exp(4 * (Mathf.Clamp(accCurrentSign / thresholdCurrentSign, 0.0f, 1.0f) - 1.0f));
|
||||
float newValue = 1 - Mathf.Clamp(distCurrentSign - thresholdCurrentSign, 0.0f, 3.0f) / 3;
|
||||
feedbackProgress.gameObject.Tween("FeedbackUpdate", oldValue, newValue, 0.2f, TweenScaleFunctions.CubicEaseInOut, (t) =>
|
||||
{
|
||||
if (feedbackProgress != null)
|
||||
@@ -537,7 +437,7 @@ public partial class SpellingBeeController : AbstractMinigameController
|
||||
}
|
||||
|
||||
// The logic for the internal workings of the game
|
||||
if (accPredictSign > thresholdPredictedSign)
|
||||
if (distPredictSign < thresholdPredictedSign)
|
||||
{
|
||||
// Correct sign, instantly pass it along
|
||||
if (predictedSign == currentSign)
|
||||
|
||||
Reference in New Issue
Block a user