Exemplo n.º 1
0
 private void initializeDrops()
 {
     _drops = new Drop2[_populationSize];
     for (int i = 0; i < _populationSize; i++)
     {
         _drops[i] = new Drop2();
     }
 }
Exemplo n.º 2
0
 private void ErodePath(Drop2 drop)
 {
     for (int i = 0; i < drop.path.Count - 1; i++)
     {
         NodeXY a       = _nodes[drop.path[i]];
         NodeXY b       = _nodes[drop.path[i + 1]];
         double erosion = CalculateErosion(a, b) / drop.pathLength;
         a.Height         -= erosion;
         _erosionProduced += erosion;
     }
 }
Exemplo n.º 3
0
        private void moveDrop(Drop2 drop, double climbingProbability)
        {
            drop.evaporated  = false;
            drop.canClimb    = false;
            drop.path        = new List <int>();
            drop.pathLength  = 0.0;
            drop.sediment    = 0.0;
            drop.currentNode = _nodes[_source];
            drop.path.Add(_source);

            double rC = _rng.NextDouble();

            if (rC <= climbingProbability)
            {
                drop.canClimb = true;
            }

            while (drop.currentNode.Index != _target && !drop.evaporated)
            {
                int    nextNodeIdx = PickNextNode(drop.currentNode);
                NodeXY nextNode    = drop.currentNode.Neighbours[nextNodeIdx];

                if (drop.path.Count >= _nodes.Count)
                {
                    drop.evaporated = true;
                    break;
                }

                drop.pathLength += drop.currentNode.NeighbourDistance[nextNodeIdx];
                drop.currentNode = nextNode;
                drop.path.Add(nextNode.Index);
            }

            if (drop.evaporated)
            {
            }
            else
            {
                ErodePath(drop);

                if (drop.pathLength < drop.bestPathLength)
                {
                    drop.bestPathLength = drop.pathLength;
                    drop.bestPath       = new List <int>(drop.path);
                }

                if (drop.pathLength < _bestPathLength)
                {
                    _bestPathLength = drop.pathLength;
                    _bestPath       = new List <int>(drop.path);
                }
            }
        }