예제 #1
0
    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);
    }
예제 #2
0
    public override float distance(BaseAgentBehavior owner, MAction action)

    {
        //calculate distance to goal after applying action

        return(-1f);
    }
예제 #3
0
    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);
    }
예제 #4
0
    public override void initCached(BaseAgentBehavior owner)
    {
        base.initCached(owner);

        destination = cachedOutFilter.getEntity <Destination>();
        map         = (cachedInFilter.getEntity <ResourceTileMap>()).getComponent <ResourceTileMap>().map;
    }
예제 #5
0
    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;
    }
예제 #6
0
    public override void initCached(BaseAgentBehavior owner)
    {
        base.initCached(owner);

        tile = owner.entities.getEntity <Destination>().getComponent <Destination>().destination;

        currentCatch = owner.entities.getEntity <Catch>();
    }
예제 #7
0
    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
    }
예제 #8
0
    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;
    }
예제 #9
0
    public override bool isDoable(BaseAgentBehavior owner)
    {
        bool doable = false;

        if (cachedInFilter.getEntity<Catch>().getComponent<ByCatch>().size > 0)
            doable = true;

        return doable;
    }
예제 #10
0
    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);
    }
예제 #11
0
    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);
    }
예제 #12
0
    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 ");
    }
예제 #13
0
    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);
        }
    }
예제 #14
0
    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);
        }
    }
예제 #15
0
 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>());
 }
예제 #16
0
 public override void execute(BaseAgentBehavior owner)
 {
     //this is what the action does
 }
예제 #17
0
 public override float distanceToGoal(BaseAgentBehavior owner, MGoal goal)
 {
     return(goal.distance(owner, this));
 }
예제 #18
0
 public override void execute(BaseAgentBehavior owner)
 {
     action.execute(owner);
 }
예제 #19
0
 public override bool isDoable(BaseAgentBehavior owner)
 {
     return(action.isDoable(owner));
 }
예제 #20
0
 public override bool isActive(BaseAgentBehavior owner)
 {
     // check if the context matches beliefs
     return(false);
 }
예제 #21
0
 public override void execute(BaseAgentBehavior owner)
 {
     //this is what the action does
     owner.StartCoroutine(moveBoat(destination.destination.tileIndex()));
 }
예제 #22
0
 public override float distanceToGoal(BaseAgentBehavior owner, MGoal goal)
 {
     throw new System.NotImplementedException();
 }
예제 #23
0
 public override bool isDoable(BaseAgentBehavior owner)
 {
     return(true);
 }
예제 #24
0
 public override List <mEntity> getTargets(BaseAgentBehavior owner)
 {
     throw new System.NotImplementedException();
 }
예제 #25
0
 public abstract float distanceToGoal(BaseAgentBehavior owner, MGoal goal);
예제 #26
0
 public override bool isDoable(BaseAgentBehavior owner)
 {
     //check if action can be performed
     return(false);
 }
예제 #27
0
 public abstract List <mEntity> getTargets(BaseAgentBehavior owner);
예제 #28
0
 public abstract void execute(BaseAgentBehavior owner);
예제 #29
0
 public override bool canBeAppliedTo(BaseAgentBehavior owner, mEntity entity)
 {
     //test if the action can be applied to a certain entity
     return(false);
 }
예제 #30
0
 public override bool canBeAppliedTo(BaseAgentBehavior owner, mEntity entity)
 {
     throw new System.NotImplementedException();
 }