public override float distance(BaseAgentBehavior owner, MAction action) { string s = ""; float d = -1; if (EntityMatchesGoal(filter, ref s)) { float capacity = 0, currentCatch = 0, byCatch = 0; foreach (mEntity e in cachedFilter) { if (e.getComponent <Capacity>() != null) { capacity = e.getComponent <Capacity>().capacity; } if (e.getComponent <Catch>() != null) { currentCatch = e.getComponent <Catch>().size; } if (e.getComponent <ByCatch>() != null) { byCatch = e.getComponent <ByCatch>().size; } } d = capacity - currentCatch - byCatch; } return(d); }
public override float distance(BaseAgentBehavior owner, MAction action) { //calculate distance to goal after applying action return(-1f); }
public override float distance(BaseAgentBehavior owner) { string s = ""; float d = -1; // if (EntityMatchesGoal(filter, ref s)) { float capacity = 0, currentCatch = 0, byCatch = 0; if (owner.GetComponent <VesselBehavior>().vesselProfile.getComponent <Capacity>() != null) { capacity = owner.GetComponent <VesselBehavior>().vesselProfile.getComponent <Capacity>().capacity; } foreach (mEntity e in cachedFilter) { if (e.getComponent <Catch>() != null) { currentCatch = e.getComponent <Catch>().size; } if (e.getComponent <ByCatch>() != null) { byCatch = e.getComponent <ByCatch>().size; } } d = capacity - currentCatch - byCatch; } Debug.Log(d); return(d); }
public override void initCached(BaseAgentBehavior owner) { base.initCached(owner); destination = cachedOutFilter.getEntity <Destination>(); map = (cachedInFilter.getEntity <ResourceTileMap>()).getComponent <ResourceTileMap>().map; }
public override void execute(BaseAgentBehavior owner) { Debug.Log("Discard execution called"); owner.entities.getEntity<Catch>().getComponent<Catch>().size += owner.entities.getEntity<ByCatch>().getComponent<ByCatch>().size; owner.entities.getEntity<ByCatch>().getComponent<ByCatch>().size = 0; }
public override void initCached(BaseAgentBehavior owner) { base.initCached(owner); tile = owner.entities.getEntity <Destination>().getComponent <Destination>().destination; currentCatch = owner.entities.getEntity <Catch>(); }
public override void execute(BaseAgentBehavior owner) { //mark violation of norm //execute the target action owner.reasoner.activeAction.execute(owner); //for goals: set as active goal, mark violation of norm. the plan will proceed }
public override void initCached(BaseAgentBehavior owner) { base.initCached(owner); destination = owner.entities.getEntity <Destination>().getComponent <Destination>(); go = owner.gameObject; speed = ((VesselBehavior)owner).vesselProfile.getComponent <Speed>().speed; }
public override bool isDoable(BaseAgentBehavior owner) { bool doable = false; if (cachedInFilter.getEntity<Catch>().getComponent<ByCatch>().size > 0) doable = true; return doable; }
public override bool isActive(BaseAgentBehavior owner) { //norm applies if you have bycatch if (owner.entities.getEntity <Catch>().getComponent <ByCatch>().size > 0) { return(true); } return(false); }
public override bool isDoable(BaseAgentBehavior owner) { bool doable = true; if (owner.entities.getEntity <BaseQuota>().getComponent <BaseQuota>() == null || owner.entities.getEntity <BaseQuota>().getComponent <BaseQuota>().quota <= 0) { doable = false; } return(doable); }
public override void execute(BaseAgentBehavior owner) { if (map == null) { map = ((VesselBehavior)owner).resourceMap; } ResourceGrid grid = map.GetComponent <MarineResourceBehavior>().grid; ResourceTile mostTile = grid.resourceTiles.ElementAt(UnityEngine.Random.Range(0, grid.resourceTiles.Count)).Value; destination.getComponent <Destination>().destination = mostTile; Debug.Log("Fishing location set "); }
public virtual void init(BaseAgentBehavior owner) { this.owner = owner; cachedContext.Clear(); foreach (mEntity ent in context) { cachedContext.Add(ECUtils.getMatchingEntity(ent, owner.entities)); } if (targetAction != null) { cachedTargetAction = owner.actions.getAction(targetAction); } if (targetGoal != null) { cachedTargetGoal = owner.goals.getGoal(targetGoal); } }
public override void init(BaseAgentBehavior owner) { //cache required info from owner //these are reference types because this is not an independent object //it needs to reason on data from the owner and return a decision to it this.owner = owner; entities.Clear(); foreach (mEntity e in owner.entities) { entities.Add(e); } goals = owner.goals; foreach (MGoal g in goals) { // qGoals.Enqueue(g); } actions = owner.actions; //find the actual actions and goals from the owner and replace the template refplan = new Plan(); plan = ((GoalReasoner)owner.reasonerTemplate).plan; foreach (KeyValuePair <MGoal, List <MAction> > entry in plan.plan) { MGoal key = goals.getGoal(entry.Key); List <MAction> value = new List <MAction>(); foreach (MAction a in entry.Value) { value.Add(actions.getAction(a)); } // KeyValuePair<MGoal, List<MAction>> newEntry = new KeyValuePair<MGoal, List<MAction>>(key, value); refplan.plan.Add(key, value); } }
public override List <mEntity> getTargets(BaseAgentBehavior owner) { //returns a list of entities belonging to the owner to which the action can be applied return(new List <mEntity>()); }
public override void execute(BaseAgentBehavior owner) { //this is what the action does }
public override float distanceToGoal(BaseAgentBehavior owner, MGoal goal) { return(goal.distance(owner, this)); }
public override void execute(BaseAgentBehavior owner) { action.execute(owner); }
public override bool isDoable(BaseAgentBehavior owner) { return(action.isDoable(owner)); }
public override bool isActive(BaseAgentBehavior owner) { // check if the context matches beliefs return(false); }
public override void execute(BaseAgentBehavior owner) { //this is what the action does owner.StartCoroutine(moveBoat(destination.destination.tileIndex())); }
public override float distanceToGoal(BaseAgentBehavior owner, MGoal goal) { throw new System.NotImplementedException(); }
public override bool isDoable(BaseAgentBehavior owner) { return(true); }
public override List <mEntity> getTargets(BaseAgentBehavior owner) { throw new System.NotImplementedException(); }
public abstract float distanceToGoal(BaseAgentBehavior owner, MGoal goal);
public override bool isDoable(BaseAgentBehavior owner) { //check if action can be performed return(false); }
public abstract List <mEntity> getTargets(BaseAgentBehavior owner);
public abstract void execute(BaseAgentBehavior owner);
public override bool canBeAppliedTo(BaseAgentBehavior owner, mEntity entity) { //test if the action can be applied to a certain entity return(false); }
public override bool canBeAppliedTo(BaseAgentBehavior owner, mEntity entity) { throw new System.NotImplementedException(); }