public BotNeeds Copy()
        {
            BotNeeds needsBefore = new BotNeeds(0.0F);

            needsBefore.SetFrom(this);
            return(needsBefore);
        }
 public void SetFrom(BotNeeds newNeeds)
 {
     foreach (Object fi in GetNeeds())
     {
         SetNeed(fi, newNeeds.GetNeed(fi));
     }
 }
        public override void InvokeReal()
        {
            SimActor TheBot = (SimActor)this.TheBot;

            TimeRemaining = rand.Next(1, 3); // one to tree cycles
            while (TimeRemaining-- > 0)
            {
                String use = TypeUsage.UsageName;
                TheBot.Approach(Victem, 5);
                TheBot.Debug(ToString());
                CurrentTopic = TheBot.LastAction;
                TheBot.TalkTo(Victem, CurrentTopic);
                Thread.Sleep(8000);
                //User.ApplyUpdate(use, simObject);
            }
            BotNeeds CurrentNeeds = (BotNeeds)TheBot["CurrentNeeds"];
            BotNeeds needsBefore  = CurrentNeeds.Copy();
            BotNeeds simNeeds     = TypeUsage.ChangeActual;

            //TODO rate interaction
            CurrentNeeds.AddFrom(simNeeds);
            CurrentNeeds.SetRange(0.0F, 100.0F);
            BotNeeds difNeeds = CurrentNeeds.Minus(needsBefore);

            TheBot.Debug(ToString() + " => " + difNeeds.ShowNonZeroNeeds());
        }
Пример #4
0
 public override CmdResult ExecuteRequest(CmdRequest args)
 {
     string to_op = args.GetString("verb");
     string objname = args.GetString("target");
     if (objname == "")
     {
         return Failure("$bot don't know what object to use.");
     }
     if (to_op == "")
     {
         SimObject objToUse;
         if (WorldSystem.tryGetPrim(objname, out objToUse))
         {
             if ((BotNeeds) TheSimAvatar["CurrentNeeds"] == null)
             {
                 TheSimAvatar["CurrentNeeds"] = new BotNeeds(90.0f);
             }
             SimTypeUsage usage = objToUse.Affordances.GetBestUse((BotNeeds) TheSimAvatar["CurrentNeeds"]);
             if (usage == null)
             {
                 //usage = new MoveToLocation(TheSimAvatar, objToUse);
                 return Failure("$bot don't have a use for " + objToUse + " yet.");
             }
             TheSimAvatar.Do(usage, objToUse);
             return Success("used " + objToUse);
         }
         return Failure("$bot don't know what to do with " + objname);
     }
     WriteLine("Trying to (" + to_op + ") with (" + objname + ")");
     TheBotClient.UseInventoryItem(to_op, objname);
     return Success("completed to (" + to_op + ") with (" + objname + ")");
 }
        public virtual void InvokeBotSideEffect(SimAvatar TheBot)
        {
            Debug(TheBot, ToString());
            //User.ApplyUpdate(use, simObject);
            BotNeeds CurrentNeeds = (BotNeeds)TheBot["CurrentNeeds"];

            if (CurrentNeeds == null)
            {
                TheBot["CurrentNeeds"] = CurrentNeeds = new BotNeeds(90.0f);
            }
            BotNeeds needsBefore = CurrentNeeds.Copy();
            BotNeeds update      = Target.Affordances.GetActualUpdate(TypeUsage.UsageName);

            //TODO rate interaction and update TheBot.Assumptions
            CurrentNeeds.AddFrom(update);
            CurrentNeeds.SetRange(0.0F, 100.0F);
            BotNeeds difNeeds = CurrentNeeds.Minus(needsBefore);

            Debug(TheBot, TheBot + " " + ToString() + "\n\t " +
                  TheBot.DistanceVectorString(Target)
                  + "=> " + difNeeds.ShowNonZeroNeeds());
            if (TheBot is SimActor)
            {
                ((SimActor)TheBot).ExecuteLisp(this, TypeUsage);
            }
            Thread.Sleep(TypeUsage.totalTimeMS);
        }
 public float TotalSideEffect(BotNeeds bn)
 {
     bn = bn.Copy();
     bn.AddFrom(this);
     bn.SetRange(0f, 100f);
     return(bn.Total());
 }
 public void AddFrom(BotNeeds needsDiff)
 {
     foreach (Object fi in GetNeeds())
     {
         SetNeed(fi, GetNeed(fi) + needsDiff.GetNeed(fi));
     }
 }
Пример #8
0
 public void SetValue(Object fi, BotNeeds needsBefore, object p)
 {
     if (!(p is Single))
     {
         p = float.Parse(p.ToString());
     }
     ((FieldInfo)fi).SetValue(needsBefore, p);
 }
 public void SetValue(Object fi, BotNeeds needsBefore, object p)
 {
     if (!(p is Single))
     {
         p = float.Parse(p.ToString());
     }
     ((FieldInfo)fi).SetValue(needsBefore, p);
 }
        public BotNeeds Minus(BotNeeds needsBefore)
        {
            BotNeeds copy = Copy();

            foreach (Object need in copy.GetNeeds())
            {
                copy.SetNeed(need, copy.GetNeed(need) - needsBefore.GetNeed(need));
            }
            return(copy);
        }
        public BotNeeds Magnify(float mag)
        {
            BotNeeds needsBefore = new BotNeeds(0.0F);

            foreach (Object fi in GetNeeds())
            {
                needsBefore.SetNeed(fi, GetNeed(fi) * mag);
            }
            return(needsBefore);
        }
Пример #12
0
        public float RateIt(BotNeeds from, SimTypeUsage use)
        {
            if (use == null)
            {
                return(-100f);
            }
            BotNeeds sat = GetUsagePromise(use.UsageName).Copy();

            sat.AddFrom(from);
            sat.SetRange(0.0F, 100.0F);
            return(sat.Total());
        }
Пример #13
0
 public override float RateIt(BotNeeds simAvatar)
 {
     return GetProposedChange().TotalSideEffect(simAvatar);
 }
Пример #14
0
 public abstract float RateIt(BotNeeds current);
 public override float RateIt(BotNeeds simAvatar)
 {
     return(GetProposedChange().TotalSideEffect(simAvatar));
 }
 public float GetValue(Object fi, BotNeeds newNeeds)
 {
     return((float)((FieldInfo)fi).GetValue(newNeeds));
 }
Пример #17
0
 public BotNeeds Minus(BotNeeds needsBefore)
 {
     BotNeeds copy = Copy();
     foreach (Object need in copy.GetNeeds())
     {
         copy.SetNeed(need, copy.GetNeed(need) - needsBefore.GetNeed(need));
     }
     return copy;
 }
Пример #18
0
 public float GetValue(Object fi, BotNeeds newNeeds)
 {
     return (float)((FieldInfo)fi).GetValue(newNeeds);
 }
Пример #19
0
 public BotNeeds Magnify(float mag)
 {
     BotNeeds needsBefore = new BotNeeds(0.0F);
     foreach (Object fi in GetNeeds())
     {
         needsBefore.SetNeed(fi, GetNeed(fi) * mag);
     }
     return needsBefore;
 }
Пример #20
0
 public float TotalSideEffect(BotNeeds bn) {
     bn = bn.Copy();           
     bn.AddFrom(this);
     bn.SetRange(0f, 100f);
     return bn.Total();
 }
Пример #21
0
 public ParrotAction(SimActor a)
     : base(String.Format("AvatarThinkerThread for {0}", a))
 {
     Actor = a;
     Actor["CurrentNeeds"] = new BotNeeds(90.0f);
     avatarHeartbeatThread = new Thread(Aging)
                                 {
                                     Name = String.Format("AvatarHeartbeatThread for {0}", Actor),
                                     Priority = ThreadPriority.Lowest
                                 };
     avatarHeartbeatThread.Start();
 }
Пример #22
0
 public BotNeeds Copy()
 {
     BotNeeds needsBefore = new BotNeeds(0.0F);
     needsBefore.SetFrom(this);
     return needsBefore;
 }
Пример #23
0
 public virtual void InvokeBotSideEffect(SimAvatar TheBot)
 {
     Debug(TheBot, ToString());
     //User.ApplyUpdate(use, simObject);
     BotNeeds CurrentNeeds = (BotNeeds)TheBot["CurrentNeeds"];
     if (CurrentNeeds == null)
     {
         TheBot["CurrentNeeds"] = CurrentNeeds = new BotNeeds(90.0f);   
     }                
     BotNeeds needsBefore = CurrentNeeds.Copy();
     BotNeeds update = Target.Affordances.GetActualUpdate(TypeUsage.UsageName);
     //TODO rate interaction and update TheBot.Assumptions
     CurrentNeeds.AddFrom(update);
     CurrentNeeds.SetRange(0.0F, 100.0F);
     BotNeeds difNeeds = CurrentNeeds.Minus(needsBefore);
     Debug(TheBot,TheBot + " " + ToString() + "\n\t " +
                  TheBot.DistanceVectorString(Target)
                  + "=> " + difNeeds.ShowNonZeroNeeds());
     if (TheBot is SimActor) ((SimActor)TheBot).ExecuteLisp(this, TypeUsage);
     Thread.Sleep(TypeUsage.totalTimeMS);
 }
Пример #24
0
 public override float RateIt(BotNeeds current)
 {
     return ProposedChange().TotalSideEffect(current);
 }
 public override float RateIt(BotNeeds current)
 {
     return(ProposedChange().TotalSideEffect(current));
 }
Пример #26
0
 public abstract float RateIt(BotNeeds current);
Пример #27
0
 public override float RateIt(BotNeeds needs)
 {
     return(ChangePromise.TotalSideEffect(needs));
 }
Пример #28
0
 public override float RateIt(BotNeeds needs)
 {
     return ChangePromise.TotalSideEffect(needs);
 }
Пример #29
0
 public void SetFrom(BotNeeds newNeeds)
 {
     foreach (Object fi in GetNeeds())
     {
         SetNeed(fi, newNeeds.GetNeed(fi));
     }
 }
Пример #30
0
 public void AddFrom(BotNeeds needsDiff)
 {
     foreach (Object fi in GetNeeds())
     {
         SetNeed(fi, GetNeed(fi) + needsDiff.GetNeed(fi));
     }
 }
Пример #31
0
 public float RateIt(BotNeeds from, SimTypeUsage use)
 {
     if (use == null) return -100f;
     BotNeeds sat = GetUsagePromise(use.UsageName).Copy();
     sat.AddFrom(from);
     sat.SetRange(0.0F, 100.0F);
     return sat.Total();
 }