vb.net
Code:
Public Class AXLearnability
Private algSent As Boolean = False
' Problems that may result because of the last deployed algorithm:
Public defcons As HashSet(Of String) = New HashSet(Of String)()
' Major chaotic problems that may result because of the last deployed algorithm:
Public defcon5 As HashSet(Of String) = New HashSet(Of String)()
' Goals the last deployed algorithm aims to achieve:
Public goals As HashSet(Of String) = New HashSet(Of String)()
' How many failures / problems till the algorithm needs to mutate (change)
Public trgTolerance As TrgTolerance
Public Sub New(tolerance As Integer)
trgTolerance = New TrgTolerance(tolerance)
trgTolerance.reset()
End Sub
Public Sub pendAlg()
' An algorithm has been deployed
' Call this method when an algorithm is deployed (in a DiSkillV2 object)
algSent = True
trgTolerance.trigger()
End Sub
Public Sub pendAlgWithoutConfirmation()
' An algorithm has been deployed
algSent = True
' No need to await for a thank you or check for goal manifestation :
' trgTolerance.trigger()
' Using this method instead of the default "pendAlg" is the same as
' giving importance to the stick and not the carrot when learning
' This method is mostly fitting workplace situations
End Sub
Public Function mutateAlg(input As String) As Boolean
' Recommendation to mutate the algorithm? true/false
If Not algSent Then Return False ' No alg sent => no reason to mutate
If goals.Contains(input) Then
trgTolerance.reset()
algSent = False
Return False
End If
' Goal manifested; the sent algorithm is good => no need to mutate the alg
If defcon5.Contains(input) Then
trgTolerance.reset()
algSent = False
Return True
End If
' ^ Something bad happened probably because of the sent alg
' Recommend alg mutation
If defcons.Contains(input) Then
algSent = False
Dim mutate As Boolean = Not trgTolerance.trigger()
If mutate Then
trgTolerance.reset()
End If
Return mutate
End If
' ^ Negative result, mutate the alg if this occurs too much
Return False
End Function
Public Sub resetTolerance()
' Use when you run code to change algorithms regardless of learnability
trgTolerance.reset()
End Sub
End Class
Code:
Public Class SkillBranch1Liner
Inherits SkillBranch
Public Sub New(goal As String, defcon As String, tolerance As Integer, ParamArray skills() As Skill)
MyBase.New(tolerance)
Me.addGoal(goal)
Me.addDefcon(defcon)
For Each skill As Skill In skills
Me.addSkill(skill)
Next
End Sub
End Class