Exemple #1
0
 private void Output()
 {
     textBox4.Text  = neoDataLoader.GetNumberOfAgents();
     agentInstances = new List <string>();
     agentInstances = neoDataLoader.GetAllInstancesIdByName("Агент");
     this.listBox_Agents.Items.Clear();
     foreach (String str in agentInstances)
     {
         this.listBox_Agents.Items.Add("Человек. ID: " + str);
     }
     this.dataGridView_agentParameters.DataSource = new object();
 }
Exemple #2
0
        public void Algorithm()
        {
            using (neoDataLoader = new NeoDataLoader("bolt://localhost:" + textBox1.Text, textBox2.Text, textBox3.Text))
            {
                agentInstances = neoDataLoader.GetAllInstancesIdByName("Агент");
            }

            foreach (string agentID in agentInstances)
            {
                // Получаем формулу на текущем состоянии

                string currentStateID;
                string currentStateFormula;
                using (neoDataLoader = new NeoDataLoader("bolt://localhost:" + textBox1.Text, textBox2.Text, textBox3.Text))
                {
                    string        stateID         = neoDataLoader.GetParameterValue(agentID, "Состояние");
                    List <String> relatedStatesId = neoDataLoader.GetStatesInWhichNodeGoes(stateID);
                    foreach (string state in relatedStatesId)
                    {
                        if (ExpressionChecker(neoDataLoader.GetRelationshipBetweenStatementsParameterValue(stateID, state, "comment")))     // Состояние меняется каждый раз ДОПИШИ ПАРСЕР ФОРМУЛ я хочу спать, не могу
                        {
                            neoDataLoader.SetNodeParameter(agentID, "Состояние", state);
                        }
                        foreach (string food in neoDataLoader.GetAllNodesWithNameInstancesId("Пища")) //Тут состояние не менятся на покой пока не будет найдена пища
                        {
                            if (checkSamePosition(food, agentID))
                            {
                                neoDataLoader.SetNodeParameter(agentID, "Состояние", "0");
                            }
                        }
                    }
                    currentStateID      = neoDataLoader.GetParameterValue(agentID, "Состояние");
                    currentStateFormula = neoDataLoader.GetParameterValue(currentStateID, "comment");
                }
                // Парсим формулу и применяем её (надо сделать проверку может ли она быть применена)

                FormulaParser(currentStateFormula, agentID);
                try
                {
                    if (currentStateID.Equals("1"))
                    { //1 = Перемещение (Это костыль)
                        neoDataLoader = new NeoDataLoader("bolt://localhost:" + textBox1.Text, textBox2.Text, textBox3.Text);
                        moving(System.Convert.ToInt32(neoDataLoader.GetParameterValue(agentID, "X")), System.Convert.ToInt32(neoDataLoader.GetParameterValue(agentID, "Y")), agentID);
                    }
                }
                catch (FormatException)
                {
                    // the FormatException is thrown when the string text does
                    // not represent a valid integer.
                }
                catch (OverflowException)
                {
                    // the OverflowException is thrown when the string is a valid integer,
                    // but is too large for a 32 bit integer.  Use Convert.ToInt64 in
                    // this case.
                }
                //Здесь делаем проверку перехода в другое состояние и, если можем перейти, переходим
                TransitionParser(); ////// Заглушка
            }
        }
Exemple #3
0
 public double CalculateAverageSatiety()
 {
     using (neoDataLoader = new NeoDataLoader("bolt://localhost:" + textBox1.Text, textBox2.Text, textBox3.Text))
     {
         List <string> agentsID = neoDataLoader.GetAllInstancesIdByName("Агент");
         double        sum      = 0;
         foreach (string agent in agentsID)
         {
             sum += Convert.ToDouble(neoDataLoader.GetParameterValue(agent, "Сытость"));
         }
         sum /= agentsID.Count();
         return(sum);
     }
 }
Exemple #4
0
        public string searchNeededItem(int X, int Y, string agentId, string neededItemName)
        {
            List <string> items = neoDataLoader.GetAllInstancesIdByName(neededItemName);

            foreach (string item in items)
            {
                int rangeOfVision = Convert.ToInt32(neoDataLoader.GetParameterValue(agentId, "Обзор"));
                int Xitem         = Convert.ToInt32(neoDataLoader.GetParameterValue(item, "X"));
                int Yitem         = Convert.ToInt32(neoDataLoader.GetParameterValue(item, "Y"));
                if ((Math.Pow(X - Xitem, 2) + Math.Pow(Y - Yitem, 2)) <= Math.Pow(rangeOfVision, 2))
                {
                    return(item);
                }
            }
            return(null);
        }
Exemple #5
0
 public double CalculateAverageFood() // Здесь дичайшие костыли
 {
     using (neoDataLoader = new NeoDataLoader("bolt://localhost:" + textBox1.Text, textBox2.Text, textBox3.Text))
     {
         List <string> agentsID = neoDataLoader.GetAllInstancesIdByName("Агент");
         double        sum      = 0;
         foreach (string agent in agentsID)
         {
             sum += Convert.ToDouble(
                 neoDataLoader.GetStatementResult(
                     "match(n) where id(n) = " + agent + " return n.Пища"
                     ).Single()[0].As <string>());
         }
         sum /= agentsID.Count();
         return(sum);
     }
 }