Exemplo n.º 1
0
        public double Utility(Desire desire, int count)
        {
            if (count == 0)
            {
                return(0);
            }
            double t = ((double)count / (double)desire.sufficient) * 4 - 2;
            double S = 1.0 / (1.0 + Math.Pow(MathHelper.E, -t));

            return(S * desire.level);
        }
Exemplo n.º 2
0
        public NPC(Vector2 pos, ContentManager content)
        {
            state             = new RestingState();
            this.pos          = pos;
            firstName         = RandUtil.Index(namePool);
            npcClass          = RandUtil.Index(classPool);
            lastAnimationTime = TimeSpan.FromMilliseconds(0);
            inventory         = new Inventory();

            facing = CharSprites.DOWN;

            if (RandUtil.Bool())
            {
                gender = Gender.Male;
            }
            else
            {
                gender = Gender.Female;
            }

            //Give them some things relevant to their class
            int numItems = RandUtil.Int(0, 5);

            for (int i = 0; i < numItems; i++)
            {
                inventory.Add(new Item(RandUtil.Index(npcClass.desires), 1));
            }



            desires = new HashSet <Desire>();
            var numDesires = RandUtil.Int(0, 4);

            for (int i = 0; i < numDesires; i++)
            {
                var    item       = RandUtil.Index(npcClass.desires);
                var    level      = RandUtil.Int(1, 10);
                var    sufficient = RandUtil.Int(1, 10);
                Desire d          = new Desire(new Item(item, 0), level, sufficient);
                desires.Add(d);
            }

            var lastNamePrefx  = RandUtil.Index(npcClass.lastNamePrefixes);
            var lastNameSuffix = RandUtil.Index(npcClass.lastNameSuffixes);

            lastName = lastNamePrefx + lastNameSuffix;

            personality = RandUtil.Index(personalityPool);
        }