problem with isTeammate()

40 views
Skip to first unread message

Måns Englund

unread,
May 7, 2021, 10:36:13 AM5/7/21
to Robocode
Hello!

I am currently developing a team robot which main function will be to protect its leader. However for this to work it has to identify which team a robot belongs to as well as identify its own leader. Unfortunately neither the isTeammate(e.getName()); , which I call in onScannedRobot, or getTeammates() seems to work. The isTeammate() method always returns a value false. When printing out the names of the retrieved bots through the getTeammates function I get SittingDuck (1), SpinBot (1), SpinBot(2) etc. but the bots on the battlefield might have different values in the parentheses or nothing at all if it is the only bot of its kind on the battlefield. Might that be the reason why isTeammate() won't work? I'm currently running robocode v 1.3.9.7

fnl

unread,
May 8, 2021, 11:08:54 AM5/8/21
to Robocode
Thank you for reporting this. I ran a test, and see that you are right that the isTeammate(e.getName()) seems to be broken.
I will have a look into getTeammates() as well, as you are right that these two issues are might be closely related.

I will follow up later, when I have a fix for it.

Cheers,
- Flemming

fnl

unread,
May 8, 2021, 6:29:10 PM5/8/21
to Robocode
I have now made a fix for it, and you can try it out here before a real release comes (later):
- Flemming

fredag den 7. maj 2021 kl. 16.36.13 UTC+2 skrev mans.en...@gmail.com:

Måns Englund

unread,
May 9, 2021, 8:55:12 AM5/9/21
to Robocode
Hi Flemming! 

Thank you for the fast answer and the fix after some testing I can see that it now works as long as there are multiple bots of the same type on the battlefield but unfortunately it still seems to be a problem when only one bot of one type is on the battlefield in a team. For example if my leader is MyFirstLeader its name on the battlefield is MyFirstLeader, since there are no other, but the name I get from getTeammates is MyFirstLeader (1) which then results in isTeammate returning false.

 Thank you for all the help,
Måns

fnl

unread,
May 9, 2021, 9:59:29 AM5/9/21
to Robocode
OK. I will have a look into this scenario as well.

fnl

unread,
May 9, 2021, 3:54:04 PM5/9/21
to Robocode
I now fixed the remaining part. Actually I made sure all robots got a unique robot index suffix on their name.
This also fixed the issue for the TeamRobots.

You can try out the 2nd fix here:
søndag den 9. maj 2021 kl. 14.55.12 UTC+2 skrev mans.en...@gmail.com:

Måns Englund

unread,
May 10, 2021, 5:54:51 AM5/10/21
to Robocode
Hi Flemming!

Thank you very much for the quick fixes, the last one seems to have done the job. My teacher said you knew that we used robocode in our education here in Lund so on behalf of all of us in the course, thank you!

fnl

unread,
May 10, 2021, 6:34:32 AM5/10/21
to Robocode
You are welcome, and thank you for the quick follow-up that confirmes that the fixes now works as expected! :-)

And yes, Markus Borg is kind to keep me updated of what is going on in Lund, and I am excited to learn what you are up to. :-D

I will get started on releasing a new version (1.9.4.2) with this fix, so we have an official version with this fix that everybody can benifit from.

Cheers,
- Flemming

Reply all
Reply to author
Forward
0 new messages