battle programmers alliance
Would you like to react to this message? Create an account in a few clicks or log in to continue.

battle programmers allianceLog in

the LivinGrimoire Artificial General Intelligence software design pattern forum

descriptionDIHomer skill EmptyDIHomer skill

more_horiz
demo :

https://streamable.com/wlgmx

updated classes for this skill :

https://github.com/yotamarker/public-livinGrimoire

unrelated : I added code871 to DSpeller class, though that voice file will be used for
automatic programming
chobit : the class is equiped to recognize standby phases
new class : TimeGate : time based boolean gate : will stay closed for set
amount of time after closing.
kokoro : can convey standby stage to skills (I call skills using this class soulistics)
DIHomer : uses mode algorithm to return AI home after she finishes tasks (see class doc)

Code:


package chobit;

import java.util.ArrayList;

public class DIHomer extends DISkill {
   private Coordinate homeXY = new Coordinate(51.4045, 30.0542);
   // 51.4045, 30.0542
   private int mode = 0;
   private int c2 = 0; // standBy counter;

   public DIHomer(Kokoro kokoro) {
      super(kokoro);
      // DB load home coordinates or default value
   }

   @Override
   public void input(String ear, String skin, String eye) {
      /*
       * the input function contains a trigger list for different modes where
       * different input conditions cause different modes and mode counters
       * modifications
       */
      if (ear.contains("this is home")) {
         this.homeXY = new Coordinate(Tokoro.lat, Tokoro.lon);
         mode = 3; // confirmation alg
         return;
         // DB save home coordinates
      }
      if (ear.contains("homer")) {
         mode = 4;
         return;
      }
         // external mode triggers :
      if (this.kokoro.standBy) {
         if (measure(this.homeXY.getX(), this.homeXY.getY(), Tokoro.lat, Tokoro.lon) < 2000) {
            mode = 0;
            // else if mode !2 mode 1
         } else {
            if (mode != 2) {
               mode = 1;
            } else {
               c2++;
            }
         }
      }

   }

   @Override
   public void output(Neuron noiron) {
      /*
       * modes summon different algorithms modes also contain mode changes such as
       * mode reset (mode 0)
       */
      switch (mode) {
      case 1:
         noiron.algParts.add(verbatimGorithm(new APVerbatim("i wanna go home")));
         mode = 2;

         break;
      case 2:
         if (c2 > 1) {
            c2 = 0;
            noiron.algParts.add(verbatimGorithm(new APVerbatim("take me home")));
         }
         break;
      case 3:
         noiron.algParts.add(verbatimGorithm(new APVerbatim("yes your majesty")));
         mode = 0;

         break;
      case 4:
         // measure(this.homeXY.getX(), this.homeXY.getY(), Tokoro.lat, Tokoro.lon)
         Double distance = measure(51.4045, 30.0542, 51.4050, 30.06);
         String s1 = String.format("%.02f kilometer", distance / 1000);
         noiron.algParts.add(verbatimGorithm(new APVerbatim(s1)));
         mode = 0;
         break;
      default:
         break;
      }
   }

   @Override
   public Boolean auto() {
      return true;
   }

   private Algorithm verbatimGorithm(AbsAlgPart itte) {
      // returns a simple algorithm for saying sent parameter
      // AbsAlgPart itte = new APVerbatim("I am");
      String representation = "about";
      ArrayList<AbsAlgPart> algParts1 = new ArrayList<>();
      algParts1.add(itte);
      Algorithm algorithm = new Algorithm("about", representation, algParts1);
      return algorithm;
   }

   public Double measure(double lat1, double lon1, double lat2, double lon2) { // generally used geo measurement
      // function
      double R = 6378.137; // Radius of earth in KM
      double dLat = lat2 * Math.PI / 180 - lat1 * Math.PI / 180;
      double dLon = lon2 * Math.PI / 180 - lon1 * Math.PI / 180;
      double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(lat1 * Math.PI / 180)
            * Math.cos(lat2 * Math.PI / 180) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
      double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
      double d = R * c;
      return d * 1000; // meters
   }
}



note this mode algorithm enables easy upgrades in which changes can be made to triggers and
algorithms fired up by modes.

trigger ->mode -> alg

for example for updatind to include visual data.

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

alg beef up plan :

{var location:=null //home
var homeDefcon}
alterHomesList(sorted)
*hotels

manual setHome

input : plain(shaded) : add to possible alter homeList
(night)time ?
check defcon
set algMode
home?
set algMode
else default mode

*********************************************
purchase/rent (depends on resources)
build
go to new explore location
********************************************
explore mode?
count standbys while defcon ok
if >x, set home and alterhome 2hours
update defcon
if bad defcon delete explore location(set to home var), go home, default mode
************************************************
defend
***************************************************
vacation mode
***************************************************
default mode
c2=0

standby?{bot at home?{mode=1;c2=0}else

switch mode:

1: go home;mode=2 //*home not null ?

2:if c2>x{c2=0;go home}

:hkn:

descriptionDIHomer skill EmptyRe: DIHomer skill

more_horiz
note

in the demo she outputs the distance from home

adding the skill :

in the chobit c'tor :

dClassesLv3.add(new DIHomer(kokoro));

:join:
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum
power_settings_newLogin to reply