private void Rlista(NodoArbolABB actual)
        {
            if (actual != null)
            {
                if (actual.getListaJuegos().primero != null)
                {
                    NodoListaDoble actual2 = actual.getListaJuegos().primero;
                    while (actual2 != null)
                    {
                        if (actual.getNicknamee() == actual2.getNickname())
                        {
                            if (contador == 0)
                            {
                                fichero.Write(actual2.getNickname() + ":f1 -> " + "\"" + "Usuario: " + actual2.getNickname() + ", \n Oponente: " + actual2.getNicknameOponente() + ", \n Unidades Desplegadas: " + actual2.getUnidadesDesplegadas().ToString() + ", \n Unidades Sobrevivientes: " + actual2.getUnidadesSobrevivientes().ToString() + ", \n Unidades Destruidas: " + actual2.getUnidadesDestruidas().ToString() + ", \n Victoria: " + actual2.getEstadoVictoria().ToString() + "\"[dir=both];");
                                fichero.Write("\n");
                                contador = 1;
                            }
                            else
                            {
                                fichero.Write("\"" + "Usuario: " + actual2.getNickname() + ", \n Oponente: " + actual2.getAnterior().getNicknameOponente() + ", \n Unidades Desplegadas: " + actual2.getUnidadesDesplegadas().ToString() + ", \n Unidades Sobrevivientes: " + actual2.getUnidadesSobrevivientes().ToString() + ", \n Unidades Destruidas: " + actual2.getUnidadesDestruidas().ToString() + ", \n Victoria: " + actual2.getEstadoVictoria().ToString() + "\"" + "->" + "\"" + "Usuario: " + actual2.getNickname() + ", \n Oponente: " + actual2.getNicknameOponente() + ", \n Unidades Desplegadas: " + actual2.getUnidadesDesplegadas().ToString() + ", \n Unidades Sobrevivientes: " + actual2.getUnidadesSobrevivientes().ToString() + ", \n Unidades Destruidas: " + actual2.getUnidadesDestruidas().ToString() + ", \n Victoria: " + actual2.getEstadoVictoria().ToString() + "\"[dir=both];");
                                fichero.Write("\n");
                            }

                            //Console.WriteLine(actual2.getNickname() + " Oponente: " + actual2.getNicknameOponente());
                            actual2 = actual2.getSiguiente();
                        }
                        else
                        {
                            actual2 = actual2.getSiguiente();
                        }
                    }
                    contador = 0;
                }
            }
        }
예제 #2
0
        public void graficar(String path)
        {
            StreamWriter   fichero = null;
            int            id      = 0;
            NodoListaDoble actual  = this.primero;

            try
            {
                fichero = new StreamWriter("ListaDobleJuegos.dot");
                fichero.Write("digraph grafica{\n" +
                              "rankdir=TB;\n" +
                              "node [shape = record, style=filled, fillcolor=aquamarine2];\n");

                while (actual != null)
                {
                    fichero.Write("nodo" + id + " [ label =\"" + "Oponente: " + actual.getNicknameOponente() + "\\n Unidades Desplegadas: " + actual.getUnidadesDesplegadas().ToString() + "\\n Unidades Sobrevivientes: " + actual.getUnidadesSobrevivientes().ToString() + "\\n Unidades Destruidas: " + actual.getUnidadesDestruidas().ToString() + "\\n Estado Victoria: " + actual.getEstadoVictoria().ToString() + "\"];\n");
                    id++;
                    actual = actual.getSiguiente();
                }

                actual = this.primero;
                id     = 0;
                while (actual != null)
                {
                    if (id == 0)
                    {
                        fichero.Write("nodo" + (id) + "->" + "nodo" + (id + 1) + ";\n");
                        id++;
                    }
                    else
                    {
                        fichero.Write("nodo" + (id) + "->" + "nodo" + (id - 1) + ";\n");
                        fichero.Write("nodo" + (id) + "->" + "nodo" + (id + 1) + ";\n");
                        id++;
                    }
                    actual = actual.getSiguiente();
                }
                fichero.Write("}\n");
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error al escribir en el archivos dot" + e.ToString());
            }
            finally
            {
                try
                {
                    if (null != fichero)
                    {
                        fichero.Close();
                    }
                }
                catch (Exception e2)
                {
                    Console.Error.WriteLine("Error al cerrar el archivo .dot" + e2.ToString());
                }
            }
            try
            {
                ProcessStartInfo startInfo = new ProcessStartInfo("C:\\Program Files (x86)\\Graphviz\\bin\\dot.exe");
                startInfo.Arguments = "dot -Tpng -o" + path + " ListaDobleJuegos.dot";
                Process.Start(startInfo);
                Process.Start("ListaDobleJuegos.png");
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Error al generar la imagen para el archivo ListaDobleJuegos.dot" + ex.ToString());
            }
        }
예제 #3
0
        private String getCodigoInterno()
        {
            String etiqueta;
            NodoListaDoble actual = this.ListaJuegos.primero;
            if (Izquierdo == null && Derecho == null)
            {
                etiqueta = "nodo" + id + " [ label =\"" + Usuario + "\"];\n";
                while (actual != null)
                {

                    etiqueta="nodo" + id + " [ label =\"" + "Oponente: " + actual.getNicknameOponente() + "\\n Unidades Desplegadas: " + actual.getUnidadesDesplegadas().ToString() + "\\n Unidades Sobrevivientes: " + actual.getUnidadesSobrevivientes().ToString() + "\\n Unidades Destruidas: " + actual.getUnidadesDestruidas().ToString() + "\\n Estado Victoria: " + actual.getEstadoVictoria().ToString() + "\"];\n");
                    id++;
                    actual = actual.getSiguiente();
                }

            }
            else
            {
                etiqueta = "nodo" + id + " [ label =\"<C0>|" + Usuario + "|<C1>\"];\n";
            }
            if (Izquierdo != null)
            {
                etiqueta = etiqueta + Izquierdo.getCodigoInterno() +
                   "nodo" + id + ":C0->nodo" + Izquierdo.id + "\n";
            }
            if (Derecho != null)
            {
                etiqueta = etiqueta + Derecho.getCodigoInterno() +
                   "nodo" + id + ":C1->nodo" + Derecho.id + "\n";
            }
            return etiqueta;
        }