' *** KAOS: Use pet name, love name or hate name depending on emotions. GetResponse = Replace(GetResponse, "", "", 1, -1, vbTextCompare) KAOSNickName = "" KAOSPrevNickName = "" KAOSNickNameChance = 0 KAOSNickNameTable = "KAOSPetNames" ' KAOSAnger indicates the strength of HAL's anger towards the User. KAOSAnger = Hate + Swear + Insults ' Search and replace instances of "" with nicknames. HAL will try to use ' different nicknames for the first four ""s. If InStr(1, GetResponse, "", vbTextCompare) > 0 Then For x = 1 To 4 ' Choose a name table, and determine the chance of using the nickname, based on HAL's ' emotions. Note that if HAL is saying the User's name more than once, each nickname ' could possibly come from a different table. This is intentional for a) variety and ' b) to give a greater sense of HAL's current emotions. If KAOSAnger = 0 Then If Compliment >= 0 Then If Compliment < 5 Then ' As Compliment ranges from 0 to 4, nickname chance ranges from 20% to 60% KAOSNickNameChance = 20 + Compliment * 10 Else ' As Compliment ranges from 5 to 10, nickname chance ranges from 70% To 90% KAOSNickNameChance = 70 + (Compliment - 5) * 4 If KAOSNickNameChance > 90 Then KAOSNickNameChance = 90 ' As Compliment ranges from 5 to 10, the chance of using a name from the ' love list increases from 20% to 100%. If Rnd * 100 < (20 + (Compliment - 5) * 16) Then KAOSNickNameTable = "KAOSLoveNames" End If End If ' If Compliment is negative, KAOS will not use nicknames. The default brain only ' drives Compliment negative in one situation (user stops talking about love). Else ' HAL has anger towards the user. HAL will not use love names in this situation. ' The chance of HAL using a nickname depends on HAL's current emotional strength, ' found by simply adding together all the emotional variables. Note that Compliment ' can sometimes become negative, so the absolute value of that is taken. As ' emotional strength ranges from 1 to 9, the chance of using a nickname ranges from ' 10% to 90%. KAOSNickNameChance = KAOSAnger + Abs(Compliment) * 10 If KAOSNickNameChance > 90 Then KAOSNickNameChance = 90 ' HAL will use only hate names if HAL's Anger starts getting close to Compliment. If KAOSAnger * 2 > Compliment Then ' HAL will choose between hate names and pet names depending on the strengh ' of Anger vs Compliment. If Rnd < KAOSAnger / (KAOSAnger + Abs(Compliment)) Then KAOSNickNameTable = "KAOSHateNames" End If End If If Rnd * 100 < KAOSNickNameChance Then ' Find a nickname, and if it the same as the last one used then try (just once) ' to get another. KAOSNickName = HalBrain.ChooseSentenceFromFile(KAOSNickNameTable) If KAOSNickName = KAOSPrevNickName Then KAOSNickName = HalBrain.ChooseSentenceFromFile(KAOSNickNameTable) End If If KAOSNickName <> "" Then GetResponse = Replace(GetResponse, "", KAOSNickName, 1, 1, vbTextCompare) KAOSPrevNickName = KAOSNickName Else GetResponse = Replace(GetResponse, "", UserName, 1, 1, vbTextCompare) End If Next ' Replace any remaining ""s with the user's name. GetResponse = Replace(GetResponse, "", UserName, 1, -1, vbTextCompare) End If