public EmptyProperty(Texture2D spriteSheet, Vector2 startPos) : base(spriteSheet, startPos) { setInteract(true); util = new Utility(HUNGER, ENERGY, FOODSTORES); setCollide(false); setStatic(true); }
public Farmland(Texture2D spriteSheet, Vector2 startPos) : base(spriteSheet, startPos) { setInteract(true); util = new Utility(5, 5); setCollide(false); setStatic(true); }
public WObject(Texture2D spriteSheet, Vector2 startPos) : base(spriteSheet, startPos) { util = new Utility(0, 0); _canInteract = false; setCollide(true); setStatic(true); }
private int hungerRate = 5; //Rate of consumption for food #endregion Fields #region Constructors public Home(Texture2D spriteSheet, Vector2 startPos, int ownID) : base(spriteSheet, startPos, ownID) { setInteract(true); util = new Utility(HUNGER, ENERGY, FOODSTORES); setCollide(false); setStatic(true); }
public Farmland(Texture2D spriteSheet, Vector2 startPos, int ownID) : base(spriteSheet, startPos, ownID) { setInteract(true); util = new Utility(HUNGER, ENERGY, FOODSTORES); setCollide(false); setStatic(true); util.setRecover(0, 0, FOOD_RECOVER); }
public Agent(Texture2D spriteSheet, Vector2 startPos, int logicNum) : base(spriteSheet, startPos) { setLogicType = logicNum; energy = 100; setDest(D1); waypoints = new Stack<Vector2>(); util = new Utility(1000,1000); plan = new List<int>(); knowledge = new List<WObject>(); }
public bool Met(Utility u) { if (u != null) { if (hunger < u.hunger) { return false; } if (energy < u.energy) { return false; } } return true; }
public Agent(Texture2D spriteSheet, Vector2 startPos, int logicNum, int id) : base(spriteSheet, startPos) { agentID = id; setLogicType = logicNum; energy = 100; setDest(D1); waypoints = new Stack<Vector2>(); util = new Utility(1000,1000,0); util.setDecay(HUNGER_DECAY, ENERGY_DECAY, FOOD_DECAY); util.setRecover(0,0,0); plan = new List<int>(); knowledge = new List<WObject>(); property = new List<WObject>(); people = new List<Agent>(); goal = new Utility(0,0,0); goalObject = null; home = null; }
public void Add(Utility u) { hunger += u.hunger; energy += u.energy; foodStores += u.foodStores; }
private void Use(Utility u) { util.Add(u); }
/* * This logic code makes use of the utility metric to make its decisions in as close to an approximation to human behavior has possible, * basing its choices on Maslow's Heirarchy of Needs. It is called on each update, and performs the following procedure: * * 1. Calls the utility's Decay function, emulating regular use of resources such as food and energy. * * 2. Examines remaining utility and determines what is the highest priority based on increasing preference to lower levels of the heirarchy. * For example, if the agent is low on hunger, they will attempt to find food. If both hunger and energy (1st level) are satisfied * and there is no immediate danger(2nd level), the agent will reach out into social activities(3rd level) * * 3. If there are no immedaite needs, the agent will attempt to predict a future possible need and if action is required, such as * working a farmland for food now so that there is food available later, even if the agent is not immedaitely hungry. * * 4. Once the end result is determined, the agent will search through its knowledgebase for a world object that will satisfy its * decision. World objects include houses, farmland, stores, and even people. Agents have a limited 'vision', and must discover new * objects before they are added to its knowledgebase. The choice of object to use will depend on its available and relevant utility, * and its distance from the agent (particularly for time-critical utility like food). * * 5. After an object to use is selected, the coordinates for that object are set as the new destination and the agent moves toward * their destination. */ private void maslowLogic() { //Note to self: should the logic only be called at destinations/impulse events to cut down on aimless wandering/cycle use? //1. Calls the utility's Decay function, emulating regular use of resources such as food and energy. util.Decay(); /* * 2. Examines remaining utility and determines what is the highest priority based on increasing preference to lower levels of the heirarchy. * For example, if the agent is low on hunger, they will attempt to find food. If both hunger and energy (1st level) are satisfied * and there is no immediate danger(2nd level), the agent will reach out into social activities(3rd level) */ //Level 1 if (util.hunger < util.concern) { goal = new Utility(util.stable, util.stable); Console.WriteLine("Food Concern"); if (util.hunger < util.critical) { Console.WriteLine("Food Critical"); /*goal hunger = concern*/ } } /* if (util.energy < util.concern) { //Goal energy = stable if (util.energy < util.critical) { //goal energy = concern * } }/**/ /*if (level2) //If both hunger and energy are not critical { //level 2 evaluation }*/ //find level 1 if (goal != null) { if (!util.Met(goal)) { WObject choice = null; foreach (WObject o in knowledge) { choice = o; } if (choice != null) setDest(choice.getPos()); } else { goal = null; setDest(D2); } } if (atDest()) { if (destination.Equals(D1)) destination = D2; else if (destination.Equals(D2)) destination = D1; } }
public void Add(Utility u) { hunger += u.hunger; energy += u.energy; }