Colobot Forum - International Colobot Community
[solved] No problem - Printable Version

+- Colobot Forum - International Colobot Community (https://colobot.info/forum)
+-- Forum: [Archive] New forum (2015-2019) (https://colobot.info/forum/forumdisplay.php?fid=76)
+--- Forum: Colobot: Gold Edition Basics (https://colobot.info/forum/forumdisplay.php?fid=58)
+---- Forum: Help (https://colobot.info/forum/forumdisplay.php?fid=61)
+---- Thread: [solved] No problem (/showthread.php?tid=869)



[solved] No problem - nknk - 12-22-2016

Hi,

( PLOT TWIST : THAT WAS A SYNTAX ERROR : missing "sens" parameter in radarall )


I'm actually trying to succeed a code battle with a friend.

I would like to try my code against bots, the 2nd "code battle" mission. But I had a problem. My code works against ants. I dont kills them, but I can build an army of robots. But when I try against bots, my robot stop on a call on busy();

Here is the piece of code :

Code:
bool checkTitanium(){
        object[] converters = radarall ( Converter, 0, 360, 0, 500, FilterFriendly|this.me.team );
        if(sizeof(converters)==0){return true;}
        for (int i = 0; i < sizeof(converters); ++i)
        {
            object conv = converters[i];
            bool bu = conv.busy();
            if(bu==true){
                continue;
            }

I play against the red robot, my converter just made a fresh Titanium, so it should be not busy anymore. I play with errmode(0), it just stopped on this word with no feedback.

I've tried to move this call of "busy()" but it seems to be this function...

Thank you for your help Smile


RE: A problem ? (maybe) with busy ft ? - tomangelo - 12-22-2016

Without errmode(0); it returns "Unable to control enemy units", as it's refering to enemy Converter, but I deleted '|this.me.team' part, as it's probably some custom class that I don't have, so reason might be a bit different in your case.
Still FilterFriendly should IMHO filter enemy Converters from radarall(); results, so I would consider it as a bug.


RE: A problem ? (maybe) with busy ft ? - nknk - 12-22-2016

This.me contains the bot objet. So this.me.team returns the same thing as "this.team" in an "object::" function.
I had problems with this always returning the first robot in "object::" functions, so I only use classes now.

Should it work if ask for "FilterFriendly | MyTeamId" or should I remove the "FilterFriendly" in codebattle (and use it only if My team id is 0) ? In that case, FilterFriendly should be named "FilterBots" or "FilterNoAnts" :p

So it will be the same for "FilterEnemy" : it will not return bots, only ants, am I right ?

So I shoud write something like
Code:
int getFriendlyFilter(){
 if(this.me.team==0)
   return FilterFriendly;
 else return this.me.team;
}
bool checkTitanium(){
       object[] converters = radarall ( Converter, 0, 360, 0, 500, getFriendlyFilter() );
       if(sizeof(converters)==0){return true;}
       for (int i = 0; i < sizeof(converters); ++i)
       {
           object conv = converters[i];
           bool bu = conv.busy();
           if(bu==true){
               continue;
           }

IMHO "busy" should also be available for strategic purpose.


Thank you for your priceless help !!

here is "your reward" :p : https://www.dropbox.com/sh/mpups9y5f00ekbd/AABD4J3yB2VpChQ3lm-ca4bMa?dl=0&preview=artificial.mp3


RE: A problem ? (maybe) with busy ft ? - krzys_h - 12-22-2016

You should only have to use FilterFriendly without using your team id. If that still returns, it's likely abug.


RE: A problem ? (maybe) with busy ft ? - nknk - 12-22-2016

In fact, I added my team id in an attempt to fix the problem.

It was crashing already with
Code:
radarall ( Converter, 0, 360, 0, 500, FilterFriendly);

I will try with just my team id, to fix my problem in the current game's behavior.


RE: A problem ? (maybe) with busy ft ? - melex750 - 12-22-2016

You are missing the 'sens' parameter.
Code:
radarall ( cat, angle, focus, min, max, sens, filter );

// try this
radarall ( Converter, 0, 360, 0, 500, 1, FilterFriendly);



RE: [solved] No problem - nknk - 12-22-2016

(12-22-2016, 02:10 PM)melex750 Wrote: You are missing the 'sens' parameter.
Code:
radarall ( cat, angle, focus, min, max, sens, filter );

// try this
radarall ( Converter, 0, 360, 0, 500, 1, FilterFriendly);

You're right,
Thank you !