Code:
class Brain(private val MVC: actionable, private val chi: thinkable) {
fun doIt(ear: String, skin: String, eye: String) {
val result = chi.think(ear!!, skin!!, eye!!)
MVC.act(result)
}
}
the class is constructed with an actionable and a ChobitV2 (thinkable)
example actionable :
Code:
import androidx.appcompat.app.AppCompatActivity;
import com.yotamarker.lgkotlinfull.LGCore.actionable;
import org.jetbrains.annotations.NotNull;
public class CerabellumV3 implements actionable {
private MainActivity main;
public CerabellumV3(MainActivity main) {
this.main = main;
}
@Override
public void act(@NotNull String thought) {
main.toaster(thought);
}
}
the chobit is the AI it processes the input and produces an output result.
the actionable (which is the MVC model) has access to the main classes hardware actions
such as SMS sending, robotics and so on.
depending on the chobit result you may want to engage on such hardware actions.
the actionable act function can be implemented to, for example, activate a public function to send an SMS
if the result is "some specific string".
on this example implementation the actionable simply uses some toast function I wrote on the main activity
to display the result as a toast message.
see MainActivity
Code:
package com.yotamarker.lgkotlinfull
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.yotamarker.lgkotlinfull.LGCore.Brain
import com.yotamarker.lgkotlinfull.LGCore.ChobitV2
import com.yotamarker.lgkotlinfull.skills.Personality2
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
var chii: ChobitV2? = null
var brain: Brain?=null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
chii= ChobitV2(Personality2())
brain= Brain(CerabellumV3(this),chii!!)
}
fun engage(view: View){
//chii!!.doIt(editText.text.toString(),"","")
brain!!.doIt(editText.text.toString(),"","")
Toast.makeText(this, editText.text.toString(), Toast.LENGTH_SHORT).show()
}
public fun toaster(str:String){Toast.makeText(this, str, Toast.LENGTH_SHORT).show()}
}
this keeps the code much cleaner and the algorithmic logic can be used for other projects or even other programming languages