Esempio n. 1
0
 void CheckWood()
 {
     if (RunTo(work.transform.position, 1.6f)) //если охотник близко к дереву
     {
         TreeBuild tempWork = work.GetComponent <TreeBuild>();
         if (tempWork)
         {
             if (tempWork.progress >= 100)
             {
                 axing          = false;
                 tempWork.axing = false;
                 work           = null;
             }
             else
             {
                 axing          = true;
                 tempWork.axing = true;
             }
             return;
         }
     }
     else //если охотник далеко от дерева
     {
         axing = false;
         GetUp();
         maxSpeed = 4f;
     }
 }
Esempio n. 2
0
        private void MakeTree()
        {
            if (_patriarch == null)
            {
                var ged = LoadGEDFromStream(gedcom);
                _patriarch = ged.PersonById("I1");
            }

            var tree = TreeBuild.BuildTree(treePanel21, _settings, _patriarch);

            var nodeExtentProvider = new NodeExtents();
            var treeLayout         = new TreeLayout <ITreeData>(tree, nodeExtentProvider, _settings, false);

            treePanel21.Boxen = treeLayout;
        }
Esempio n. 3
0
        private void TreePerson(Person val)
        {
            var config = TreeConfiguration.LoadConfig();

            config.MaxDepth = (int)spinMaxGen.Value;

            var tree = TreeBuild.BuildTree(treePanel1, config, val);

            // create the NodeExtentProvider for TextInBox nodes
            var nodeExtentProvider = new NodeExtents();

            // create the layout
            var treeLayout = new TreeLayout <ITreeData>(tree, nodeExtentProvider, config, !tree.getRoot().IsReal);

            treePanel1.Boxen = treeLayout;
        }
Esempio n. 4
0
 void CheckWork()
 {
     if (RunTo(work.transform.position, 1.6f)) //если понь близко к работе
     {
         TreeBuild tempWork = work.GetComponent <TreeBuild>();
         if (tempWork)
         {
             if (tempWork.progress >= 100)
             {
                 axing          = false;
                 tempWork.axing = false;
                 work           = null;
             }
             else
             {
                 axing          = true;
                 tempWork.axing = true;
             }
             return;
         }
         WeaponBuilding tempWork1 = work.GetComponent <WeaponBuilding>();
         if (tempWork1)
         {
             anim.SetBool("sit", true);
             sit = true;
             transform.position = tempWork1.workerPosition.position;
             positionY          = tempWork1.workerPosition.position.y;
             return;
         }
         FarmBuild tempWork2 = work.GetComponent <FarmBuild>();
         if (tempWork2)
         {
             anim.SetBool("sit", true);
             sit = true;
             transform.position = tempWork2.workerPosition.position;
             positionY          = tempWork2.workerPosition.position.y;
             return;
         }
     }
     else //если понь далеко от работы
     {
         axing = false;
         GetUp();
         maxSpeed = 4f;
     }
 }
        public void LearnModel()
        {
            Init();
            foreach (Feature currFeature in DomPool.SelectorFeatures)
            {
                String             featureString = currFeature.ToString();
                HashSet <HtmlNode> resNodes      = DomPool.RunXpathQuery(featureString);
                foreach (HtmlNode nd in resNodes)
                {
                    if (!allNodes.Contains(nd))
                    {
                        continue;
                    }
                    nodeFeatures[nd].Add(featureString);
                }
            }

            FastVector fvWekaAttributes = GetDataSetAtts();
            Instances  trainingSet      = new Instances("TS", fvWekaAttributes, 100);

            trainingSet.setClassIndex(fvWekaAttributes.size() - 1);

            foreach (HtmlNode currNode in allNodes)
            {
                Instance item = new SparseInstance(fvWekaAttributes.size());

                for (int i = 0; i < fvWekaAttributes.size() - 1; i++)
                {
                    weka.core.Attribute currFeature = (weka.core.Attribute)fvWekaAttributes.elementAt(i);
                    if (nodeFeatures[currNode].Contains(currFeature.name()))
                    {
                        item.setValue(currFeature, 1);
                    }
                    else
                    {
                        item.setValue(currFeature, 0);
                    }
                }

                //set the class
                weka.core.Attribute classFeature = (weka.core.Attribute)fvWekaAttributes.elementAt(fvWekaAttributes.size() - 1);
                item.setValue(classFeature, (DomPool.TargetNodes.Contains(currNode)?"yes":"no"));
                item.setDataset(trainingSet);
                if (DomPool.TargetNodes.Contains(currNode))
                {
                    for (int t = 0; t < (DomPool.NonTargetNodes.Count() / DomPool.TargetNodes.Count()); t++)
                    {
                        trainingSet.add(new SparseInstance(item));
                    }
                }
                else
                {
                    trainingSet.add(item);
                }
            }

            String[] options = new String[2];
            options[0] = "-C";                 // unpruned tree
            options[1] = "0.1";
            J48 tree = new J48();              // new instance of tree

            tree.setOptions(options);          // set the options
            tree.buildClassifier(trainingSet); // build classifier
            //save the resulting classifier
            classifierTree = tree;

            Reader    treeDot   = new StringReader(tree.graph());
            TreeBuild treeBuild = new TreeBuild();
            Node      treeRoot  = treeBuild.create(treeDot);

            FeaturesUsed = getTreeFeatures(treeRoot);
        }