//------------------------------------------------------------------------------ void DoMyWindow(int windowID) { if (GUI.Button(new Rect(5, 20, 55, 20), "Edit")) { GUI.BringWindowToFront(windowID); modo = Modo.edicao; qualJanelaActiva = windowID; for (int i = 0; i < numMaxCondicoes; i++) { condicoes[i] = true; } } if (GUI.Button(new Rect(55, 20, 55, 20), "Delete")) { MarkovTemplate.deleteState(windowID); } if (Event.current.type == EventType.MouseDown && modo == Modo.edicao) { qualJanelaActiva = windowID; } //GUI.DragWindow(); GUI.DragWindow(new Rect(0, 0, 10000, 20)); }
//------------------------------------------------------------------------- //ADD NEW STATE //-------------------------------------------------------------------------- void addNewState() { int index = MarkovTemplate.stateList.Count; windows[index] = windowTemplate; windows[index] = GUI.Window(index, windows[index], DoMyWindow, "State " + index); windows[index].x += windows[index].x + index * 10; windows[index].y += windows[index].y + index * 10; MarkovTemplate.newState("State Name"); }
public void init() { //Cria 12 estados newState("S0-Origem"); newState("S1-Producao"); newState("S2-Entrega"); newState("S3-Transacion"); //Define as transicoes ArrayList cond; //transicao S0 com S1 cond = new ArrayList { Sensor.hu, Sensor.perto }; addTransition(0, 1, cond, 0.5f); //transicao S1 com S1 cond = new ArrayList { Sensor.hu, Sensor.perto }; addTransition(1, 1, cond, 0.5f); //transicao S1 com S2 cond = new ArrayList { Sensor.perto }; addTransition(1, 2, cond, 0.5f); //transicao S2 com S2 cond = new ArrayList { Sensor.longe }; addTransition(0, 4, cond, 0.5f); //transicao S2 com S3 cond = new ArrayList { Sensor.perto }; addTransition(0, 8, cond, 0.5f); //transicao S3 com S0 cond = new ArrayList { Sensor.ht, Sensor.longe }; addTransition(1, 1, cond, 0.5f); distribuiProbabilidades(); MarkovTemplate.showInternalMarkov(); }
//-------------------------------------------- void Start() { MarkovTemplate md = new MarkovTemplate(); md.init(); }
void dialogEdicao() { Estado estado = MarkovTemplate.getState(qualJanelaActiva); if (estado != null) { if (estado.transicoes.Count == 0) { janela.height = 100; } else { janela.height = 500; } } verticalSpace(); EditorGUILayout.LabelField("State: " + qualJanelaActiva, EditorStyles.boldLabel); ((Estado)MarkovTemplate.getState(qualJanelaActiva)).titulo = EditorGUILayout.TextField(estado.titulo, GUILayout.Width(125));//, GUILayout.Width(75),GUILayout.ExpandWidth(true),EditorStyles.textField); verticalSpace(); //Visualiza Check Boxes das Transicoes if (estado != null) { scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(190), GUILayout.Height(300)); //Para todas as transicoes deste estado for (int t = estado.transicoes.Count - 1; t >= 0; t--) { bool aux = false; Estado.Transicao transicao = (Estado.Transicao)estado.transicoes[t]; aux = condicoes[t]; condicoes[t] = EditorGUILayout.BeginToggleGroup("Transition to: " + transicao.destino, condicoes[t]); if (aux != condicoes[t]) { if (!condicoes[t]) { estado.transicoes.RemoveAt(t); condicoes[t] = true; } } //Condicoes foreach (MarkovTemplate.Sensor sTemplate in listaEstados) { aux = false; int idx = -1; for (int s = 0; s < transicao.condicao.Count; s++) { MarkovTemplate.Sensor sr = (MarkovTemplate.Sensor)transicao.condicao[s]; if (sr == (MarkovTemplate.Sensor)sTemplate) { aux = true; idx = s; } } myBool = EditorGUILayout.Toggle("Sensor: " + sTemplate, aux); if (aux != myBool) { if (myBool) { transicao.condicao.Add(sTemplate); } else { transicao.condicao.RemoveAt(idx); } } } EditorGUILayout.EndToggleGroup(); } EditorGUILayout.EndScrollView(); //EditorGUILayout.EndVertical(); } }
public void init() { //Cria 12 estados newState("S0-Repouso"); newState("S1-MoveMate"); newState("S2-MovePrey"); newState("S3-Wander"); newState("S4-Quer Mate"); newState("S5-InteractM"); newState("S6-InteractM"); newState("S7-Mate"); newState("S8-Quer Atacar"); newState("S9-InteractA"); newState("S10-InteractA"); newState("S11-Ataca"); newState("S12-Emergency"); //Define as transicoes ArrayList cond; //transicao S0 com S1 cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.longe }; addTransition(0, 1, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.longe }; addTransition(0, 1, cond, 0.5f); //transicao S0 com S2 cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.longe }; addTransition(0, 2, cond, 0.5f); cond = new ArrayList { Sensor.hu, Sensor.longe }; addTransition(0, 2, cond, 0.5f); //transicao S0 com S3 cond = new ArrayList { Sensor.ht, Sensor.longe }; addTransition(0, 3, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.longe }; addTransition(0, 3, cond, 0.5f); cond = new ArrayList { Sensor.hu, Sensor.longe }; addTransition(0, 3, cond, 0.5f); cond = new ArrayList { Sensor.longe }; addTransition(0, 3, cond, 0.5f); cond = new ArrayList { Sensor.perto }; addTransition(0, 3, cond, 0.5f); //transicao S0 com S4 cond = new ArrayList { Sensor.ht, Sensor.perto }; addTransition(0, 4, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.perto }; addTransition(0, 4, cond, 0.5f); //transicao S0 com S8 cond = new ArrayList { Sensor.hu, Sensor.perto }; addTransition(0, 8, cond, 0.5f); cond = new ArrayList { Sensor.hu, Sensor.ht, Sensor.perto }; addTransition(0, 8, cond, 0.5f); //transicao S0 com S12 cond = new ArrayList { Sensor.emergency }; addTransition(0, 12, cond, 2); //transicao S1 com S1 cond = new ArrayList { Sensor.ht, Sensor.longe }; addTransition(1, 1, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.longe }; addTransition(1, 1, cond, 0.5f); //transicao S1 com S2 cond = new ArrayList { Sensor.hu, Sensor.longe }; addTransition(1, 2, cond, 0.5f); //transicao S1 com S4 cond = new ArrayList { Sensor.ht, Sensor.perto }; addTransition(1, 4, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.perto }; addTransition(1, 4, cond, 0.5f); //transicao S1 com S8 cond = new ArrayList { Sensor.hu, Sensor.perto }; addTransition(1, 8, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.perto }; addTransition(1, 8, cond, 0.5f); //transicao S1 com S12 cond = new ArrayList { Sensor.emergency }; addTransition(3, 12, cond, 2); //transicao S2 com S1 cond = new ArrayList { Sensor.ht, Sensor.longe }; addTransition(2, 1, cond, 0.5f); //transicao S2 com S2 cond = new ArrayList { Sensor.hu, Sensor.longe }; addTransition(2, 2, cond, 0.5f); cond = new ArrayList { Sensor.hu, Sensor.ht, Sensor.longe }; addTransition(2, 2, cond, 0.5f); //transicao S2 com S8 cond = new ArrayList { Sensor.hu, Sensor.perto }; addTransition(2, 8, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.perto }; addTransition(2, 8, cond, 0.5f); //transicao S2 com S4 cond = new ArrayList { Sensor.ht, Sensor.perto }; addTransition(2, 4, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.perto }; addTransition(2, 4, cond, 0.5f); //transicao S3 com S1 cond = new ArrayList { Sensor.hu, Sensor.longe }; addTransition(3, 1, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.longe }; addTransition(3, 1, cond, 0.5f); //transicao S3 com S2 cond = new ArrayList { Sensor.ht, Sensor.longe }; addTransition(3, 2, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.longe }; addTransition(3, 2, cond, 0.5f); //transicao S3 com S3 cond = new ArrayList { Sensor.ht, Sensor.longe }; addTransition(3, 3, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.longe }; addTransition(3, 3, cond, 0.5f); cond = new ArrayList { Sensor.hu, Sensor.longe }; addTransition(3, 3, cond, 0.5f); cond = new ArrayList { Sensor.longe }; addTransition(3, 3, cond, 0.5f); cond = new ArrayList { Sensor.perto }; addTransition(3, 3, cond, 0.5f); //transicao S3 com S4 cond = new ArrayList { Sensor.ht, Sensor.perto }; addTransition(3, 4, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.perto }; addTransition(3, 4, cond, 0.5f); //transicao S3 com S8 cond = new ArrayList { Sensor.hu, Sensor.perto }; addTransition(3, 8, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.perto }; addTransition(3, 8, cond, 0.5f); //transicao S3 com S12 cond = new ArrayList { Sensor.emergency }; addTransition(3, 12, cond, 2); //transicao S4 com S1 cond = new ArrayList { Sensor.ht, Sensor.longe }; addTransition(4, 1, cond, 0.5f); //transicao S4 com S2 cond = new ArrayList { Sensor.hu, Sensor.longe }; addTransition(4, 2, cond, 0.5f); //transicao S4 com S5 cond = new ArrayList { Sensor.ht, Sensor.perto, Sensor.conhecido }; addTransition(4, 5, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.perto, Sensor.conhecido }; addTransition(4, 5, cond, 0.5f); //transicao S4 com S6 cond = new ArrayList { Sensor.ht, Sensor.perto, Sensor.desconhecido }; addTransition(4, 6, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.perto, Sensor.conhecido }; addTransition(4, 5, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.perto, Sensor.desconhecido }; addTransition(4, 6, cond, 0.5f); cond = new ArrayList { Sensor.ht, Sensor.hu, Sensor.perto, Sensor.conhecido }; addTransition(4, 5, cond, 0.5f); cond = new ArrayList { Sensor.hu, Sensor.perto }; addTransition(4, 8, cond, 0.5f); cond = new ArrayList { Sensor.hu, Sensor.ht, Sensor.perto }; addTransition(4, 8, cond, 0.5f); //transicao S4 com S12 cond = new ArrayList { Sensor.emergency }; addTransition(4, 12, cond, 2); //transicao S5 com S3 cond = new ArrayList { Sensor.n_interact }; addTransition(5, 3, cond, 0.5f); cond = new ArrayList { Sensor.emergency }; addTransition(5, 12, cond, 2); //transicao S5 com S7 cond = new ArrayList { Sensor.interact }; addTransition(5, 7, cond, 0.5f); //transicao S6 com S3 cond = new ArrayList { Sensor.n_interact }; addTransition(6, 3, cond, 0.5f); cond = new ArrayList { Sensor.emergency }; addTransition(6, 12, cond, 2); cond = new ArrayList { Sensor.interact }; addTransition(6, 7, cond, 0.5f); //transicao S7 com S3 cond = new ArrayList { Sensor.n_interact }; addTransition(7, 3, cond, 0.5f);//transicao S6 com S7 //transicao S8 com S2 cond = new ArrayList { Sensor.hu, Sensor.longe }; addTransition(8, 2, cond, 0.5f); cond = new ArrayList { Sensor.emergency }; addTransition(8, 12, cond, 2); //transicao S8 com S9 cond = new ArrayList { Sensor.hu, Sensor.conhecido }; addTransition(8, 9, cond, 0.5f); //transicao S8 com S10 cond = new ArrayList { Sensor.hu, Sensor.desconhecido }; addTransition(8, 10, cond, 0.5f); //transicao S8 com S4 cond = new ArrayList { Sensor.ht, Sensor.perto }; addTransition(8, 4, cond, 0.5f); //transicao S9 com S3 cond = new ArrayList { Sensor.n_interact }; addTransition(9, 3, cond, 0.5f); //transicao S9 com S11 cond = new ArrayList { Sensor.interact }; addTransition(9, 11, cond, 0.5f); cond = new ArrayList { Sensor.emergency }; addTransition(9, 12, cond, 2); //transicao S10 com S3 cond = new ArrayList { Sensor.n_interact }; addTransition(10, 3, cond, 0.5f); //transicao S10 com S11 cond = new ArrayList { Sensor.interact }; addTransition(10, 11, cond, 0.5f); cond = new ArrayList { Sensor.emergency }; addTransition(10, 12, cond, 2); //transicao S11 com S3 cond = new ArrayList { Sensor.n_interact }; addTransition(11, 3, cond, 0.5f); cond = new ArrayList { Sensor.emergency }; addTransition(12, 12, cond, 2); distribuiProbabilidades(); #if ShowInternalMarkov MarkovTemplate.showInternalMarkov(); #endif }