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()); }
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)); } }
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); }
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()); }
public override float RateIt(BotNeeds simAvatar) { return GetProposedChange().TotalSideEffect(simAvatar); }
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)); }
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 float GetValue(Object fi, BotNeeds newNeeds) { return (float)((FieldInfo)fi).GetValue(newNeeds); }
public BotNeeds Magnify(float mag) { BotNeeds needsBefore = new BotNeeds(0.0F); foreach (Object fi in GetNeeds()) { needsBefore.SetNeed(fi, GetNeed(fi) * mag); } return needsBefore; }
public float TotalSideEffect(BotNeeds bn) { bn = bn.Copy(); bn.AddFrom(this); bn.SetRange(0f, 100f); return bn.Total(); }
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(); }
public BotNeeds Copy() { BotNeeds needsBefore = new BotNeeds(0.0F); needsBefore.SetFrom(this); return needsBefore; }
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 override float RateIt(BotNeeds current) { return ProposedChange().TotalSideEffect(current); }
public override float RateIt(BotNeeds current) { return(ProposedChange().TotalSideEffect(current)); }
public override float RateIt(BotNeeds needs) { return(ChangePromise.TotalSideEffect(needs)); }
public override float RateIt(BotNeeds needs) { return ChangePromise.TotalSideEffect(needs); }
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(); }