Skip to content

Commit fb8be7e

Browse files
committed
Implemented Sentimental Reponse and Emotional State MAchine:
1 parent 8ab57d1 commit fb8be7e

2 files changed

Lines changed: 37 additions & 3 deletions

File tree

AI_AgentModel.vb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
Imports System.Runtime.Remoting.Messaging
22
Imports AI_Contracts
33
Public Class AI_AgentModel
4+
'ShortTerm Memory
45
Private PreviousResponses As List(Of String)
56
Private PreviousUserInputs As List(Of String)
7+
8+
'Working Memory
69
Public PreviousResponse As String
710
Public PreviousUserInput As String
811
Public UserInput As String
912
Public Response As String
10-
Private PLUGIN_FOLDER As String = Application.StartupPath & "\Plugins"
11-
1213

14+
Private PLUGIN_FOLDER As String = Application.StartupPath & "\Plugins"
15+
Public Sentiment As New Emotional_State
1316

1417
'Responses Are Genearated Externally
1518
#Region "Responses"
@@ -23,8 +26,16 @@ Public Class AI_AgentModel
2326
GET_RESPONSE = GetPluginResponse(UserInput, PreviousUserInput, PreviousResponse)
2427
'IF NO RESPONSE TRY - Question Answer Database
2528
If GET_RESPONSE = "" Then GetQAResponse(UserInput, GET_RESPONSE)
29+
'TRY EMOTIONAL RESPONSE
30+
If GET_RESPONSE = "" And Sentiment.NewEmotionDetected(UserInput) = True Then Sentiment.MakeEmotionalResponse()
2631
'IF No Response Fallback Response
2732
If GET_RESPONSE = "" Then GET_RESPONSE = "Excuse me? Please, Rephrase?"
33+
34+
'MainTain History
35+
PreviousUserInput = UserInput
36+
PreviousResponse = GET_RESPONSE
37+
PreviousUserInputs.Add(PreviousUserInput)
38+
PreviousResponses.Add(PreviousResponse)
2839
End Function
2940
Private Function GetPluginResponse(ByRef UserInput As String, ByRef PrevUSerInput As String, ByRef PrevResponse As String) As String
3041
GetPluginResponse = ExecutePlugins(UserInput, ScanPlugins)

Emotion_Handler.vb

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,30 @@
4646
MakeEmotionalResponse = "" & LCase(FoundEmotion) & " "
4747
End Select
4848
End Function
49-
49+
''' <summary>
50+
''' Used to make a Emotional response fromt he currently held Emotion
51+
''' </summary>
52+
''' <returns></returns>
53+
Public Function MakeEmotionalResponse() As String
54+
Dim FoundEmotion As String = CurrentStateStr
55+
MakeEmotionalResponse = ""
56+
Randomize()
57+
Dim C As Short = Int(Rnd() * 6 + 1)
58+
Select Case C
59+
Case 1
60+
MakeEmotionalResponse = "I detect emotion in your tone, you are feeling " & LCase(FoundEmotion) & " perhaps"
61+
Case 2
62+
MakeEmotionalResponse = "Are you feeling " & LCase(FoundEmotion) & " ?"
63+
Case 3
64+
MakeEmotionalResponse = "Perhaps ? you can tell me more about why you are feeling ? " & LCase(FoundEmotion)
65+
Case 4
66+
MakeEmotionalResponse = "Detecting " & LCase(FoundEmotion) & " maybe?"
67+
Case 5
68+
MakeEmotionalResponse = "feeling a bit " & LCase(FoundEmotion) & " ?"
69+
Case 6
70+
MakeEmotionalResponse = "" & LCase(FoundEmotion) & " "
71+
End Select
72+
End Function
5073
Private Sub SetEmotionState(ByRef UserInput As String)
5174
'Reset Counters
5275
StateChanged = False

0 commit comments

Comments
 (0)