Example #1
0
        void processSelectedAction(CreatureActions externalAction)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            if (worldServer != null && worldServer.IsConnected)
            {
                switch (externalAction)
                {
                case CreatureActions.DO_NOTHING:
                    // Do nothing as the own value says
                    break;

                case CreatureActions.ROTATE_CLOCKWISE:
                    worldServer.SendSetAngle(creatureId, 2, -2, 2);
                    break;

                case CreatureActions.GET_JEWEL:
                    worldServer.SendSackIt(creatureId, jewelToGet.Name);
                    break;

                case CreatureActions.GET_FOOD:
                    worldServer.SendEatIt(creatureId, foodToGet.Name);
                    break;

                case CreatureActions.GO_TO_JEWEL:
                    worldServer.SendSetAngle(creatureId, 0, 0, prad);
                    worldServer.SendSetGoTo(creatureId, 2, 2, jewelToGoTo.X1, jewelToGoTo.Y1);
                    break;

                case CreatureActions.GO_TO_FOOD:
                    worldServer.SendSetAngle(creatureId, 0, 0, prad);
                    worldServer.SendSetGoTo(creatureId, 2, 2, foodToGoTo.X1, foodToGoTo.Y1);
                    break;

                case CreatureActions.WANDER:
                    worldServer.SendSetAngle(creatureId, 2, -2, 2);
                    break;

                case CreatureActions.GO_TO_DELIVER:
                    // Send creature to the delivery spot.
                    worldServer.SendSetAngle(creatureId, 0, 0, prad);
                    worldServer.SendSetGoTo(creatureId, 2, 2, deliverySpot.X1, deliverySpot.Y1);
                    break;

                case CreatureActions.DELIVER:
                    // Deliver jewels
                    worldServer.SendDeliver(creatureId, leaflet1Id);
                    worldServer.SendDeliver(creatureId, leaflet2Id);
                    worldServer.SendDeliver(creatureId, leaflet3Id);
                    worldServer.SendStopCreature(creatureId);
                    // Delete the Agent
                    Abort(true);
                    break;

                default:
                    break;
                }
            }
        }
Example #2
0
        void processSelectedAction(CreatureActions externalAction)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            if (worldServer != null && worldServer.IsConnected)
            {
                //Console.WriteLine(externalAction);
                switch (externalAction)
                {
                case CreatureActions.DO_NOTHING:
                    // Do nothing as the own value says
                    break;

                case CreatureActions.ROTATE_CLOCKWISE:
                    //worldServer.SendSetAngle(creatureId, 2, 0, 0);
                    worldServer.SendSetAngle(creatureId, 0.5, -0.5, 0.5);
                    break;

                case CreatureActions.GO_AHEAD:
                    //worldServer.SendSetAngle(creatureId, 1, 1, prad);
                    worldServer.SendSetAngle(creatureId, 0.5, -0.5, 0.5);
                    //worldServer.SendSetAngle(creatureId, 2, 0, 0);
                    break;

                case CreatureActions.GO_TO_JEWEL:
                    worldServer.SendSetGoTo(creatureId, 1, 1, currentJewel.X1, currentJewel.Y1);
                    break;

                case CreatureActions.EAT_FOOD:
                    worldServer.SendEatIt(creatureId, currentFood.Name);
                    break;

                case CreatureActions.GET_JEWEL:
                    worldServer.SendSackIt(creatureId, currentJewel.Name);
                    processLeafletControl(currentJewel.Material.Color);
                    //Console.WriteLine(currentJewel.Name + " | " + currentJewel.Material.Color + " | " + currentJewel.X1 + "|" + currentJewel.Y1);
                    break;

                case CreatureActions.HIDE_JEWEL:
                    worldServer.SendHideIt(creatureId, currentJewel.Name);
                    break;

                case CreatureActions.GOAL_ACHIEVED:
                    worldServer.SendStopCreature(creatureId);
                    processLeafletControl();
                    Console.Out.WriteLine();
                    Console.Out.WriteLine("Clarion Creature: Goal achieved at: " + DateTime.Now);
                    MaxNumberOfCognitiveCycles = CurrentCognitiveCycle;
                    break;

                default:
                    break;
                }
            }
            //Console.WriteLine("Remaining jewel: " + getJewelRemainingTotal());
        }
Example #3
0
        void processSelectedAction(CreatureActions externalAction)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            if (worldServer != null && worldServer.IsConnected)
            {
                //Console.WriteLine("Action choosen: " + externalAction);
                switch (externalAction)
                {
                case CreatureActions.DO_NOTHING:
                    // Do nothing as the own value says
                    break;

                case CreatureActions.ROTATE_CLOCKWISE:
                    //worldServer.SendSetAngle(creatureId, 2, 0, 0);
                    worldServer.SendSetAngle(creatureId, 0.5, -0.5, 0.5);
                    break;

                case CreatureActions.GO_AHEAD:
                    //worldServer.SendSetAngle(creatureId, 1, 1, prad);
                    worldServer.SendSetAngle(creatureId, 0.5, -0.5, 0.5);
                    //worldServer.SendSetAngle(creatureId, 2, 0, 0);
                    break;

                case CreatureActions.GO_TO_JEWEL:
                    worldServer.SendSetGoTo(creatureId, 1, 1, currentJewel.X1, currentJewel.Y1);
                    break;

                case CreatureActions.FUEL_LOW:
                    //Console.WriteLine ("Low fuel working.......current food: " + currentFood);

                    if (currentFood != null)
                    {
                        worldServer.SendSetGoTo(creatureId, 1, 1, currentFood.X1, currentFood.Y1);                          // go to the near food
                    }
                    else
                    {
                        worldServer.SendSetAngle(creatureId, 0.5, -0.5, 0.5);                          // rotate to see more foods
                    }
                    break;

                case CreatureActions.EAT_FOOD:
                    worldServer.SendEatIt(creatureId, currentFood.Name);
                    break;

                case CreatureActions.GET_JEWEL:
                    if (isDesiredJewel(currentJewel.Material.Color))
                    {
                        worldServer.SendSackIt(creatureId, currentJewel.Name);
                    }
                    else
                    {
                        worldServer.SendHideIt(creatureId, currentJewel.Name);                          // Workaround in case to get a jewel that is not needed
                    }

                    processLeafletControl(currentJewel.Material.Color);
                    //Console.WriteLine(currentJewel.Name + " | " + currentJewel.Material.Color + " | " + currentJewel.X1 + "|" + currentJewel.Y1);
                    break;

                case CreatureActions.HIDE_JEWEL:
                    worldServer.SendHideIt(creatureId, currentJewel.Name);
                    break;

                case CreatureActions.GOAL_ACHIEVED:
                    // Creature distance to spot - start
                    String [] creatureXY = worldServer.sendGetCreaturePosition(creatureId);
                    double    creatureX  = Convert.ToDouble(creatureXY [0]);
                    double    creatureY  = Convert.ToDouble(creatureXY [1]);
                    //Console.WriteLine ("Creature X: " + creatureX);
                    //Console.WriteLine ("Creature Y: " + creatureY);
                    double distance = worldServer.CalculateDistanceToCreature(creatureX, creatureY, 700.0, 500.0);
                    //Console.WriteLine ("Creature distance to spot: " + distance);
                    // Creature distance to spot - end

                    if (distance <= 20)
                    {
                        worldServer.SendStopCreature(creatureId);
                        processLeafletControl();
                        exchangeJewels = true;
                        //Console.WriteLine ("Leaflet numbers: ");
                        //Console.WriteLine (Convert.ToString (leaflet1.leafletID));
                        //Console.WriteLine (Convert.ToString (leaflet2.leafletID));
                        //Console.WriteLine (Convert.ToString (leaflet3.leafletID));
                        worldServer.sendDeliverLeaflet(creatureId, Convert.ToString(leaflet1.leafletID));
                        worldServer.sendDeliverLeaflet(creatureId, Convert.ToString(leaflet2.leafletID));
                        worldServer.sendDeliverLeaflet(creatureId, Convert.ToString(leaflet3.leafletID));
                        //Console.WriteLine ("Jewels exchanged!!!");
                        MaxNumberOfCognitiveCycles = CurrentCognitiveCycle;
                        //Console.Out.WriteLine ("Clarion Creature: Goal achieved at: " + DateTime.Now);
                    }
                    else
                    {
                        worldServer.SendSetGoTo(creatureId, 1, 1, 700.0, 500.0);
                    }

                    break;

                default:
                    break;
                }
            }
            //Console.WriteLine("Remaining jewel: " + getJewelRemainingTotal());
        }
Example #4
0
        void processSelectedAction(CreatureActions externalAction)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            if (worldServer != null && worldServer.IsConnected)
            {
                switch (externalAction)
                {
                case CreatureActions.DO_NOTHING:
                    // Do nothing as the own value says
                    break;

                case CreatureActions.ROTATE_CLOCKWISE:
                    Console.WriteLine("Rotate clockwise");
                    worldServer.SendSetAngle(creatureId, 2, -2, 2);
                    break;

                case CreatureActions.GO_TO_CLOSEST_JEWEL:
                    Console.WriteLine("Move to closest jewel required in a leaflet: " + closestJewel.Name);
                    worldServer.SendSetGoTo(creatureId, 1, 1, closestJewel.comX, closestJewel.comY);
                    break;

                case CreatureActions.GO_TO_CLOSEST_FOOD:
                    Console.WriteLine("Move to closest food: " + closestFood.Name);
                    worldServer.SendSetGoTo(creatureId, 1, 1, closestFood.comX, closestFood.comY);
                    break;

                case CreatureActions.GO_AHEAD:
                    Console.WriteLine("Go ahead");
                    worldServer.SendSetAngle(creatureId, 1, 1, prad);
                    break;

                case CreatureActions.EAT_FOOD:
                    worldServer.SendEatIt(creatureId, foodName);
                    Console.WriteLine("Eat food " + foodName);
                    break;

                case CreatureActions.SACK_JEWEL:
                    worldServer.SendSackIt(creatureId, jewelName);
                    Console.WriteLine("Sack jewel " + jewelName);
                    break;

                case CreatureActions.PREPARE_TO_DELIVER_LEAFLET:
                    Console.WriteLine("Ready to deliver " + leafletId);
                    // don't actually deliver it, otherwise the world creates a new leaflet and the 3 will never end
                    //worldServer.SendDeliverIt (creatureId, leafletId);
                    deliverableLeaflets[leafletId] = true;
                    break;

                case CreatureActions.STOP:
                    worldServer.SendStopCreature(creatureId);
                    foreach (string leafletIdKey in deliverableLeaflets.Keys)
                    {
                        worldServer.SendDeliverIt(creatureId, leafletIdKey);
                    }
                    Console.WriteLine("Success! All leaflets delivered. Stop the creature.");
                    mind.ShowCompleteMessage();
                    stopped = true;
                    break;

                default:
                    break;
                }
            }
        }