Re: How to use getTurn() correctly for an AdvancedRobot?

fnl <[email protected]> Sat, 27 Nov 2021 06:58:53 -0800 (PST)
Newsgroups gmane.comp.java.robocode
Message-ID <[email protected]>
------=_Part_4473_876794869.1638025133023
Content-Type: multipart/alternative; 
	boundary="----=_Part_4474_1601895140.1638025133023"

------=_Part_4474_1601895140.1638025133023
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi John and welcome to Robocode. :)

The best source to get tips about Robocode is the RoboWiki here:
https://robowiki.net/wiki/Main_Page

The getTurn() method returns the current turn number, which is the same as=
=20
the "time" or "tick" in Robocode.

If you want to do something every 100 ticks then you can use the modulo=20
operator <https://www.baeldung.com/modulo-java>.
So you could e.g. do something like:

If (getTime() % 100 =3D=3D 0) { // every 100th tick
    // do something else with radar
}

I guess your radar strategy depends on how many enemy bots are (left) on=20
the battlefield (using the getOthers()=20
<https://robocode.sourceforge.io/docs/robocode/robocode/RobotStatus.html#ge=
tOthers-->=20
method).
E.g. if there is only one robot left, you might as well "lock" the radar on=
=20
this last robot (1-to-1 battle).
If there are two robots left, then a better strategy might be to sweep the=
=20
shortest distance for the radar between the two robots.

Make sure to have a look at some of the well-known radar strategies here at=
=20
the RoboWiki:
https://robowiki.net/wiki/Radar

Best regards,
- Flemming

l=C3=B8rdag den 27. november 2021 kl. 15.43.24 UTC+1 skrev John Smith:

> I am very knew to robocode and I am trying to have some way of keeping=20
> track of time for some of my code. For example: I want my radar to do a 3=
60=20
> scan to check for greater threats than the current target and I would lik=
e=20
> it to do it once every 100 ticks/turns.=20
>
> Any tips would be great. Unfortunately it appears that a lot of website=
=20
> links are no longer hosted that have examples robocode.
>
> Thank you for your time.   =20
>

--=20
You received this message because you are subscribed to the Google Groups "=
Robocode" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/=
robocode/59e17db0-9b02-4c84-8eb0-79c083d8fae3n%40googlegroups.com.

------=_Part_4474_1601895140.1638025133023
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi John and welcome to Robocode. :)<br><br>The best source to get tips abou=
t Robocode is the RoboWiki here:<br>https://robowiki.net/wiki/Main_Page<br>=
<br>The getTurn() method returns the current turn number, which is the same=
 as the "time" or "tick" in Robocode.<div><br></div><div>If you want to do =
something every 100 ticks then you can use the<a href=3D"https://www.baeldu=
ng.com/modulo-java"> modulo operator</a>.</div><div>So you could e.g. do so=
mething like:</div><div><br></div><div>If (getTime() % 100 =3D=3D 0) { // e=
very 100th tick</div><div>&nbsp; &nbsp; // do something else with radar</di=
v><div>}</div><div><br></div><div>I guess your radar strategy depends on ho=
w many enemy bots are (left) on the battlefield (using the <a href=3D"https=
://robocode.sourceforge.io/docs/robocode/robocode/RobotStatus.html#getOther=
s--">getOthers()</a> method).</div><div>E.g. if there is only one robot lef=
t, you might as well "lock" the radar on this last robot (1-to-1 battle).</=
div><div>If there are two robots left, then a better strategy might be to s=
weep the shortest distance for the radar between the two robots.<br><br>Mak=
e sure to have a look at some of the well-known radar strategies here at th=
e RoboWiki:<br>https://robowiki.net/wiki/Radar</div><div><br></div><div>Bes=
t regards,</div><div>- Flemming<br><br></div><div class=3D"gmail_quote"><di=
v dir=3D"auto" class=3D"gmail_attr">l=C3=B8rdag den 27. november 2021 kl. 1=
5.43.24 UTC+1 skrev John Smith:<br/></div><blockquote class=3D"gmail_quote"=
 style=3D"margin: 0 0 0 0.8ex; border-left: 1px solid rgb(204, 204, 204); p=
adding-left: 1ex;"><div>I am very knew to robocode and I am trying to have =
some way of keeping track of time for some of my code. For example: I want =
my radar to do a 360 scan to check for greater threats than the current tar=
get and I would like it to do it once every 100 ticks/turns. <br></div><div=
><br></div><div>Any tips would be great. Unfortunately it appears that a lo=
t of website links are no longer hosted that have examples robocode.</div><=
div><br></div><div>Thank you for your time.=C2=A0 =C2=A0 </div></blockquote=
></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;Robocode&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">robocode+u=
[email protected]</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/d/msgid/robocode/59e17db0-9b02-4c84-8eb0-79c083d8fae3n%40googlegroups.co=
m?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid=
/robocode/59e17db0-9b02-4c84-8eb0-79c083d8fae3n%40googlegroups.com</a>.<br =
/>

------=_Part_4474_1601895140.1638025133023--

------=_Part_4473_876794869.1638025133023--