コード例 #1
0
ファイル: EventPopulator.cs プロジェクト: fgeraci/CS195-Core
    /// <summary>
    /// Takes a list of world SmartObjects and an EventDescriptor and creates
    /// one bin for each of the event's participant slot containing the
    /// objects that satisfy that slot's State (not Relation) requirements.
    /// Makes sure that any index in fixedSlots only considers the accompanied
    /// SmartObject. Does however not check state for those.
    /// </summary>
    private static BinHolder BinIntoParameterSlots(
        EventDescriptor evtDesc,
        IEnumerable<IHasState> objs,
        IDictionary<int, IHasState> fixedSlots = null)
    {
        StateName[][] stateReqs = evtDesc.StateRequirements;
        BinHolder bins = new BinHolder(stateReqs.Length);

        for (int i = 0; i < stateReqs.Length; i++)
        {
            if (fixedSlots != null && fixedSlots.ContainsKey(i) == true)
                bins.AddBin(new IHasState[] { fixedSlots[i] });
            else
                bins.AddBin(Filter.ByState(objs, stateReqs[i]));
        }

        return bins;
    }
コード例 #2
0
ファイル: EventPopulator.cs プロジェクト: fgeraci/CS195-Core
    /// <summary>
    /// Given a bin holder, creates all variations of event populations
    /// without using a single object in more than one slot
    /// </summary>
    private static List<EventPopulation> GetPopulations(
        EventDescriptor evtDesc,
        BinHolder bins)
    {
        int slots = bins.Count;
        if (slots == 0)
            return new List<EventPopulation>();

        // Convert the first bin to a list of EventPopulations
        List<EventPopulation> result =
            bins[0].Convert(s => new EventPopulation(slots, s));

        for (int i = 1; i < slots; i++)
            result = AddBin(evtDesc, result, bins[i]);

        return result;
    }