Skip to content

Instantly share code, notes, and snippets.

@simoninithomas
Created September 16, 2021 09:18
Show Gist options
  • Save simoninithomas/4efca52b03e0f3da7ccf0593d4b1d15e to your computer and use it in GitHub Desktop.
Save simoninithomas/4efca52b03e0f3da7ccf0593d4b1d15e to your computer and use it in GitHub Desktop.
JammoBehavior_Tutorial Part 3
/// <summary>
/// Utility function: Given the results of HuggingFace API, select the State with the highest score
/// </summary>
/// <param name="maxValue">Value of the option with the highest score</param>
/// <param name="maxIndex">Index of the option with the highest score</param>
private void Utility(float maxScore, int maxScoreIndex)
{
// First we check that the score is > of 0.3, otherwise we let our agent perplexed;
// This way we can handle strange input text (for instance if we write "Go see the dog!" the agent will be puzzled).
if (maxScore < 0.20f)
{
state = State.Puzzled;
}
else
{
// Get the verb and noun (if there is one)
goalObject = GameObject.Find(actionsList[maxScoreIndex].noun);
string verb = actionsList[maxScoreIndex].verb;
// Set the Robot State == verb
state = (State)System.Enum.Parse(typeof(State), verb, true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment