// 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"); } } } }
/* * 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); } } }
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]; } } }
// 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); } } }