Ejemplo n.º 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
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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>();
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 7
0
        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;
            }
        }
Ejemplo n.º 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()));
     }
 }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        public void Run(IPersonality personality)
        {
            if (m_timer == null)
            {
                m_timer = Stopwatch.StartNew();
            }
            else
            {
                m_timer.Restart();
            }

            Personality = personality;
        }
Ejemplo n.º 11
0
        public int CompareTo(IPersonality other)
        {
            int nameComp = Name.CompareTo(other.Name);

            if (nameComp == 0)
            {
                return(Age.CompareTo(other.Age));
            }
            else
            {
                return(nameComp);
            }
        }
Ejemplo n.º 12
0
        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")
            };
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 14
0
 public Greeter(IPersonality personality)
 {
     _personality = personality;
 }
Ejemplo n.º 15
0
 public void AddToDictionary(IPersonality p)
 {
     personalities.Add(p.getSetName, p);
 }
Ejemplo n.º 16
0
        public void CreatePersonality <T>() where T : IPersonality, new()
        {
            personality = new T();

            AddToDictionary(personality);
        }
Ejemplo n.º 17
0
 public static IWriteFile GetLstFromPP(this ppParser pp, IPersonality personality)
 {
     string file = personality.LSTLocation.GetFilename('/');
     return pp.Subfiles.First(iw => iw.Name == file);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 19
0
 public Speaker(IPersonality personality)
 {
     _personality = personality;
     _synth = new SpeechSynthesizer();
 }
Ejemplo n.º 20
0
        public static IWriteFile GetLst(this IPersonality personality)
        {
            string file = personality.LSTLocation.GetFilename('/');

            return(personality.GetLstPP().Subfiles.First(iw => iw.Name == file));
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 22
0
 public Outfit CreateEmptyOutfit(IPersonality o)
 {
     return OutfitProvider.CreateEmptyOutfit(o);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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
        }