Exemple #1
0
        public Enemy(string name, Actor actor, float speed, int _health)
            : base(name, actor)
        {
            FrostbyteLevel l = This.Game.LoadingLevel as FrostbyteLevel;

            Personality    = new WanderingMinstrelPersonality(this);
            UpdateBehavior = update;
            l.enemies.Add(this);
            EndBehavior            = Die;
            Speed                  = speed;
            Health                 = _health;
            CollidesWithBackground = true;

            #region HealthBar
            float alpha = 0.15f;
            healthBar = new ProgressBar("Health_" + Name, MaxHealth,
                                        Color.Black * 0, Color.Red * 0.5f, Color.Black * alpha, barSize);
            healthBar.Pos    = Pos - l.Camera.Pos + new Vector2(0, -20);
            healthBar.Static = true;
            healthBar.Value  = MaxHealth;

            HealthChanged += delegate(object obj, int value)
            {
                if (healthBar != null)
                {
                    healthBar.Value = value;
                    if (value == 0)
                    {
                        This.Game.CurrentLevel.RemoveSprite(healthBar);
                    }
                }
            };
            #endregion
        }
        public float Evaluate(AnalysisNode node, IPersonality personality)
        {
            m_white_data.Init(node.Position);
            m_black_data.Init(node.Position);

            ulong white_good_cells = 0;
            ulong black_good_cells = 0;

            float white_value = m_white_data.m_material;
            float black_value = m_black_data.m_material;

            // TODO - if not endgame..
            white_good_cells = CentralSquares;
            black_good_cells = CentralSquares;

            // TODO - create arrays for pawns, we need them anyway
            var white_pieces = node.Position.GetPieces(Players.White);
            var black_pieces = node.Position.GetPieces(Players.Black);

            var white_good_cells_count = CountGoodCells(white_good_cells,
                Players.White, white_pieces);
            var black_good_cells_count = CountGoodCells(black_good_cells,
                Players.Black, black_pieces);

            // TODO - consider here optimistic and pessimistic players
            white_value += 0.05f * white_good_cells_count;
            black_value += 0.05f * black_good_cells_count;

            // TODO - do more
            return white_value - black_value;
        }
Exemple #3
0
        private void cmbPersonality_SelectedIndexChanged(object sender, EventArgs e)
        {
            IPersonality personality = Personalities.ElementAt(cmbPersonality.SelectedIndex).Value;

            if (card != null)
            {
                card.data.PROFILE_PERSONALITY_ID = personality.Slot;
            }
        }
Exemple #4
0
        public static ppParser GetIcfPP(this IPersonality personality)
        {
            string path = Paths.AA2Play + "\\" + personality.ICFLocation;

            if (!File.Exists(path))
            {
                path = Paths.AA2Edit + "\\" + personality.ICFLocation;
            }
            return(new ppParser(path));
        }
Exemple #5
0
 /// <summary>
 /// Base constructor
 /// </summary>
 public NonPlayerCharacterTemplate()
 {
     WillPurchase          = new HashSet <IMerchandise>();
     WillSell              = new HashSet <IMerchandise>();
     InventoryRestock      = new HashSet <MerchandiseStock>();
     TeachableProficencies = new HashSet <IQuality>();
     Personality           = new Personality();
     Race         = new Race();
     Descriptives = new HashSet <ISensoryEvent>();
 }
Exemple #6
0
        public static ppParser GetLstPP(this IPersonality personality)
        {
            string path = Paths.AA2Play + "\\" + personality.LSTLocation.RemoveFilename('/');

            if (!File.Exists(path))
            {
                path = Paths.AA2Edit + "\\" + personality.LSTLocation.RemoveFilename('/');
            }
            return(new ppParser(path));
        }
        public void GetDressed(IPersonality person)
        {
            foreach (var outfit in person.Outfits)
            {
                var gearset = outfit.GearPieceIds.Select(o =>
                    GetGearPiece(o))
                    .ToDictionary(x => x.BodyPart, x => x);

                outfit.GearSet = gearset;
            }
        }
Exemple #8
0
 public static PersonalityLST LoadLST(this IPersonality p)
 {
     if (p.Custom)
     {
         return(new CustomPersonalityLST(p.GetLst().ToStream().ToArray()));
     }
     else
     {
         return(new PersonalityLST(p.GetLst().ToStream().ToArray()));
     }
 }
        public void AddOufit(IPersonality person, Outfit outfit)
        {
            var previous = person.Outfits
                .FirstOrDefault(o =>
                    o.Period == outfit.Period
                    && o.Name == outfit.Name);

            if (previous != null)
                person.Outfits.Remove(previous);

            person.Outfits.Add(outfit);
        }
        public void Run(IPersonality personality)
        {
            if (m_timer == null)
            {
                m_timer = Stopwatch.StartNew();
            }
            else
            {
                m_timer.Restart();
            }

            Personality = personality;
        }
        public int CompareTo(IPersonality other)
        {
            int nameComp = Name.CompareTo(other.Name);

            if (nameComp == 0)
            {
                return(Age.CompareTo(other.Age));
            }
            else
            {
                return(nameComp);
            }
        }
        public static Outfit CreateEmptyOutfit(IPersonality owner)
        {
            string imgPath = ImagePath + "NoOutfit.png";

            var emptyPieces = GetGearPieces()
                .Where(o => o.Name.StartsWith("Empty"));

            return new Outfit
            {
                ImageSource = Path.GetFullPath(imgPath),
                GearSet = emptyPieces.ToDictionary(o => o.BodyPart, o => o),
            Dye = GetDyes().FirstOrDefault(o => o.Name == "Empty Dye")
            };
        }
Exemple #13
0
        /// <summary>
        /// Returns a list of all behaviours which have the Personality type of mindP
        /// </summary>
        /// <param name="mindP">The personality state the mind is currently in</param>
        /// <returns></returns>
        public IList <IState> getAvailableBehaviours(IPersonality mindP)
        {
            IList <IState> list = new List <IState>();

            //foreach (KeyValuePair<IState, IPersonality> p in behaves)
            //{
            //    if (p.Value == mindP)
            //    {
            //        list.Add(p.Key);
            //    }
            //}

            return(list);
        }
Exemple #14
0
 public Greeter(IPersonality personality)
 {
     _personality = personality;
 }
Exemple #15
0
 public void AddToDictionary(IPersonality p)
 {
     personalities.Add(p.getSetName, p);
 }
Exemple #16
0
        public void CreatePersonality <T>() where T : IPersonality, new()
        {
            personality = new T();

            AddToDictionary(personality);
        }
Exemple #17
0
 public static IWriteFile GetLstFromPP(this ppParser pp, IPersonality personality)
 {
     string file = personality.LSTLocation.GetFilename('/');
     return pp.Subfiles.First(iw => iw.Name == file);
 }
Exemple #18
0
        /// <summary>
        /// Get an ordered list of employment for the last three years at random
        /// </summary>
        /// <param name="options"></param>
        /// <param name="personality"></param>
        /// <param name="eduLevel"></param>
        /// <param name="emplyRanges">
        /// Optional, allows calling assembly to set this directly, defaults to <see cref="GetEmploymentRanges"/>
        /// </param>
        /// <returns></returns>
        protected internal virtual List <ILaboris> GetRandomEmployment(AmericanDomusOpesOptions options, IPersonality personality = null,
                                                                       OccidentalEdu eduLevel = OccidentalEdu.None, List <Tuple <DateTime, DateTime?> > emplyRanges = null)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();
            var empls = new HashSet <ILaboris>();

            emplyRanges = emplyRanges ?? GetEmploymentRanges(options, personality);

            //limit result to those which match the edu level
            Predicate <SocDetailedOccupation> filter = null;

            if (eduLevel < (OccidentalEdu.Bachelor | OccidentalEdu.Grad))
            {
                filter = s => !StandardOccupationalClassification.IsDegreeRequired(s);
            }

            var occ = StandardOccupationalClassification.RandomOccupation(filter);

            foreach (var range in emplyRanges)
            {
                var emply = new AmericanEmployment()
                {
                    Occupation = occ
                };
                var cloneOptions = options.GetClone();
                cloneOptions.Inception = range.Item1;
                cloneOptions.Terminus  = range.Item2;
                emply.RandomizeAllItems(options);
                empls.Add(emply);
            }

            var e = empls.ToList();

            e.Sort(Comparer);
            return(e);
        }
Exemple #19
0
 public Speaker(IPersonality personality)
 {
     _personality = personality;
     _synth = new SpeechSynthesizer();
 }
Exemple #20
0
        public static IWriteFile GetLst(this IPersonality personality)
        {
            string file = personality.LSTLocation.GetFilename('/');

            return(personality.GetLstPP().Subfiles.First(iw => iw.Name == file));
        }
Exemple #21
0
        public void Run(IPersonality personality)
        {
            // TODO - restore the check
            Debug.Assert(/*personality != null &&*/ CurrentPosition != null);

            m_stats = new AnalysisStats();
            m_stats.Run(personality);
            m_stats.UpdateBestLine(m_tree.Root, false);

            var legal_moves = GetLegalMoves();
            if (legal_moves.Count == 0
                // Only one legal move - play it without doubt
                || legal_moves.Count == 1)
            {
                return;
            }

            // Check the current node for the deterministic evaluation
            // (checkmate, stalemate or some other draw)
            // TODO

            m_tree.Root.ResetMinmaxEvaluation();
            MakeStaticEvaluation(m_tree.Root);

            // TODO - init properly
            //int buffer_capacity = 1500000;
            ulong max_node_count = 10000000;

            for (int depth = 1; m_stats.NodesEvaluated < max_node_count; depth += 2)
            {
                Run(m_tree.Root, depth, max_node_count);
            }

            MinMax.Evaluate(m_tree.Root);
            m_stats.UpdateBestLine(m_tree.Root, true);
            m_stats.Stop();

            // Clean the tree and restore root's children
            CleanAnalysisTree();
        }
 public Outfit CreateEmptyOutfit(IPersonality o)
 {
     return OutfitProvider.CreateEmptyOutfit(o);
 }
Exemple #23
0
        /// <summary>
        /// Gets a list of time ranges over for all the years of this income&apos;s start date (and then some).
        /// Each block is assumed as a span of employment at one single employer.
        /// </summary>
        /// <param name="options"></param>
        /// <param name="personality"></param>
        /// <returns></returns>
        protected internal virtual List <Tuple <DateTime, DateTime?> > GetEmploymentRanges(AmericanDomusOpesOptions options,
                                                                                           IPersonality personality = null)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();
            var emply = new List <Tuple <DateTime, DateTime?> >();

            //make it appear as if the start date is randomly before options start date
            var sdt = options.Inception;

            sdt = sdt == DateTime.MinValue
                ? Etx.RandomDate(-3, DateTime.Today, true).Date
                : sdt.AddDays(Etx.RandomInteger(0, 360) * -1);

            //TODO - tie this together with personality
            var tenure = AmericanEmployment.RandomEmploymentTenure(options);
            var lpDt   = sdt;

            while (lpDt < DateTime.Today)
            {
                var randDays = Etx.RandomInteger(0, 21);
                lpDt = lpDt.AddMonths(3).AddDays(randDays);

                if (lpDt <= sdt.Add(tenure))
                {
                    continue;
                }
                emply.Add(new Tuple <DateTime, DateTime?>(sdt, lpDt < DateTime.Today ? new DateTime?(lpDt) : null));
                sdt    = lpDt;
                tenure = AmericanEmployment.RandomEmploymentTenure(options);
            }
            if (!emply.Any())
            {
                emply.Add(new Tuple <DateTime, DateTime?>(Etx.RandomDate(-4, DateTime.Today, true).Date, null));
            }
            return(emply);
        }
Exemple #24
0
        public Enemy(string name, Actor actor, float speed, int _health)
            : base(name, actor)
        {
            FrostbyteLevel l = This.Game.LoadingLevel as FrostbyteLevel;
            Personality = new WanderingMinstrelPersonality(this);
            UpdateBehavior = update;
            l.enemies.Add(this);
            EndBehavior = Die;
            Speed = speed;
            Health = _health;
            CollidesWithBackground = true;

            #region HealthBar
            float alpha = 0.15f;
            healthBar = new ProgressBar("Health_" + Name, MaxHealth,
                Color.Black * 0, Color.Red * 0.5f, Color.Black * alpha, barSize);
            healthBar.Pos = Pos - l.Camera.Pos + new Vector2(0, -20);
            healthBar.Static = true;
            healthBar.Value = MaxHealth;

            HealthChanged += delegate(object obj, int value)
            {
                if (healthBar != null)
                {
                    healthBar.Value = value;
                    if (value == 0)
                    {
                        This.Game.CurrentLevel.RemoveSprite(healthBar);
                    }
                }
            };
            #endregion
        }