class MyClass:
def __init__(self, *args):
# Constructor for variable arguments
self.values = args
@classmethod
def from_list(cls, input_list):
# Constructor for a list
return cls(*input_list)
# Using the variable arguments constructor
obj1 = MyClass(1, 2, 3)
print(obj1.values) # Output: (1, 2, 3)
# Using the list constructor
obj2 = MyClass.from_list([4, 5, 6])
print(obj2.values) # Output: (4, 5, 6)
Public Class APVerbatim
Inherits Mutatable
Private sentences As New List(Of String)()
' Constructor accepting variable arguments
Public Sub New(ParamArray sentences() As String)
Me.sentences.AddRange(sentences)
End Sub
' Constructor accepting a List(Of String)
Public Sub New(list1 As List(Of String))
Me.sentences = New List(Of String)(list1)
End Sub
' Overrides action method
Public Overrides Function Action(ear As String, skin As String, eye As String) As String
' Return the next sentence and remove it from the list
If Me.sentences.Count > 0 Then
Dim nextSentence As String = Me.sentences(0)
Me.sentences.RemoveAt(0)
Return nextSentence
End If
Return "" ' Return empty string if no sentences left
End Function
' Overrides completed method
Public Overrides Function Completed() As Boolean
' Check if all sentences have been processed
Return Me.sentences.Count = 0
End Function
End Class
Public Class Skill
' Protected fields
Protected kokoro As Kokoro = Nothing ' Consciousness, shallow ref class for interskill communications
Protected outAlg As Algorithm = Nothing ' Skills output
Protected outpAlgPriority As Integer = -1 ' DEFCON levels 1->5
' Default constructor
Public Sub New()
MyBase.New()
End Sub
' Skill triggers and algorithmic logic
Public Sub Input(ear As String, skin As String, eye As String)
' Implement your logic here
End Sub
' Extraction of skill algorithm to run (if there is one)
Public Sub Output(noiron As Neuron)
If outAlg IsNot Nothing Then
noiron.InsertAlg(Me.outpAlgPriority, outAlg)
outpAlgPriority = -1
outAlg = Nothing
End If
End Sub
' Set Kokoro for interskill communication
Public Sub SetKokoro(kokoro As Kokoro)
Me.kokoro = kokoro
End Sub
' Build a simple output algorithm to speak string by string per think cycle
Protected Sub SetVerbatimAlg(priority As Integer, ParamArray sayThis() As String)
Me.outAlg = New Algorithm(New APVerbatim(sayThis))
Me.outpAlgPriority = priority ' DEFCON levels 1->5
End Sub
' Shortcut to build a simple algorithm
Protected Sub SetSimpleAlg(ParamArray sayThis() As String)
Me.outAlg = New Algorithm(New APVerbatim(sayThis))
Me.outpAlgPriority = 4 ' Default priority 4
End Sub
' Build a verbatim algorithm from a list
Protected Sub SetVerbatimAlgFromList(priority As Integer, sayThis As List(Of String))
Me.outAlg = New Algorithm(New APVerbatim(sayThis))
Me.outpAlgPriority = priority ' DEFCON levels 1->5
End Sub
' Check if an algorithm is pending
Public Function PendingAlgorithm() As Boolean
Return Me.outAlg IsNot Nothing
End Function
' Skill notes method
Public Function SkillNotes(param As String) As String
Return "notes unknown"
End Function
End Class
Public Class Skill
Protected kokoro As Kokoro = Nothing ' consciousness, shallow ref class to enable interskill communications
Protected outAlg As Algorithm = Nothing ' skills output
Protected outpAlgPriority As Integer = -1 ' defcon 1->5
Public Sub New()
MyBase.New()
End Sub
Public Overridable Sub Input(ear As String, skin As String, eye As String)
End Sub
Public Overridable Sub Output(noiron As Neuron)
If outAlg IsNot Nothing Then
noiron.InsertAlg(Me.outpAlgPriority, outAlg)
outpAlgPriority = -1
outAlg = Nothing
End If
End Sub
Public Overridable Sub SetKokoro(kokoro As Kokoro)
Me.kokoro = kokoro
End Sub
' Build a simple output algorithm to speak string by string per think cycle
Protected Sub SetVerbatimAlg(priority As Integer, ParamArray sayThis() As String)
Me.outAlg = New Algorithm(New APVerbatim(sayThis))
Me.outpAlgPriority = priority ' DEFCON levels 1->5
End Sub
' Shortcut to build a simple algorithm
Protected Sub SetSimpleAlg(ParamArray sayThis() As String)
Me.outAlg = New Algorithm(New APVerbatim(sayThis))
Me.outpAlgPriority = 4 ' Default priority 4
End Sub
' Build a verbatim algorithm from a list
Protected Sub SetVerbatimAlgFromList(priority As Integer, sayThis As List(Of String))
Me.outAlg = New Algorithm(New APVerbatim(sayThis))
Me.outpAlgPriority = priority ' DEFCON levels 1->5
End Sub
Public Function PendingAlgorithm() As Boolean
Return Me.outAlg IsNot Nothing
End Function
Public Overridable Function SkillNotes(param As String) As String
Return "notes unknown"
End Function
End Class
public class Skill
{
protected Kokoro kokoro = null; // consciousness, shallow ref class to enable interskill communications
protected Algorithm outAlg = null; // skill's output
protected int outpAlgPriority = -1; // defcon 1->5
public Skill()
{
base(); // Constructor chaining (not necessary in C# but matches semantics)
}
// Skill triggers and algorithmic logic
public virtual void Input(string ear, string skin, string eye)
{
// Add your logic here
}
// Extraction of skill algorithm to run (if there is one)
public virtual void Output(Neuron noiron)
{
if (outAlg != null)
{
noiron.InsertAlg(this.outpAlgPriority, outAlg);
outpAlgPriority = -1;
outAlg = null;
}
}
public void SetKokoro(Kokoro kokoro)
{
// Use this for telepathic communication between different chobits objects
this.kokoro = kokoro;
}
// In-skill algorithm building shortcut methods:
protected void SetVerbatimAlg(int priority, params string[] sayThis)
{
// Build a simple output algorithm to speak string by string per think cycle
// Uses varargs parameter
this.outAlg = new Algorithm(new APVerbatim(sayThis));
this.outpAlgPriority = priority; // 1->5 1 is the highest algorithm priority
}
protected void SetSimpleAlg(params string[] sayThis)
{
// Based on the SetVerbatimAlg method
// Build a simple output algorithm to speak string by string per think cycle
// Uses varargs parameter
this.outAlg = new Algorithm(new APVerbatim(sayThis));
this.outpAlgPriority = 4; // 1->5 1 is the highest algorithm priority
}
protected void SetVerbatimAlgFromList(int priority, List<string> sayThis)
{
// Build a simple output algorithm to speak string by string per think cycle
// Uses list parameter
this.outAlg = new Algorithm(new APVerbatim(sayThis));
this.outpAlgPriority = priority; // 1->5 1 is the highest algorithm priority
}
public bool PendingAlgorithm()
{
// Is an algorithm pending?
return this.outAlg != null;
}
public virtual string SkillNotes(string param)
{
return "notes unknown";
}
}
class APVerbatim extends Mutatable {
constructor(...sentences) {
super();
this.sentences = Array.isArray(sentences[0]) ? [...sentences[0]] : [...sentences];
}
action(ear, skin, eye) {
// Return the next sentence and remove it from the list
if (this.sentences.length > 0) {
return this.sentences.shift(); // Removes and returns the first sentence
}
return ""; // Return empty string if no sentences left
}
completed() {
// Check if all sentences have been processed
return this.sentences.length === 0;
}
}
class Algorithm {
constructor(algParts) {
// Handle both Array input and variable arguments (rest parameters)
this.algParts = Array.isArray(algParts) ? [...algParts] : [...arguments];
}
getAlgParts() {
return this.algParts;
}
getSize() {
return this.algParts.length;
}
}
class Skill {
constructor() {
this.kokoro = null; // Consciousness, shallow ref class for interskill communications
this.outAlg = null; // Skill's output
this.outpAlgPriority = -1; // DEFCON levels 1->5
}
// Skill triggers and algorithmic logic
input(ear, skin, eye) {
// Logic for skill triggers goes here
}
// Extraction of skill algorithm to run (if there is one)
output(noiron) {
if (this.outAlg !== null) {
noiron.insertAlg(this.outpAlgPriority, this.outAlg);
this.outpAlgPriority = -1;
this.outAlg = null;
}
}
// Set Kokoro for interskill communication
setKokoro(kokoro) {
// Use this for telepathic communication between different objects
this.kokoro = kokoro;
}
// Build a simple output algorithm to speak string by string per think cycle (varargs)
setVerbatimAlg(priority, ...sayThis) {
this.outAlg = new Algorithm(new APVerbatim(...sayThis));
this.outpAlgPriority = priority; // DEFCON levels 1->5, 1 is the highest
}
// Shortcut to build a simple algorithm
setSimpleAlg(...sayThis) {
this.outAlg = new Algorithm(new APVerbatim(...sayThis));
this.outpAlgPriority = 4; // Default priority 4
}
// Build a verbatim algorithm from a list
setVerbatimAlgFromList(priority, sayThis) {
this.outAlg = new Algorithm(new APVerbatim(sayThis));
this.outpAlgPriority = priority; // DEFCON levels 1->5, 1 is the highest
}
// Check if an algorithm is pending
pendingAlgorithm() {
return this.outAlg !== null;
}
// Skill notes method
skillNotes(param) {
return "notes unknown";
}
}
class APVerbatim:
def __init__(self, *sentences):
# Initialize with either a list of sentences or a variable number of arguments
if len(sentences) == 1 and isinstance(sentences[0], list):
self.sentences = list(sentences[0]) # Initialize with a copy of the list
else:
self.sentences = list(sentences) # Initialize with sentences provided as arguments
def action(self, ear, skin, eye):
# Return the next sentence and remove it from the list
if self.sentences:
return self.sentences.pop(0)
return "" # Return an empty string if no sentences are left
def completed(self):
# Check if all sentences have been processed
return not self.sentences
class Algorithm:
def __init__(self, *algParts):
# Check if a single argument is a list, otherwise use variable arguments
if len(algParts) == 1 and isinstance(algParts[0], list):
self.algParts = list(algParts[0]) # Initialize with the given list
else:
self.algParts = list(algParts) # Initialize with variable arguments
def get_alg_parts(self):
return self.algParts
def get_size(self):
return len(self.algParts)
class Algorithm:
def __init__(self, *algParts):
# Handle both a list input and variable arguments
if len(algParts) == 1 and isinstance(algParts[0], list):
self.algParts = list(algParts[0]) # Initialize with the given list
else:
self.algParts = list(algParts) # Initialize with variable arguments
@classmethod
def from_list(cls, input_list):
# Alternate constructor that takes a list
return cls(input_list)
def get_alg_parts(self):
return self.algParts
def get_size(self):
return len(self.algParts)
class Algorithm:
def __init__(self, *algParts):
# Handle both a list input and variable arguments
if len(algParts) == 1 and isinstance(algParts[0], list):
self.algParts = list(algParts[0]) # Initialize with the given list
else:
self.algParts = list(algParts) # Initialize with variable arguments
@classmethod
def from_list(cls, input_list):
# Alternate constructor that takes a list
return cls(input_list)
def get_alg_parts(self):
return self.algParts
def get_size(self):
return len(self.algParts)
class Algorithm:
def __init__(self, algParts: list[Mutatable]): # list of Mutatable
super().__init__()
self.algParts: list[Mutatable] = algParts
# *constract with string and goal
@property
def getAlgParts(self) -> list[Mutatable]:
return self.algParts
def getSize(self) -> int:
return len(self.algParts)
class Algorithm:
def __init__(self, *args: Mutatable) -> None:
super().__init__()
if len(args) == 1 and isinstance(args[0], list): # Check if input is a list
self.algParts: list[Mutatable] = args[0] # Assign the list directly
else: # Handle varargs case
self.algParts: list[Mutatable] = list(args) # Convert varargs to a list
@property
def getAlgParts(self) -> list[Mutatable]:
return self.algParts
def getSize(self) -> int:
return len(self.algParts)
class Algorithm:
def __init__(self, algParts: list[Mutatable]) -> None:
super().__init__()
self.algParts: list[Mutatable] = algParts
@classmethod
def from_varargs(cls, *algParts: Mutatable) -> 'Algorithm':
# Create an instance from varargs
return cls(list(algParts)) # Convert varargs to a list and pass to the primary constructor
@property
def getAlgParts(self) -> list[Mutatable]:
return self.algParts
def getSize(self) -> int:
return len(self.algParts)
class Skill:
def __init__(self):
# The variables start with an underscore (_) because they are protected
self._kokoro = None # consciousness, shallow ref class to enable interskill communications
self._outAlg: Algorithm # skills output
self._outAlg = None
self._outpAlgPriority: int = -1 # defcon 1->5
def setOutalg(self, alg: Algorithm):
self._outAlg = alg
def getOutAlg(self) -> Algorithm:
return self._outAlg
def setOutAlgPriority(self, priority):
self._outpAlgPriority = priority
# skill triggers and algorithmic logic
def input(self, ear: str, skin: str, eye: str):
pass
# extraction of skill algorithm to run (if there is one)
def output(self, noiron: Neuron):
if self._outAlg is not None:
noiron.insertAlg(self._outpAlgPriority, self._outAlg)
self._outpAlgPriority = -1
self._outAlg = None
def setKokoro(self, kokoro: Kokoro):
# use this for telepathic communication between different chobits objects
self._kokoro = kokoro
def getKokoro(self):
return self._kokoro
# in skill algorithm building shortcut methods:
def setVerbatimAlg(self, priority: int, *sayThis: str):
# build a simple output algorithm to speak string by string per think cycle
# uses varargs param
temp: list[str] = []
for i in range(0, len(sayThis)):
temp.append(sayThis[i])
self._outAlg = self.simpleVerbatimAlgorithm(temp)
self._outpAlgPriority = priority # 1->5 1 is the highest algorithm priority
def setSimpleAlg(self, *sayThis: str):
# based on the setVerbatimAlg method
# build a simple output algorithm to speak string by string per think cycle
# uses varargs param
temp: list[str] = []
for i in range(0, len(sayThis)):
temp.append(sayThis[i])
self._outAlg = self.simpleVerbatimAlgorithm(temp)
self._outpAlgPriority = 4 # 1->5 1 is the highest algorithm priority
def setVebatimAlgFromList(self, priority: int, sayThis: list[str]):
# build a simple output algorithm to speak string by string per think cycle
# uses list param
self._outAlg = self.algBuilder(APVerbatim(sayThis))
self._outpAlgPriority = priority # 1->5 1 is the highest algorithm priority
def algPartsFusion(self, priority: int, *algParts: Mutatable):
# build a custom algorithm out of a chain of algorithm parts(actions)
algParts1: list[Mutatable] = []
for i in range(0, len(algParts)):
algParts1.append(algParts[i])
self._outAlg = Algorithm(algParts1)
self._outpAlgPriority = priority # 1->5 1 is the highest algorithm priority
def pendingAlgorithm(self) -> bool:
# is an algorithm pending?
return self._outAlg is not None
# skill utils
# alg part based algorithm building methods
# var args param
# noinspection PyMethodMayBeStatic
def algBuilder(self, *itte: Mutatable) -> Algorithm:
# returns an algorithm built with the algPart varargs
algParts1: list[Mutatable] = []
for i in range(0, len(itte)):
algParts1.append(itte[i])
algorithm: Algorithm = Algorithm(algParts1)
return algorithm
# String based algorithm building methods
def simpleVerbatimAlgorithm(self, *sayThis) -> Algorithm:
# returns alg that says the word string (sayThis)
return self.algBuilder(APVerbatim(*sayThis))
def skillNotes(self, param: str) -> str:
return "notes unknown"