Ejemplo n.º 1
0
        public MainClass()
        {
            Application.Init();
            Console.WriteLine("ClarionApp V0.8");

            RandomGenerator rg        = new RandomGenerator();
            int             ws_width  = 800;
            int             ws_lenght = 600;

            try
            {
                ws = new WSProxy("localhost", 4011);

                String message = ws.Connect();


                if (ws != null && ws.IsConnected)
                {
                    Console.Out.WriteLine("[SUCCESS] " + message + "\n");
                    //ws.SendWorldReset();
                    ws.NewCreature(400, 200, 0, out creatureId, out creatureName);
                    ws.SendCreateLeaflet();

                    ws.NewBrick(4, 0, 0, -50, ws_lenght + 50);
                    ws.NewBrick(4, 0, ws_lenght, ws_width + 50, ws_lenght + 50);
                    ws.NewBrick(4, ws_width, ws_lenght, ws_width + 50, -50);
                    ws.NewBrick(4, ws_width, 0, -50, -50);

                    //while (true) {
                    int nu_of_jewels = 15;
                    for (int i = 0; i < nu_of_jewels; i++)
                    {
                        ws.NewJewel(rg.randomInt(0, 6), rg.randomInt(0, ws_width), rg.randomInt(0, ws_lenght));
                    }

                    int nu_of_foods = 8;
                    for (int i = 0; i < nu_of_foods; i++)
                    {
                        ws.NewFood(rg.randomInt(0, 2), rg.randomInt(0, ws_width), rg.randomInt(0, ws_lenght));
                    }
                    //Thread.Sleep(10000);
                    //}

                    if (!String.IsNullOrWhiteSpace(creatureId))
                    {
                        ws.SendStartCamera(creatureId);
                        ws.SendStartCreature(creatureId);
                    }

                    Console.Out.WriteLine("Creature created with name: " + creatureId + "\n");
                    agent = new ClarionAgent(ws, creatureId, creatureName);
                    agent.Run();
                    Console.Out.WriteLine("Running Simulation ...\n");
                }
                else
                {
                    Console.Out.WriteLine("The WorldServer3D engine was not found ! You must start WorldServer3D before running this application !");
                    System.Environment.Exit(1);
                }
            }
            catch (WorldServerInvalidArgument invalidArtgument)
            {
                Console.Out.WriteLine(String.Format("[ERROR] Invalid Argument: {0}\n", invalidArtgument.Message));
            }
            catch (WorldServerConnectionError serverError)
            {
                Console.Out.WriteLine(String.Format("[ERROR] Is is not possible to connect to server: {0}\n", serverError.Message));
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(String.Format("[ERROR] Unknown Error: {0}\n", ex.Message));
            }
            Application.Run();
        }
Ejemplo n.º 2
0
        public MainClass(string[] args)
        {
            Application.Init();
            Console.WriteLine("IA941 - Clarion - Activity");
            try
            {
                ws = new WSProxy("localhost", 4011);

                String message = ws.Connect();

                if (ws != null && ws.IsConnected)
                {
                    Console.Out.WriteLine("[SUCCESS] " + message + "\n");
                    if (args.Length > 1)
                    {
                        if (args[1] == "reset")
                        {
                            ws.SendWorldReset();
                        }
                    }
                    else
                    {
                        ws.SendWorldReset();
                    }

                    ws.NewCreature(100, 500, 0, out creatureId, out creatureName);
                    //Console.WriteLine ("SendCreateLeaflet: ");
                    //ws.SendCreateLeaflet();
                    //ws.SendNewWayPoint (700, 500);

                    if (args.Length > 1)
                    {
                        if (args[3] == "grow")
                        {
                            //ws.NewBrick(4, 747, 2, 800, 567);
                            //ws.NewBrick(4, 50, -4, 747, 47);
                            //ws.NewBrick(4, 49, 562, 796, 599);
                            //ws.NewBrick(4, -2, 6, 50, 599);

                            Random x    = new Random();
                            Random y    = new Random();
                            Random z    = new Random();
                            int    minX = 100;
                            int    maxX = 600;
                            int    minY = 100;
                            int    maxY = 500;
                            int    xNew = 0;
                            int    yNew = 0;

                            // Random Jewels
                            for (int j = 0; j < 7; j++)
                            {
                                for (int i = 0; i < 5; i++)
                                {
                                    xNew = x.Next(minX, maxX);
                                    yNew = y.Next(minY, maxY);
                                    if (((mod(xNew, 100) < 50) && (mod(yNew, 100) < 50)) || ((mod(xNew, 100) < 50) && (mod(yNew, 500) < 50)))
                                    {
                                        x.Next(minX + z.Next(1, 50), maxX);
                                        if (i > 0)
                                        {
                                            i--;
                                        }
                                    }
                                    else
                                    {
                                        ws.NewJewel(j, xNew, yNew);
                                        x.Next(minX + z.Next(1, 50), maxX);
                                    }
                                }
                            }

                            // Random food
                            for (int j = 0; j < 2; j++)
                            {
                                for (int i = 0; i < 2; i++)
                                {
                                    xNew = x.Next(minX, maxX);
                                    yNew = y.Next(minY, maxY);
                                    if (!(((xNew > 60) && (xNew < 140)) || (((xNew > 360) && (xNew < 440)))))
                                    {
                                        ws.NewFood(j, xNew, yNew);
                                        x.Next(minX + i, maxX);
                                    }
                                    else
                                    {
                                        x.Next(minX + i, maxX);
                                        if (i > 0)
                                        {
                                            i--;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        //ws.NewBrick(4, 747, 2, 800, 567);
                        //ws.NewBrick(4, 50, -4, 747, 47);
                        //ws.NewBrick(4, 49, 562, 796, 599);
                        //ws.NewBrick(4, -2, 6, 50, 599);

                        Random x    = new Random();
                        Random y    = new Random();
                        Random z    = new Random();
                        int    minX = 100;
                        int    maxX = 600;
                        int    minY = 100;
                        int    maxY = 500;
                        int    xNew = 0;
                        int    yNew = 0;

                        // Random Jewels
                        for (int j = 0; j < 7; j++)
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                xNew = x.Next(minX, maxX);
                                yNew = y.Next(minY, maxY);
                                if (((mod(xNew, 100) < 50) && (mod(yNew, 100) < 50)) || ((mod(xNew, 100) < 50) && (mod(yNew, 500) < 50)))
                                {
                                    x.Next(minX + z.Next(1, 50), maxX);
                                    if (i > 0)
                                    {
                                        i--;
                                    }
                                }
                                else
                                {
                                    ws.NewJewel(j, xNew, yNew);
                                    x.Next(minX + z.Next(1, 50), maxX);
                                }
                            }
                        }

                        // Random food
                        for (int j = 0; j < 2; j++)
                        {
                            for (int i = 0; i < 2; i++)
                            {
                                xNew = x.Next(minX, maxX);
                                yNew = y.Next(minY, maxY);
                                if (!(((xNew > 60) && (xNew < 140)) || (((xNew > 360) && (xNew < 440)))))
                                {
                                    ws.NewFood(j, xNew, yNew);
                                    x.Next(minX + i, maxX);
                                }
                                else
                                {
                                    x.Next(minX + i, maxX);
                                    if (i > 0)
                                    {
                                        i--;
                                    }
                                }
                            }
                        }
                    }
                    if (!String.IsNullOrWhiteSpace(creatureId))
                    {
                        ws.SendStartCamera(creatureId);
                        ws.SendStartCreature(creatureId);
                    }

                    if (args.Length > 0)
                    {
                        Console.Out.WriteLine("Sleep time: " + Convert.ToInt32(args[0]));
                        Thread.Sleep(Convert.ToInt32(args[0]));
                    }
                    else
                    {
                        Thread.Sleep(500);
                    }

                    Console.Out.WriteLine("Creature created with name: " + creatureId + "\n");
                    agent = new ClarionAgent(ws, creatureId, creatureName);
                    agent.Run();
                    Console.Out.WriteLine("Running Simulation ...\n");
                }
                else
                {
                    Console.Out.WriteLine("The WorldServer3D engine was not found ! You must start WorldServer3D before running this application !");
                    System.Environment.Exit(1);
                }
            }
            catch (WorldServerInvalidArgument invalidArtgument)
            {
                Console.Out.WriteLine(String.Format("[ERROR] Invalid Argument: {0}\n", invalidArtgument.Message));
            }
            catch (WorldServerConnectionError serverError)
            {
                Console.Out.WriteLine(String.Format("[ERROR] Is is not possible to connect to server: {0}\n", serverError.Message));
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(String.Format("[ERROR] Unknown Error: {0}\n", ex.Message));
            }
            Application.Run();
        }
Ejemplo n.º 3
0
        public MainClass(string [] args)
        {
            Application.Init();
            Console.WriteLine("IA941 - Clarion - Activity");
            try {
                ws = new WSProxy("localhost", 4011);

                String message = ws.Connect();

                if (ws != null && ws.IsConnected)
                {
                    Console.Out.WriteLine("[SUCCESS] " + message + "\n");
                    if (args.Length > 1)
                    {
                        if (args [1] == "reset")
                        {
                            ws.SendWorldReset();
                        }
                    }
                    else
                    {
                        ws.SendWorldReset();
                    }

                    ws.NewCreature(100, 500, 0, out creatureId, out creatureName);

                    // Start >>> Leaflet process preparation //
                    String    leaflets_raw = ws.SendCreateLeaflet();
                    string [] leaflets_arr = leaflets_raw.Split(' ');
                    //Console.WriteLine ("Leaflets: " + leaflets_raw);

                    Leaflet leaflet1 = new Leaflet();
                    leaflet1.items = new List <LeafletItem> ();
                    Leaflet leaflet2 = new Leaflet();
                    leaflet2.items = new List <LeafletItem> ();
                    Leaflet leaflet3 = new Leaflet();
                    leaflet3.items = new List <LeafletItem> ();

                    int leafNum = 1;
                    int lf1T    = 0;
                    int lf2T    = 0;
                    int lf3T    = 0;
                    for (int i = 0; i < leaflets_arr.Length; i++)
                    {
                        if (leaflets_arr [i] != "")
                        {
                            if (leaflets_arr [i] == "false")
                            {
                                leafNum++;
                            }
                            else if (leaflets_arr [i].Length > 3)
                            {
                                switch (leafNum)
                                {
                                case 1:
                                    leaflet1.items.Add(new LeafletItem(leaflets_arr [i], Int32.Parse(leaflets_arr [i + 2]), 0));
                                    lf1T = lf1T + Int32.Parse(leaflets_arr [i + 2]);
                                    i    = i + 2;
                                    break;

                                case 2:
                                    leaflet2.items.Add(new LeafletItem(leaflets_arr [i], Int32.Parse(leaflets_arr [i + 2]), 0));
                                    lf2T = lf2T + Int32.Parse(leaflets_arr [i + 2]);
                                    i    = i + 2;
                                    break;

                                case 3:
                                    leaflet3.items.Add(new LeafletItem(leaflets_arr [i], Int32.Parse(leaflets_arr [i + 2]), 0));
                                    lf3T = lf3T + Int32.Parse(leaflets_arr [i + 2]);
                                    i    = i + 2;
                                    break;

                                default:
                                    break;
                                }
                            }
                        }
                    }

                    //Console.WriteLine ("Leaflet 1 items: ");
                    //foreach(LeafletItem lt in leaflet1.items) {
                    //	Console.WriteLine ("Jewel: " + lt.itemKey);
                    //	Console.WriteLine ("Total: " + lt.totalNumber);

                    //}

                    //Console.WriteLine ("Leaflet 2 items: ");
                    //foreach (LeafletItem lt in leaflet2.items) {
                    //	Console.WriteLine ("Jewel: " + lt.itemKey);
                    //	Console.WriteLine ("Total: " + lt.totalNumber);

                    //}

                    //Console.WriteLine ("Leaflet 3 items: ");
                    //foreach (LeafletItem lt in leaflet3.items) {
                    //	Console.WriteLine ("Jewel: " + lt.itemKey);
                    //	Console.WriteLine ("Total: " + lt.totalNumber);

                    //}

                    // In case the leaflets sum have less than 9 jewels, then add remaining
                    int remJewels = 9 - (lf1T + lf2T + lf3T);
                    //Console.WriteLine ("Rem Jewels: " + remJewels);
                    //Console.WriteLine ("count lf1: " + leaflet1.items.Count);
                    if (remJewels > 0)
                    {
                        for (int i = 0; i < remJewels; i++)
                        {
                            if (lf1T < 3)
                            {
                                leaflet1.items.Add(new LeafletItem("Red", 1, 0));
                                lf1T++;
                                //Console.WriteLine ("Added rem Jewel - Leaflet 1");
                            }
                            else if (lf2T < 3)
                            {
                                leaflet2.items.Add(new LeafletItem("Red", 1, 0));
                                lf2T++;
                                //Console.WriteLine ("Added rem Jewel - Leaflet 2");
                            }
                            else if (lf3T < 3)
                            {
                                leaflet3.items.Add(new LeafletItem("Red", 1, 0));
                                lf3T++;
                                //Console.WriteLine ("Added rem Jewel - Leaflet 3");
                            }
                        }
                    }
                    //Console.WriteLine ("Double check: ");
                    //Console.WriteLine ("Leaflet 1 items: ");
                    //foreach (LeafletItem lt in leaflet1.items) {
                    //	Console.WriteLine ("Jewel: " + lt.itemKey);
                    //	Console.WriteLine ("Total: " + lt.totalNumber);

                    //}

                    //Console.WriteLine ("Leaflet 2 items: ");
                    //foreach (LeafletItem lt in leaflet2.items) {
                    //	Console.WriteLine ("Jewel: " + lt.itemKey);
                    //	Console.WriteLine ("Total: " + lt.totalNumber);

                    //}

                    //Console.WriteLine ("Leaflet 3 items: ");
                    //foreach (LeafletItem lt in leaflet3.items) {
                    //	Console.WriteLine ("Jewel: " + lt.itemKey);
                    //	Console.WriteLine ("Total: " + lt.totalNumber);

                    //}
                    // End >>> Leaflet process preparation //

                    ws.SendNewWayPoint(700, 500);
                    if (args.Length > 1)
                    {
                        if (args [3] == "grow")
                        {
                            //ws.NewBrick (4, 747, 2, 800, 567);
                            //ws.NewBrick (4, 50, -4, 747, 47);
                            //ws.NewBrick (4, 49, 562, 796, 599);
                            //ws.NewBrick (4, -2, 6, 50, 599);

                            Random x    = new Random();
                            Random y    = new Random();
                            Random z    = new Random();
                            int    minX = 100;
                            int    maxX = 600;
                            int    minY = 100;
                            int    maxY = 500;
                            int    xNew = 0;
                            int    yNew = 0;

                            // Random Jewels
                            for (int j = 0; j < 7; j++)
                            {
                                for (int i = 0; i < 5; i++)
                                {
                                    xNew = x.Next(minX, maxX);
                                    yNew = y.Next(minY, maxY);
                                    if (((mod(xNew, 100) < 50) && (mod(yNew, 100) < 50)) || ((mod(xNew, 100) < 50) && (mod(yNew, 500) < 50)))
                                    {
                                        x.Next(minX + z.Next(1, 50), maxX);
                                        if (i > 0)
                                        {
                                            i--;
                                        }
                                    }
                                    else
                                    {
                                        ws.NewJewel(j, xNew, yNew);
                                        x.Next(minX + z.Next(1, 50), maxX);
                                    }
                                }
                            }

                            // Random food
                            for (int j = 0; j < 2; j++)
                            {
                                for (int i = 0; i < 2; i++)
                                {
                                    xNew = x.Next(minX, maxX);
                                    yNew = y.Next(minY, maxY);
                                    if (!(((xNew > 60) && (xNew < 140)) || (((xNew > 360) && (xNew < 440)))))
                                    {
                                        ws.NewFood(j, xNew, yNew);
                                        x.Next(minX + i, maxX);
                                    }
                                    else
                                    {
                                        x.Next(minX + i, maxX);
                                        if (i > 0)
                                        {
                                            i--;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        //ws.NewBrick (4, 747, 2, 800, 567);
                        //ws.NewBrick (4, 50, -4, 747, 47);
                        //ws.NewBrick (4, 49, 562, 796, 599);
                        //ws.NewBrick (4, -2, 6, 50, 599);

                        Random x    = new Random();
                        Random y    = new Random();
                        Random z    = new Random();
                        int    minX = 100;
                        int    maxX = 600;
                        int    minY = 100;
                        int    maxY = 500;
                        int    xNew = 0;
                        int    yNew = 0;

                        // Random Jewels
                        for (int j = 0; j < 7; j++)
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                xNew = x.Next(minX, maxX);
                                yNew = y.Next(minY, maxY);
                                if (((mod(xNew, 100) < 50) && (mod(yNew, 100) < 50)) || ((mod(xNew, 100) < 50) && (mod(yNew, 500) < 50)))
                                {
                                    x.Next(minX + z.Next(1, 50), maxX);
                                    if (i > 0)
                                    {
                                        i--;
                                    }
                                }
                                else
                                {
                                    ws.NewJewel(j, xNew, yNew);
                                    x.Next(minX + z.Next(1, 50), maxX);
                                }
                            }
                        }

                        // Random food
                        for (int j = 0; j < 2; j++)
                        {
                            for (int i = 0; i < 2; i++)
                            {
                                xNew = x.Next(minX, maxX);
                                yNew = y.Next(minY, maxY);
                                if (!(((xNew > 60) && (xNew < 140)) || (((xNew > 360) && (xNew < 440)))))
                                {
                                    ws.NewFood(j, xNew, yNew);
                                    x.Next(minX + i, maxX);
                                }
                                else
                                {
                                    x.Next(minX + i, maxX);
                                    if (i > 0)
                                    {
                                        i--;
                                    }
                                }
                            }
                        }
                    }


                    // ---- Start - Leaflet Generation --- //
                    IList <Thing> response = null;
                    if (ws != null && ws.IsConnected)
                    {
                        response = ws.SendGetCreatureState(creatureName);
                        if (leaflet1.leafletID == 0 && leaflet2.leafletID == 0 && leaflet3.leafletID == 0)
                        {
                            Creature cc = (Creature)response [0];
                            //leaflet1.leafletID = cc.leaflets [0].leafletID;
                            //leaflet2.leafletID = cc.leaflets [1].leafletID;
                            //leaflet3.leafletID = cc.leaflets [2].leafletID;
                            leaflet1 = cc.leaflets [0];
                            leaflet2 = cc.leaflets [1];
                            leaflet3 = cc.leaflets [2];
                            //Console.WriteLine ("Creature found: " + cc.Name);
                            //Console.WriteLine ("LF1: " + cc.leaflets [0].leafletID);
                            //Console.WriteLine ("LF2: " + cc.leaflets [1].leafletID);
                            //Console.WriteLine ("LF3: " + cc.leaflets [2].leafletID);
                        }
                    }
                    List <Leaflet> leafletList = new List <Leaflet> ();
                    leafletList.Add(leaflet1);
                    leafletList.Add(leaflet2);
                    leafletList.Add(leaflet3);
                    // ---- Finish - Leaflet generation --- //



                    if (!String.IsNullOrWhiteSpace(creatureId))
                    {
                        ws.SendStartCamera(creatureId);
                        ws.SendStartCreature(creatureId);
                    }

                    if (args.Length > 0)
                    {
                        Console.Out.WriteLine("Sleep time: " + Convert.ToInt32(args [0]));
                        Thread.Sleep(Convert.ToInt32(args [0]));
                    }
                    else
                    {
                        Thread.Sleep(500);
                    }

                    Console.Out.WriteLine("Creature created with name: " + creatureId + "\n");
                    agent = new ClarionAgent(ws, creatureId, creatureName, leafletList);
                    agent.Run();
                    Console.Out.WriteLine("Running Simulation ...\n");
                }
                else
                {
                    Console.Out.WriteLine("The WorldServer3D engine was not found ! You must start WorldServer3D before running this application !");
                    System.Environment.Exit(1);
                }
            } catch (WorldServerInvalidArgument invalidArtgument) {
                Console.Out.WriteLine(String.Format("[ERROR] Invalid Argument: {0}\n", invalidArtgument.Message));
            } catch (WorldServerConnectionError serverError) {
                Console.Out.WriteLine(String.Format("[ERROR] Is is not possible to connect to server: {0}\n", serverError.Message));
            } catch (Exception ex) {
                Console.Out.WriteLine(String.Format("[ERROR] Unknown Error: {0}\n", ex.Message));
            }
            Application.Run();
        }
Ejemplo n.º 4
0
        public MainClass()
        {
            Application.Init();
            Console.WriteLine("ClarionApp V0.8");
            try
            {
                ws = new WSProxy("localhost", 4011);

                String message = ws.Connect();

                if (ws != null && ws.IsConnected)
                {
                    Console.Out.WriteLine("[SUCCESS] " + message + "\n");
                    if (!skipReset)
                    {
                        ws.SendWorldReset();
                        ws.NewBrick(4, 747, 2, 800, 567);
                        ws.NewBrick(4, 50, -4, 747, 47);
                        ws.NewBrick(4, 49, 562, 796, 599);
                        ws.NewBrick(4, -2, 6, 50, 599);

                        // Create some food
                        ws.NewFood(0, 415, 212);
                        ws.NewFood(0, 237, 321);
                        ws.NewFood(0, 165, 440);

                        // Create 9 jewels of each color, to enable easy planning
                        ws.NewJewel(0, 200, 200);
                        ws.NewJewel(0, 200, 220);
                        ws.NewJewel(0, 200, 440);
                        ws.NewJewel(0, 420, 100);
                        ws.NewJewel(0, 420, 220);
                        ws.NewJewel(0, 420, 440);
                        ws.NewJewel(0, 640, 100);
                        ws.NewJewel(0, 640, 220);
                        ws.NewJewel(0, 640, 440);
                        ws.NewJewel(1, 200, 200);
                        ws.NewJewel(1, 140, 340);
                        ws.NewJewel(1, 140, 500);
                        ws.NewJewel(1, 340, 220);
                        ws.NewJewel(1, 340, 340);
                        ws.NewJewel(1, 340, 500);
                        ws.NewJewel(1, 600, 140);
                        ws.NewJewel(1, 600, 340);
                        ws.NewJewel(1, 600, 500);
                        ws.NewJewel(2, 250, 170);
                        ws.NewJewel(2, 250, 240);
                        ws.NewJewel(2, 250, 400);
                        ws.NewJewel(2, 440, 170);
                        ws.NewJewel(2, 440, 240);
                        ws.NewJewel(2, 440, 400);
                        ws.NewJewel(2, 530, 170);
                        ws.NewJewel(2, 530, 240);
                        ws.NewJewel(2, 530, 400);

                        ws.NewJewel(3, 260, 100);
                        ws.NewJewel(3, 260, 220);
                        ws.NewJewel(3, 260, 440);
                        ws.NewJewel(3, 500, 100);
                        ws.NewJewel(3, 500, 220);
                        ws.NewJewel(3, 480, 440);
                        ws.NewJewel(3, 700, 100);
                        ws.NewJewel(3, 700, 220);
                        ws.NewJewel(3, 700, 440);
                        ws.NewJewel(4, 200, 140);
                        ws.NewJewel(4, 200, 340);
                        ws.NewJewel(4, 200, 500);
                        ws.NewJewel(4, 400, 220);
                        ws.NewJewel(4, 400, 340);
                        ws.NewJewel(4, 400, 500);
                        ws.NewJewel(4, 660, 140);
                        ws.NewJewel(4, 660, 340);
                        ws.NewJewel(4, 660, 500);
                        ws.NewJewel(5, 310, 170);
                        ws.NewJewel(5, 310, 240);
                        ws.NewJewel(5, 310, 400);
                        ws.NewJewel(5, 500, 170);
                        ws.NewJewel(5, 500, 240);
                        ws.NewJewel(5, 500, 400);
                        ws.NewJewel(5, 590, 170);
                        ws.NewJewel(5, 590, 240);
                        ws.NewJewel(5, 590, 400);
                    }
                    ws.NewCreature(100, 100, 0, out creatureId, out creatureName);
                    ws.SendCreateLeaflet();

                    if (!String.IsNullOrWhiteSpace(creatureId))
                    {
                        ws.SendStartCamera(creatureId);
                        ws.SendStartCreature(creatureId);
                    }

                    Console.Out.WriteLine("Creature created with name: " + creatureId + "\n");
                    agent = new ClarionAgent(ws, creatureId, creatureName);
                    agent.Run();
                    Console.Out.WriteLine("Running Simulation ...\n");
                }
                else
                {
                    Console.Out.WriteLine("The WorldServer3D engine was not found ! You must start WorldServer3D before running this application !");
                    System.Environment.Exit(1);
                }
            }
            catch (WorldServerInvalidArgument invalidArtgument)
            {
                Console.Out.WriteLine(String.Format("[ERROR] Invalid Argument: {0}\n", invalidArtgument.Message));
            }
            catch (WorldServerConnectionError serverError)
            {
                Console.Out.WriteLine(String.Format("[ERROR] Is is not possible to connect to server: {0}\n", serverError.Message));
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(String.Format("[ERROR] Unknown Error: {0}\n", ex.Message));
            }
            Application.Run();
        }