當前位置: 首頁>>代碼示例>>C#>>正文


C# ActiveSite.GetNeighbor方法代碼示例

本文整理匯總了C#中ActiveSite.GetNeighbor方法的典型用法代碼示例。如果您正苦於以下問題:C# ActiveSite.GetNeighbor方法的具體用法?C# ActiveSite.GetNeighbor怎麽用?C# ActiveSite.GetNeighbor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ActiveSite的用法示例。


在下文中一共展示了ActiveSite.GetNeighbor方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Algorithm

        //---------------------------------------------------------------------

        public static bool Algorithm(ISpecies   species,
                                     ActiveSite site)
        {
            //if (species.EffectiveSeedDist == EffectiveSeedDist.Universal)
            //if (species.EffectiveSeedDist == Landis.Species.EffectiveSeedDist.Universal)
            if (species.EffectiveSeedDist == Universal)
                return UniversalDispersal.Algorithm(species, site);

            if (! Reproduction.SufficientResources(species, site)) {
                if (isDebugEnabled)
                    log.DebugFormat("site {0}: {1} not seeded: insufficient light",
                                    site.Location, species.Name);
                return false;
            }

            if (! Reproduction.Establish(species, site)) {
                if (isDebugEnabled)
                    log.DebugFormat("site {0}: {1} not seeded: cannot establish",
                                    site.Location, species.Name);
                return false;
            }

            // if (Reproduction.MaturePresent(species, site)) {
            if (SiteVars.Cohorts[site].IsMaturePresent(species)) {
                if (isDebugEnabled)
                    log.DebugFormat("site {0}: {1} seeded on site",
                                    site.Location, species.Name);
                return true;
            }

            if (isDebugEnabled)
                log.DebugFormat("site {0}: search neighbors for {1}",
                                site.Location, species.Name);

            //UI.WriteLine("   Ward seed disersal.  Spp={0}, site={1},{2}.", species.Name, site.Location.Row, site.Location.Column);
            foreach (RelativeLocationWeighted reloc in Seeding.MaxSeedQuarterNeighborhood)
            {
                double distance = reloc.Weight;
                int rRow = (int) reloc.Location.Row;
                int rCol = (int) reloc.Location.Column;
                
                double EffD = (double) species.EffectiveSeedDist;
                double MaxD = (double) species.MaxSeedDist;
                    
                if(distance > MaxD + ((double) Model.Core.CellLength / 2.0 * 1.414)) 
                    return false;  //Check no further
                    
                double dispersalProb = GetDispersalProbability(EffD, MaxD, distance);
                //UI.WriteLine("      DispersalProb={0}, EffD={1}, MaxD={2}, distance={3}.", dispersalProb, EffD, MaxD, distance);

                //First check the Southeast quadrant:
                if (dispersalProb > Model.Core.GenerateUniform())
                {
                    Site neighbor = site.GetNeighbor(reloc.Location);
                    if (neighbor != null && neighbor.IsActive)
                        // if (Reproduction.MaturePresent(species, neighbor)) 
                        if (SiteVars.Cohorts[site].IsMaturePresent(species))
                            return true;
                }                              
                
                //Next, check all other quadrants:        
                if (dispersalProb > Model.Core.GenerateUniform())
                {
                    Site neighbor = site.GetNeighbor(new RelativeLocation(rRow * -1, rCol));
                    if(rCol == 0)
                        neighbor = site.GetNeighbor(new RelativeLocation(0, rRow));
                    if (neighbor != null && neighbor.IsActive)
                        // if (Reproduction.MaturePresent(species, neighbor)) 
                        if (SiteVars.Cohorts[site].IsMaturePresent(species))
                            return true;
                }

                if (dispersalProb > Model.Core.GenerateUniform())
                {
                    Site neighbor = site.GetNeighbor(new RelativeLocation(rRow * -1, rCol * -1));
                    if (neighbor != null && neighbor.IsActive)
                        // if (Reproduction.MaturePresent(species, neighbor)) 
                        if (SiteVars.Cohorts[site].IsMaturePresent(species))
                            return true;
                 }

                if (dispersalProb > Model.Core.GenerateUniform())
                {
                    Site neighbor = site.GetNeighbor(new RelativeLocation(rRow, rCol * -1));
                    if(rCol == 0)
                        neighbor = site.GetNeighbor(new RelativeLocation(0, rRow * -1));
                    if (neighbor != null && neighbor.IsActive)
                        // if (Reproduction.MaturePresent(species, neighbor)) 
                        if (SiteVars.Cohorts[site].IsMaturePresent(species))
                            return true;
                }

            }  // end foreach relativelocation

            return false;
        }
開發者ID:LANDIS-II-Foundation,項目名稱:Libraries,代碼行數:98,代碼來源:WardSeedDispersal.cs


注:本文中的ActiveSite.GetNeighbor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。