Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Radius param for search()
#1
Would be nice for path finding & detecting objects near a point away from the robot.

search(cat[, pos][, radius]);

And maybe:

object items[] = searchall(cat[, pos], radius);



I actually already did this myself.
#2
Adding the radius parameter makes no sense to me, it would be better to add all radar() parameters.
searchall() is a great idea too
#3
I like the idea of using all radar parameters.
But using angle and focus might be confusing.

Maybe if the search function has an orientation of it's own,
direction("search position") could be relative 0 angle for search.

So it could be used and calculated in terms of right angles.

Radius was just max parameter by a different name.

Edit: Or just leave out angle and focus, replaced by position. search(cat, pos, min, max, sens, filter);
#4
Radius for search can be done in a custom CBOT function pretty easily.

Returning an array of all objects of certain category is even easier.

I bet angular limitations are possible as well. Tho I don't see much of a use for those. You can choose a percise spot to look at anyway.

Example:
Code:
object object::bettersearch(int cat, point pos, float rmin, float rmax)
{
    // Generate objects list
    
    object objects[];
    int i = 0;
    float range = 0;
    int size;
    
    while(true)
    {
        objects[i] = radar(cat, 0, 360, range);
        if(objects[i] == null)
        {
            size = i;
            break;
        }
        
        range = distance(this.position,objects[i].position)+0.1;
        i++;
    }
    
    // Objects list ready
    // One could 'return objects;' here to get searchAll
    
    float distances[];
    int result = nan;
    
    for(i=0;i<size;i++)
    {
        distances[i] = distance(pos,objects[i].position); // Determine distances
        if (distances[i] < rmin) distances[i] = 1000; // Trim objects too close
        
        if (distances[i] < rmax) // Locate closest object
        {
            rmax = distances[i];
            result = i;
        }
    }
    
    // Return the result
    
    if (result == nan)
    {
        message("Object not found",DisplayError);
        return null;
    }
    else return objects[result];
}
 
I didn't post in a while now did I?
My Code Battle League program: MhrodeBattle.txt

Welcome back, Mrocza. You last visited: Sunday, July 7th, 2013, 02:12 pm 
http://imgur.com/L3Y8bQz
#5
This is similar to what I was doing at first, but it was
very slow to call such a function hundreds of times per minute.
Which then made creating a path finding algorithm pretty pointless.

The game engine already has this functionality, it only needed to be enabled.
The A* algorithm I have now, is as fast and even more accurate than goto().

I imagine search() and searchall() as being built-in functions of
the satellite that is usually in orbit above your position. Wink


Forum Jump:


Users browsing this thread: 1 Guest(s)