// sets about indices to purely random
    // complex entities of specified type
    public static void SetIndicesByPureRandom(
        BaseSimpleEntity beingFilled,
        SimpleEntitySharedData sharedData,
        World w)
    {
        Random randomEngine = new Random();

        for (int i = 0; i < beingFilled.about.Count; i++)
        {
            // negative value in "about" indicates no set index
            if (beingFilled.about[i] < 0)
            {
                var targetType = sharedData.aboutSpecs[i].targetType;

                int ranNum;
                switch (targetType)
                {
                case COMPLEX_ENTITY_TYPE.CHARACTER:
                    ranNum = randomEngine.Next(w.characters.Count);
                    beingFilled.about[i] = ranNum;
                    break;

                case COMPLEX_ENTITY_TYPE.COLLECTIVE:
                    ranNum = randomEngine.Next(w.collectives.Count);
                    beingFilled.about[i] = ranNum;
                    break;

                default:
                    throw new Exception("Type neither character nor collective");
                }
            }
        }
    }
예제 #2
0
    /*
     *  1) get all relevant CareAbouts for each index's
     *  IndexFillSpecification at each index that is not set
     *  2) for all non-set indices, get all targeted complex entities
     *  3) for all non-set indices, assign id of the complex entity with highest score
     */
    public static void SetIndiciesByCareAbout(
        BaseSimpleEntity beingFilled,
        SimpleEntitySharedData beingFilledSharedData,
        Collective c)
    {
        int numOfFillSpecs = beingFilledSharedData.aboutSpecs.Count;

        for (int i = 0; i < numOfFillSpecs; i++)
        {
            // the specification for how to fill the associated
            // index with a complex entity id
            IndexSpecification spec = beingFilledSharedData.aboutSpecs[i];

            // negative value in "about" indicates no set index
            if (spec.fillType <= INDEX_FILL_TYPE.CARE_ABOUT_FIRST &&
                beingFilled.about[i] < 0)
            {
                List <CareAbout> temp = new List <CareAbout>();

                for (int j = 0; j < c.controllingCharacters.Count; j++)
                {
                    var character = c.controllingCharacters[j];

                    // all CareAbouts that have any of the specified IDs
                    temp.AddRange(GetRelevantCareAbouts(character, spec));
                }

                beingFilled.about[i] = GetHighestScoringComplexEntityID(temp);
            }
        }
    }
예제 #3
0
    // compiles a description with the full names of all referenced entities
    public string GetDescription(int worldID, SimpleEntitySharedData sharedData)
    {
        if (sharedData.description.Contains("@"))
        {
            string[]      descriptionParts = sharedData.description.Split('@');
            StringBuilder builder          = new StringBuilder();

            for (int i = 0; i < descriptionParts.Length; i++)
            {
                builder.Append(descriptionParts[i]);

                // if it's not of type character, then collective is assumed
                BaseComplexEntity entity = (sharedData.aboutSpecs[i].targetType == COMPLEX_ENTITY_TYPE.CHARACTER) ?
                                           entity                   = Command.worlds[worldID].characters[about[i]] :
                                                             entity = Command.worlds[worldID].collectives[about[i]];

                builder.Append(entity.GetName(entity.categoryNumbers));
            }

            return(builder.ToString());
        }

        else
        {
            return(sharedData.description);
        }
    }
예제 #4
0
 public static void ForwardIndices(
     BaseSimpleEntity beingFilled,
     SimpleEntitySharedData sharedData,
     List <int> indicesToForward)
 {
     for (int i = 0; i < indicesToForward.Count; i++)
     {
         // negative value in "about" indicates no set index
         if (sharedData.aboutSpecs[i].fillType == INDEX_FILL_TYPE.INDEX_FORWARDING_FIRST &&
             beingFilled.about[i] < 0)
         {
             beingFilled.about[i] = indicesToForward[i];
         }
     }
 }
예제 #5
0
    // returns -1 if registration failed,
    // else it returns the new resources' id
    public static int RegisterNewSharedDataResource(SimpleEntitySharedData newResource)
    {
        Type check = newResource.GetType();

        if (newResource != null)
        {
            if (check == typeof(CharacterSituationSharedData))
            {
                var r = (CharacterSituationSharedData)newResource;
                characterSituations.Add(r);
                return(characterSituations.Count - 1);
            }
            else if (check == typeof(CharacterOptionSharedData))
            {
                var r = (CharacterOptionSharedData)newResource;
                characterOptions.Add(r);
                return(characterOptions.Count - 1);
            }
            else if (check == typeof(CharacterForecastSharedData))
            {
                var r = (CharacterForecastSharedData)newResource;
                characterForecasts.Add(r);
                return(characterForecasts.Count - 1);
            }
            else if (check == typeof(CollectiveSituationSharedData))
            {
                var r = (CollectiveSituationSharedData)newResource;
                collectiveSituations.Add(r);
                return(collectiveSituations.Count - 1);
            }
            else if (check == typeof(CollectiveOptionSharedData))
            {
                var r = (CollectiveOptionSharedData)newResource;
                collectiveOptions.Add(r);
                return(collectiveOptions.Count - 1);
            }
            else if (check == typeof(CollectiveForecastSharedData))
            {
                var r = (CollectiveForecastSharedData)newResource;
                collectiveForecasts.Add(r);
                return(collectiveForecasts.Count - 1);
            }

            return(-1);
        }

        return(-1);
    }
예제 #6
0
    // gets a list of all potential candidate complex entities
    // that match any of the required category numbers, for then
    // to choose a random candidate
    public static void SetIndicesByCategoryNumbers(
        BaseSimpleEntity beingFilled,
        SimpleEntitySharedData sharedData,
        World w)
    {
        Random randomEngine = new Random();

        for (int i = 0; i < beingFilled.about.Count; i++)
        {
            // negative value in "about" indicates no set index
            if (beingFilled.about[i] < 0)
            {
                var tempFillSpecs = sharedData.aboutSpecs[i];

                List <int> candidates = w.GetComplexEntitiesByCategory(
                    tempFillSpecs.categoryNumbers,
                    tempFillSpecs.targetType);

                int ranNum = randomEngine.Next(candidates.Count);
                beingFilled.about[i] = candidates[ranNum];
            }
        }
    }
    /*
     *  1) get all relevant CareAbouts for each index's
     *  IndexFillSpecification at each index that is not set
     *  2) for all non-set indices, get all targeted complex entities
     *  3) for all non-set indices, assign id of the complex entity with highest score
     */
    public static void SetIndiciesByCareAbout(
        BaseSimpleEntity beingFilled,
        SimpleEntitySharedData beingFilledSharedData,
        Character c)
    {
        int numOfFillSpecs = beingFilledSharedData.aboutSpecs.Count;

        for (int i = 0; i < numOfFillSpecs; i++)
        {
            // the specification for how to fill the associated
            // index with a complex entity id
            IndexSpecification spec = beingFilledSharedData.aboutSpecs[i];

            // negative value in "about" indicates no set index
            if (spec.fillType <= INDEX_FILL_TYPE.CARE_ABOUT_FIRST &&
                beingFilled.about[i] < 0)
            {
                // all CareAbouts that have any of the specified IDs
                var temp = GetRelevantCareAbouts(c, spec);

                beingFilled.about[i] = GetHighestScoringComplexEntityID(temp);
            }
        }
    }