Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't make the programm find 4 items
#1
Hi,
I have a problem, I'm stuck on the first mission of the second level of the game, specifically I have problems with one particular task, which is to make my winged bot to find 4 pieces of titaium ore, it only finds 1 piece of the ore and then proceeds to find the the same piece of ore instead of going for another one.
So, the question is, how to make the bot to find all  4 pieces needed to complete the task (through class system by adding to the found object a specific characteristic or something)

Here is the code I wrote.

Code:
extern void object::New()
{
    object rdr;
    int counter = 0;
    float range = 0;
    
    do
    {
        rdr = radar(TitaniumOre, 0, 360, range);
        if (rdr != null)
        {
            goto (rdr.position);
            grab ();
            object home;
            home = radar(SpaceShip);
            goto (space (home.position));
            drop ();
            counter = counter + 1;
            message(counter);
        }
        else
        {
            message ("Titanium not found");
            goto(rdr.position);
            rdr = radar(TitaniumOre, 0, 360, range++);
        }
    }
    while (counter < 5);
}
 P.S sorry for bad english.
#2
The radar command has min parameter which will make it find closest ores that are at least min away. If I remember correctly it's just another parameter after regular range, so:



Code:
radar(TitaniumOre, 0, 360, range, 15)

This should make it so bot doesn't look for ores that are within 15 meters from it. Notice that it works as properly only if you radar while in spaceship. Do check radar in SatCom though, as I am not sure.

If you are a perfectionist, you can browse though list of all objects on map, save all Titanium Ores that are not on space ship (> 10m away) in array, pick the from the array the one that's closest. This level of pettiness shouldn't be necessary though
"Deep within all of us lives an idiot, and if you let that idiot dictate your decisions your live is going to be rough."
~ Ryan Letourneau, 2k15
#3
(07-09-2017, 11:12 AM)radioactivity Wrote: The radar command has min parameter which will make it find closest ores that are at least min away. If I remember correctly it's just another parameter after regular range, so:



Code:
radar(TitaniumOre, 0, 360, range, 15)

This should make it so bot doesn't look for ores that are within 15 meters from it. Notice that it works as properly only if you radar while in spaceship. Do check radar in SatCom though, as I am not sure.

If you are a perfectionist, you can browse though list of all objects on map, save all Titanium Ores that are not on space ship (> 10m away) in array, pick the from the array the one that's closest. This level of pettiness shouldn't be necessary though
 Thank you, but I've already found the problem. Command radar has 'sens', which determines whether the closest objects will be found first or the fartherst.
#4
If you always go to the furthest ore, your robot will have to travel a lot further than if you chose the closest one that's not on a SpaceShip yet, so @radioactivity's solution is technically more optimized. In Gold you also have radarall() that could be useful for the second solution of choosing from all objects. An easier solution if you want to detect objects while you are not on a SpaceShip would be the search() command which is like radar() but relative to position given as argument.
#5
Thank you guys for your promt answers. Here is the code I ended up with

Code:
extern void object::Transmutation()
{
    object [] list;
    object alchemist;
    list = radarall (TitaniumOre);
    message ("Found " + sizeof(list) + " piece(s) of titanium ore");
    
    for(int i=0; i<sizeof(list); i++)
    {
          object item = list[i];
          goto(item.position);
          grab();
        
          alchemist = radar(Converter);
          goto(alchemist.position);
          drop ();
          move (-2.5);
          wait (8);
          
        while (alchemist.busy ())
        {
            wait (1);
        }
           move (2.5);
           grab ();
           goto (space());
           drop ();
    }
    message ("The task is completed");
}
But I have yet another question Angel .
I have a task to find a black box. So, is there any way to check whether it is possible for a bot to get to the box and return back to the base?
Here is code I wrote.

Code:
extern void object::New()
{
    if (this.energyCell.energyLevel == 1)
    {
        object questitem;
        object home;
        questitem = radar (BlackBox);
        home = radar (SpaceShip);
        goto (questitem.position);
        grab ();
        goto (home.position);
        drop ();
    }
    else {
        message ("I can't");
    }
}
My solution is to check energy level of the bot. If it is fully charged then the bot flies there. It works well on this level, but it is not perfect.
#6
I don't think you can check that, but It shouldn't be needed. I am pretty sure a single full battery is enough to go across entire map, if Black Box is further than ~half map away you can take a spare cell with you and switch it when you're about to pick up Black Box
"Deep within all of us lives an idiot, and if you let that idiot dictate your decisions your live is going to be rough."
~ Ryan Letourneau, 2k15


Forum Jump:


Users browsing this thread: 2 Guest(s)