This is an algorithm designed to find the best emote given the input text from the library of emotes.
The code is a module that you require, fire the function with a string and temperature, and it returns an animation if any from the library.
Model/Animation Library: IntelligentEmotes - Creator Store (roblox.com)
Bulk Animation Importer --Needed to Import all the animations in the library
Alternatively, you can implement this module to load animations without importing them all.
Custom LoadAnimation (Load any Animation) - Resources / Community Resources - Developer Forum | Roblox
Demonstration
–Code
local AnimationEngine = {}
local AnimationLibrary=script.AnimationsLibrary:GetChildren()
local SearchArray={}
local function splitString(str)
local words = {}
-- str=cm.Duplicates(str)
-- print(str)
if str~=nil then
if str:gmatch("%w+") then
for word in str:gmatch("%w+") do
word=word:lower()
table.insert(words, word)
end
end
end
if #words==0 then
return {str}
end
return words
end
for i,v in AnimationLibrary do
SearchArray[v]={splitString(v.Value.Value),math.random(75,125)/100}--assign random weight to each animation
end
--local RunService=game:GetService("RunService")
--local isLocal = RunService:IsClient()
--local proccessor=nil
--if isLocal then
-- proccessor=game.Players.LocalPlayer.PlayerGui:WaitForChild("Chatbot"):WaitForChild("LocalProcessor")
--else
-- proccessor=game.ReplicatedStorage.GlobalSpells.BindableFunction
--end
function AnimationEngine.Emotes(str,temperature)
--local synoms
local words=splitString(str)
--if proccessor then
--local synoms=--proccessor:Invoke("GetSynomArray",{words,true,false})
-- end
local count=0
local match=nil
local maximum=#words
local threshold=1/temperature
local noise=.1*temperature
local address=nil
if threshold>0 then
--for y,wordsg in synoms do --words of the npc
local rew=1
-- if string.find(y:lower(),"antonym") then
-- rew=-.5
-- end
for r,f in words do--for r,f in wordsg[1] do --words of the npc
for i,v in SearchArray do
local c=0
for t,o in v[1] do
if string.find(f,o) then
c+=rew+(noise*(math.random(75,100)/100*v[2]))
break -- only one match per synom group
end
end
if c>count and c>threshold then
count=c
match=i
address=i
end
end
end
-- end
end
if address~=nil then
SearchArray[address][2]=SearchArray[address][2]/1.2--adjust the weights to reduce chance of repetition
--guess it can learn the least used animation
end
return address -- return the animation object
end
--local iemotes=require(game.ServerScriptService.DeterminantAI.IntelligentEmotes)
return AnimationEngine
Backported from my most recent version.
Understanding Emotes: A Labeled Dataset Exploration
Introduction
Emotes play a crucial role in creating engaging and interactive experiences for players in Roblox games. As a developer, you want to provide a wide range of expressive animations that resonate with your audience. In this post, we’ll delve into an exciting dataset called “IntelligentEmotes,” which contains labeled emotes based on specific words or phrases.
The IntelligentEmotes Dataset
- Source: The IntelligentEmotes dataset is available in the Roblox Creator Store. It’s a treasure trove of character animations that can enhance your game’s emotional depth.
- Bulk Animation Importer: To make the most of this dataset, you’ll need the “Bulk Animation Importer.” This tool allows you to efficiently import all the animations from the library. You can configure it here.
- Randomly Weighted Animations: Each animation in the library has a random weight assigned to it. These weights influence the selection process when matching input text to emotes. The higher the weight, the more likely an animation will be chosen.
How the Algorithm Works
The heart of this system is the AnimationEngine
. Let’s break down its functionality:
- Input Text Processing:
- The algorithm takes input text (such as chat messages) and splits it into individual words.
- It converts all words to lowercase for consistency.
- Matching Process:
- For each word in the input, the algorithm searches the
AnimationLibrary
. - The
SearchArray
contains pairs of animation names and their associated split words. - A threshold (based on temperature) determines how closely a word must match to trigger an animation.
- Noise (controlled by temperature) introduces randomness to the selection process.
- Selecting the Best Emote:
- The algorithm accumulates weights for matching animations.
- If the accumulated weight surpasses the threshold, the corresponding animation becomes a candidate.
- The final emote is chosen from the candidates.
Conclusion
By leveraging the IntelligentEmotes dataset and the AnimationEngine, you can create dynamic and context-aware emotes for your Roblox game. Experiment with different thresholds and noise levels to fine-tune the system and provide an immersive experience for your players!