Re: Robocode Tank Royale - Python?
fnl <[email protected]> Mon, 30 Sep 2024 15:54:48 -0700 (PDT)
| Newsgroups | gmane.comp.java.robocode |
|---|---|
| Message-ID | <[email protected]> |
------=_Part_10150_1652142966.1727736888961 Content-Type: multipart/alternative; boundary="----=_Part_10151_1031927243.1727736888961" ------=_Part_10151_1031927243.1727736888961 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable You can set the turn timeout in microseconds (us) for each game type. This= =20 is possible from the GUI from the menu: Battle -> Setup Rules. The default= =20 turn timeout is set to 30.000 microseconds =3D 30 ms Or it can be set manually in the games.properties file, e.g. as=20 `1v1.turnTimeout=3D30000 You are right that the network traffic and also WebSocket implementation at= =20 the server and client (bot) side introduce some latency. You can also create your own Observer that subscribe to events from the=20 server, which you record. This way you can train your AI based on the=20 recorded data without taking turn timeout and network latency into account. Cheers, - Flemming tirsdag den 1. oktober 2024 kl. 00.34.44 UTC+2 skrev Sarb: > Hello Flemming, > Perhaps you can help with a follow-up question. To help, I'd like to shar= e=20 > some background of my use case. > I am using Robocode to explore AI. Namely RL and Neural Nets. To expedite= =20 > training, in the classic Robocode, I rely heavily upon the feature whereb= y=20 > minimizing the UI greatly speeds up the simulation and hence data=20 > collection. Now I could have missed it, but is something similar possible= =20 > in Royale? If so, I expect the simulation bottleneck would now be speed o= f=20 > websocket traffic right? > > BTW. My motivation for programming the bots in Python is of course to=20 > enable use of existing libraries such as PyTorch & Tensorflow. > Thank you, > Sarb > > On Tuesday 24 September 2024 at 09:24:59 UTC-7 fnl wrote: > >> *Correction:* >> Jython <https://www.jython.org/> is a Python implementation for Java,=20 >> which can be used for the the existing Java Bot API=20 >> <https://robocode-dev.github.io/tank-royale/api/java/dev/robocode/tankro= yale/botapi/package-summary.html> for=20 >> Robocode Tank Royale. >> tirsdag den 24. september 2024 kl. 18.22.22 UTC+2 skrev fnl: >> >>> Hi Sarb, >>> >>> Currently, there are two official bot APIs for Robocode Tank Royale: >>> >>> *Java platform:*=20 >>> https://github.com/robocode-dev/tank-royale/tree/main/bot-api/java >>> *.Net platform*:=20 >>> https://github.com/robocode-dev/tank-royale/tree/main/bot-api/dotnet >>> >>> And at some point I will introduce an API for web as well. >>> >>> If you want to build an API from scratch, you could choose to: >>> 1) Create an API very similar to the current APIs that are made very=20 >>> similar on purpose. Meaning that your Python API would have same classe= s=20 >>> and methods, but in Python style of course. >>> 2) Create your own version and just use communicate with the server in = a=20 >>> more "raw" fashion by communicating over a WebSocket. >>> >>> If you choose option 2, you need to send and receive messages using the= *protocol=20 >>> *described here: >>> >>> https://github.com/robocode-dev/tank-royale/blob/main/schema/schemas/ga= me/README.md >>> >>> And the *schemas *(message formats) are available here (In JsonSchema= =20 >>> <https://json-schema.org/specification>format) >>> https://github.com/robocode-dev/tank-royale/tree/main/schema/schemas/ga= me >>> >>> If you choose option 1, you should create something similar to *BaseBot= =20 >>> *as a first step (like I did), which handles the basic communication=20 >>> between a bot and the server. >>> Later you can create a *Bot *with more advanced methods as step 2. >>> >>> Also note that you could use the existing APIs as is. For example, we= =20 >>> have Jython <https://www.jython.org/>, which is a Python implementation= =20 >>> for the existing Java Bot AP=20 >>> <https://robocode-dev.github.io/tank-royale/api/java/dev/robocode/tankr= oyale/botapi/package-summary.html> >>> I. >>> And you could use Python.Net <https://pythonnet.github.io/> for with=20 >>> the existing .Net Bot API=20 >>> <https://robocode-dev.github.io/tank-royale/api/dotnet/api/Robocode.Tan= kRoyale.BotApi.html> >>> . >>> >>> I you want to do a real Python API that are similar to the existing one= ,=20 >>> I will be happy to assist you. =F0=9F=91=8D >>> I guess most code from the existing platforms can be translated without= =20 >>> a big hassle for Python. I did the same for Java to .Net, and I will do= it=20 >>> again later for the coming web API. =F0=9F=98=8A >>> >>> Best regards, >>> - Flemming >>> tirsdag den 24. september 2024 kl. 18.00.54 UTC+2 skrev Sarb: >>> >>>> Apologies if this question has already been asked. >>>> >>>> I am interested in developing bots in Python. It appears this may be= =20 >>>> possible with Robocode Tank Royale. How would I go about building a Py= thon=20 >>>> bot API? Any pointers or guidance would be greatly appreciated. >>>> >>>> *Refs*: >>>> >>>> 1. https://robocode-dev.github.io/tank-royale/ >>>> =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/ef816506-dde6-4fd6-b7a0-f5403eb182e4n%40googlegroups.com. ------=_Part_10151_1031927243.1727736888961 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable You can set the turn timeout in microseconds (us) for each game type. This = is possible from the GUI from the menu: Battle -> Setup Rules. The defau= lt turn timeout is set to 30.000 microseconds =3D 30 ms<br />Or it can be s= et manually in the games.properties file, e.g. as `1v1.turnTimeout=3D30000<= br /><br />You are right that the network traffic and also WebSocket implem= entation at the server and client (bot) side introduce some latency.<br /><= br />You can also create your own Observer that subscribe to events from th= e server, which you record. This way you can train your AI based on the rec= orded data without taking turn timeout and network latency into account.<br= /><br />Cheers,<br />- Flemming<br /><br /><div class=3D"gmail_quote"><div= dir=3D"auto" class=3D"gmail_attr">tirsdag den 1. oktober 2024 kl. 00.34.44= UTC+2 skrev Sarb:<br/></div><blockquote class=3D"gmail_quote" style=3D"mar= gin: 0 0 0 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: = 1ex;">Hello Flemming,<br>Perhaps you can help with a follow-up question. To= help, I'd like to share some background of my use case.<br>I am using = Robocode to explore AI. Namely RL and Neural Nets. To expedite training, in= the classic Robocode, I rely heavily upon the feature whereby minimizing t= he UI greatly speeds up the simulation and hence data collection. Now I cou= ld have missed it, but is something similar possible in Royale? If so, I ex= pect the simulation bottleneck would now be speed of websocket traffic righ= t?<div><br></div><div>BTW. My motivation for programming the bots in Python= is of course to enable use of existing libraries such as PyTorch & Ten= sorflow.<br>Thank you,<br>Sarb<br><br></div><div class=3D"gmail_quote"></di= v><div class=3D"gmail_quote"><div dir=3D"auto" class=3D"gmail_attr">On Tues= day 24 September 2024 at 09:24:59 UTC-7 fnl wrote:<br></div></div><div clas= s=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 0= .8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><b>Correction= :</b><br><a href=3D"https://www.jython.org/" rel=3D"nofollow" style=3D"colo= r:rgb(26,115,232)" target=3D"_blank" data-saferedirecturl=3D"https://www.go= ogle.com/url?hl=3Dda&q=3Dhttps://www.jython.org/&source=3Dgmail&= ;ust=3D1727822997727000&usg=3DAOvVaw1w9E2ReGTfB4CbJf9Ac0mA">Jython</a>= =C2=A0is a Python implementation for Java, which can be used for the=C2=A0t= he existing=C2=A0<a href=3D"https://robocode-dev.github.io/tank-royale/api/= java/dev/robocode/tankroyale/botapi/package-summary.html" rel=3D"nofollow" = style=3D"color:rgb(26,115,232)" target=3D"_blank" data-saferedirecturl=3D"h= ttps://www.google.com/url?hl=3Dda&q=3Dhttps://robocode-dev.github.io/ta= nk-royale/api/java/dev/robocode/tankroyale/botapi/package-summary.html&= source=3Dgmail&ust=3D1727822997727000&usg=3DAOvVaw1nYDJWsTYl_tl518X= n2ocj">Java Bot API</a>=C2=A0for Robocode Tank Royale.<br><div class=3D"gma= il_quote"><div dir=3D"auto" class=3D"gmail_attr">tirsdag den 24. september = 2024 kl. 18.22.22 UTC+2 skrev fnl:<br></div><blockquote class=3D"gmail_quot= e" style=3D"margin:0 0 0 0.8ex;border-left:1px solid rgb(204,204,204);paddi= ng-left:1ex">Hi Sarb,<br><br>Currently, there are two official bot APIs for= Robocode Tank Royale:<br><br><b>Java platform:</b>=C2=A0<a href=3D"https:/= /github.com/robocode-dev/tank-royale/tree/main/bot-api/java" rel=3D"nofollo= w" target=3D"_blank" data-saferedirecturl=3D"https://www.google.com/url?hl= =3Dda&q=3Dhttps://github.com/robocode-dev/tank-royale/tree/main/bot-api= /java&source=3Dgmail&ust=3D1727822997727000&usg=3DAOvVaw3Vw1K08= 225HaRMoTz9ZDTB">https://github.com/robocode-dev/tank-royale/tree/main/bot-= api/java</a><br><b>.Net platform</b>:=C2=A0<a href=3D"https://github.com/ro= bocode-dev/tank-royale/tree/main/bot-api/dotnet" rel=3D"nofollow" target=3D= "_blank" data-saferedirecturl=3D"https://www.google.com/url?hl=3Dda&q= =3Dhttps://github.com/robocode-dev/tank-royale/tree/main/bot-api/dotnet&= ;source=3Dgmail&ust=3D1727822997727000&usg=3DAOvVaw00LI8KkxDmSJ90e_= 8Dj7HZ">https://github.com/robocode-dev/tank-royale/tree/main/bot-api/dotne= t</a><br><br>And at some point I will introduce an API for web as well.<br>= <br>If you want to build an API from scratch, you could choose to:<br>1) Cr= eate an API very similar to the current APIs that are made very similar on = purpose. Meaning that your Python API would have same classes and methods, = but in Python style of course.<br>2) Create your own version and just use c= ommunicate with the server in a more "raw" fashion by communicati= ng over a WebSocket.<br><br>If you choose option 2, you need to send and re= ceive messages using the <b>protocol </b>described here:<br><a href=3D"http= s://github.com/robocode-dev/tank-royale/blob/main/schema/schemas/game/READM= E.md" rel=3D"nofollow" target=3D"_blank" data-saferedirecturl=3D"https://ww= w.google.com/url?hl=3Dda&q=3Dhttps://github.com/robocode-dev/tank-royal= e/blob/main/schema/schemas/game/README.md&source=3Dgmail&ust=3D1727= 822997727000&usg=3DAOvVaw2wzcfocrU9tecQW3GuTZmj">https://github.com/rob= ocode-dev/tank-royale/blob/main/schema/schemas/game/README.md</a><br><br>An= d the <b>schemas </b>(message formats) are available here (In <a href=3D"ht= tps://json-schema.org/specification" rel=3D"nofollow" target=3D"_blank" dat= a-saferedirecturl=3D"https://www.google.com/url?hl=3Dda&q=3Dhttps://jso= n-schema.org/specification&source=3Dgmail&ust=3D1727822997727000&am= p;usg=3DAOvVaw30a_yxR2w0ixx2_YJK2Gt4">JsonSchema </a>format)<br><a href=3D"= https://github.com/robocode-dev/tank-royale/tree/main/schema/schemas/game" = rel=3D"nofollow" target=3D"_blank" data-saferedirecturl=3D"https://www.goog= le.com/url?hl=3Dda&q=3Dhttps://github.com/robocode-dev/tank-royale/tree= /main/schema/schemas/game&source=3Dgmail&ust=3D1727822997727000&= ;usg=3DAOvVaw33ANa9SGbuqhlQlczJ7Krr">https://github.com/robocode-dev/tank-r= oyale/tree/main/schema/schemas/game</a><br><br>If you choose option 1, you = should create something similar to <b>BaseBot </b>as a first step (like I d= id), which handles the basic communication between a bot and the server.<br= >Later you can create a <b>Bot </b>with more advanced methods as step 2.<br= ><br>Also note that you could use the existing APIs as is. For example, we = have <a href=3D"https://www.jython.org/" rel=3D"nofollow" target=3D"_blank"= data-saferedirecturl=3D"https://www.google.com/url?hl=3Dda&q=3Dhttps:/= /www.jython.org/&source=3Dgmail&ust=3D1727822997727000&usg=3DAO= vVaw1w9E2ReGTfB4CbJf9Ac0mA">Jython</a>, which is a Python implementation fo= r the existing=C2=A0<a href=3D"https://robocode-dev.github.io/tank-royale/a= pi/java/dev/robocode/tankroyale/botapi/package-summary.html" rel=3D"nofollo= w" target=3D"_blank" data-saferedirecturl=3D"https://www.google.com/url?hl= =3Dda&q=3Dhttps://robocode-dev.github.io/tank-royale/api/java/dev/roboc= ode/tankroyale/botapi/package-summary.html&source=3Dgmail&ust=3D172= 7822997727000&usg=3DAOvVaw1nYDJWsTYl_tl518Xn2ocj">Java Bot AP</a>I.<div= >And you could use <a href=3D"https://pythonnet.github.io/" rel=3D"nofollow= " target=3D"_blank" data-saferedirecturl=3D"https://www.google.com/url?hl= =3Dda&q=3Dhttps://pythonnet.github.io/&source=3Dgmail&ust=3D172= 7822997727000&usg=3DAOvVaw2VwXlCb1UVu2aPI9SEQ097">Python.Net</a> for wi= th the existing<a href=3D"https://robocode-dev.github.io/tank-royale/api/do= tnet/api/Robocode.TankRoyale.BotApi.html" rel=3D"nofollow" target=3D"_blank= " data-saferedirecturl=3D"https://www.google.com/url?hl=3Dda&q=3Dhttps:= //robocode-dev.github.io/tank-royale/api/dotnet/api/Robocode.TankRoyale.Bot= Api.html&source=3Dgmail&ust=3D1727822997727000&usg=3DAOvVaw02o1= Tg86XcsuljqLiOht2s"> .Net Bot API</a>.<br><br>I you want to do a real Pytho= n API that are similar to the existing one, I will be happy to assist you. = =F0=9F=91=8D<br>I guess most code from the existing platforms can be transl= ated without a big hassle for Python. I did the same for Java to .Net, and = I will do it again later for the coming web API. =F0=9F=98=8A<br><br>Best r= egards,<br>- Flemming</div><div class=3D"gmail_quote"><div dir=3D"auto" cla= ss=3D"gmail_attr">tirsdag den 24. september 2024 kl. 18.00.54 UTC+2 skrev S= arb:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 0.8ex= ;border-left:1px solid rgb(204,204,204);padding-left:1ex">Apologies if this= question has already been asked.<div><br></div><div>I am interested in dev= eloping bots in Python. It appears this may be possible with Robocode Tank = Royale. How would I go about building a Python bot API? Any pointers or gui= dance would be greatly appreciated.<div><br></div><div><i>Refs</i>:</div><d= iv><ol><li><a href=3D"https://robocode-dev.github.io/tank-royale/" rel=3D"n= ofollow" target=3D"_blank" data-saferedirecturl=3D"https://www.google.com/u= rl?hl=3Dda&q=3Dhttps://robocode-dev.github.io/tank-royale/&source= =3Dgmail&ust=3D1727822997728000&usg=3DAOvVaw3HL9B-inue148QP9_EOnEp"= >https://robocode-dev.github.io/tank-royale/</a><br></li></ol></div></div><= /blockquote></div></blockquote></div></blockquote></div></blockquote></div> <p></p> -- <br /> You received this message because you are subscribed to the Google Groups &= quot;Robocode" 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/ef816506-dde6-4fd6-b7a0-f5403eb182e4n%40googlegroups.co= m?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid= /robocode/ef816506-dde6-4fd6-b7a0-f5403eb182e4n%40googlegroups.com</a>.<br = /> ------=_Part_10151_1031927243.1727736888961-- ------=_Part_10150_1652142966.1727736888961--