예제 #1
0
        // Should generate a deep copy of self
        private SimulationObject GenerateNextAgent(List<KeyValPair> curCom,
            SimulationObject prvAgnt, string genDim)
        {
            double currMax = (double)
                ((KeyValPair)curCom[curCom.Count - 1]).Value;
            if(currMax != 0.00)
            {
                double randVal = randGen.NextDoubleInRange(0, currMax);
                for(int i = 0; i < curCom.Count; i++)
                {
                    if(randVal <= ((KeyValPair)curCom[i]).Value)
                    {
                        return prvAgnt.CreateNewCopy(genDim, i);
                    }
                }

            }
            else
            {
                return prvAgnt.CreateNewCopy(genDim,
                    randGen.NextInRange(0, (curCom.Count - 1)));
            }
            return null;
        }