-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bots receives skipped-turn-event events while dead #83
Comments
@SirStone Thank you for reporting this issue, and also providing the details. I will have a look into this bug. |
@SirStone Could you create a minimum bot that can be used for showing this issue? 😊 |
I've tried to make a simple bot with the java API but looks like the API
itself is stopping to process the events after bot's death, with my API in
Nim I'm printing out for test all received events, so I can see that the
server is still sending out the after-death skipped-turn events.
Sometimes, after several consecutive games where I start a match, stop it,
restart it and so on, I find the server using 100% or more CPU, even with
no running game. I'm not able to replicate it constantly, that's why I
never opened an issue about this but could be that sometime the server
keeps talking to dead bots.
Il Dom 17 Mar 2024, 18:52 Flemming N. Larsen ***@***.***> ha
scritto:
… @SirStone <https://github.com/SirStone> Could you create a minimum bot
that can be used for showing this issue? 😊
I have trouble doing this with the sample bots for Java and C#.
I should like you to attach the source code to this issue.
—
Reply to this email directly, view it on GitHub
<#83 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJ7Z3FINN4MSONANAFEYSLYYXJ6DAVCNFSM6AAAAABE2BQSSGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBSGU2TGOJQGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I agree with you that something needs to be fixed, and it definitely looks like there is something going on at the server side. |
About Nim bot, wait for me, I'll paste here a basic bot
Il Mar 19 Mar 2024, 16:29 Flemming N. Larsen ***@***.***> ha
scritto:
… I've tried to make a simple bot with the java API but looks like the API
itself is stopping to process the events after bot's death, with my API in
Nim I'm printing out for test all received events, so I can see that the
server is still sending out the after-death skipped-turn events. Sometimes,
after several consecutive games where I start a match, stop it, restart it
and so on, I find the server using 100% or more CPU, even with no running
game. I'm not able to replicate it constantly, that's why I never opened an
issue about this but could be that sometime the server keeps talking to
dead bots.
I agree with you that something needs to be fixed, and it definitely looks
like there is something going on at the server side.
I will try this out with your Nim API to reproduce the issue. 🙂
—
Reply to this email directly, view it on GitHub
<#83 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJ7Z3AZJLI5GVED55RYGY3YZBKV3AVCNFSM6AAAAABE2BQSSGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBXGQ4TKNZUGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I will wait for the basic bot. I was able to build and run the Walls NIM 0.1.0 on Ubuntu 22 running on WSL 2 for Windows 11 using Visual Code. |
mmm I imagine you used the code on GitHub, that code is year old and is made with NIM 1.6, that's why is not usable with NIM 2.0. Nim 2.0 is not fully compatible with the 1.* versions. Since 1 year I started the API with NIM 2.0 from scratch but I committed on my personal git repo, the plan was to replace the repo on GitHub with this new one. Here the zip code with the latest correct sources for Nim2.0, inside you will find the SkipperTester. the "SkipperTester" bot location is in src/RTR_nim_botApi2/OtherBots/SkipperTester bash src/RTR_nim_botApi2/OtherBots/SkipperTester/SkipperTester.sh this bash script will try to run the compiled bot in the same directory or the source code (this case). The compiled file is deleted afterwards. In order to be able to see the SkippedTurn events after death, the game cannot end at bot's death, so I suggest to create this kind of match with 3 tanks:
With this set of bots there will be high chances that TackFire will kill the SkipperTester bot first and will continue trying to kill Walls, but Walls will be able to stay alive long enough to allow us to watch that the dead SkipperTester is still receiving the SkippedTurn events. In this version of the API I'm printing, by the API themselves and not the bot, a '+' when a Tick arrived, a '-' when an intent is sent and a '!' when a skippedTurn event is received here is the same source code that can be found in the sources for the SkipperTester bot (SkipperTester.nim) import os
import ../../../RTR_nim_botApi2 # import the bot api
startBot newBot("SkipperTester.json") # start the bot
var dead = false
method run(bot:Bot) =
while bot.isRunning(): # <--- we want mantain the bot running to avoid the automatc go()
sleep(1000) # <--- sleep for 1 second, doing nothing
# bot.go() <--- not sending go, we want to skip every turn!
method onDeath(bot: Bot, e: BotDeathEvent) =
echo "I'm dead: " & $e.turnNumber
dead = true
method onSkippedTurn(bot: Bot, e: SkippedTurnEvent) =
if not dead: echo "Skipped turn: " & $e.turnNumber
else: echo "Skipped turn: " & $e.turnNumber & " (dead)" PS: these API are not usable for complex bots, I just reached a good point of the development but there are bugs that still needs to be fixed. |
@SirStone I am looking into the skipping issue, and hope I will get it into the 0.23 release, but no promise. When creating a Java bot with same behaviour, I am not able to reproduce the issue. But I did not get any skipped turn event with the run() method if go() is never called. So I do expect some issue here. I am looking into it... |
@SirStone Hence, the way your SkipperTester is written is not good for testing the SkipTurnsEvent. import dev.robocode.tankroyale.botapi.*;
import dev.robocode.tankroyale.botapi.events.*;
public class SkipperTester extends Bot {
private boolean dead;
public static void main(String[] args) {
new SkipperTester().start();
}
SkipperTester() {
super(BotInfo.fromFile("SkipperTester.json"));
}
@Override
public void run() {
while (isRunning()) {
int turnTimeOut = getTurnTimeout(); // in microseconds
try {
Thread.sleep(turnTimeOut / 1000); // in milliseconds
} catch (InterruptedException ex) {
break;
}
go(); // skip turn and receive events
}
}
@Override
public void onDeath(DeathEvent e) {
System.out.println("I am dead: " + e.getTurnNumber());
dead = true;
}
@Override
public void onSkippedTurn(SkippedTurnEvent e) {
System.out.println("Skipped turn: " + e.getTurnNumber() + ", dead: " + dead);
}
} The main difference here is happening in the I propose you try out the same thing for the Nim version of this bot and see if the behaviour is changing so it will skip almost all turns, and you will receive the SkippedTurnEvents. |
I don't think this is the right way for you to replicate the behavior. SERVER -> API -> onSkippedTurn When the bot is dead, the API can and should stop sending the "onSkippedTurn" to the bot and this is what your and mine API do. But developing the API i noticed that the SERVER is still sending the SkippedTurnEvent after the bot death, I'm talking about the SERVER -> API piece of the path, you can check it only fiddling with the API code and with the socket listener, even before the json message is converted to an usable object. |
@SirStone |
I've looked in the server code and I found this part that looks like is relevant to this case: I see from the highlighted code that there's no distinction between a 'participant' alive or dead but only if the intent have been received or not, so if a dead bot is still among the participants, is still going to receive the skipped turn event from the server |
@SirStone The bug should be fixed by now (at the server side), and will be available in release 0.23.0. |
Fixed with release 0.23.0 |
Describe the bug
I've took a while to discover this because I actively started again to work on code only yesterday, but looks like to me that at the death of the robot the server is still giving out the "skipped-turn-event" every turn
Expected behavior
2. stopping receiving the "skipped-turn-event" if the bot is dead
Screenshots
![immagine](https://private-user-images.githubusercontent.com/1309932/313459087-4c063008-f8e1-4735-b484-4fcf6f6eb565.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA2MTc1ODYsIm5iZiI6MTcyMDYxNzI4NiwicGF0aCI6Ii8xMzA5OTMyLzMxMzQ1OTA4Ny00YzA2MzAwOC1mOGUxLTQ3MzUtYjQ4NC00ZmNmNmY2ZWI1NjUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MTBUMTMxNDQ2WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YTE0YzM4NzhlYzFiNjNlYjU4NGUyZWVlODNkYTFhODcxZTc4MTU2NzQ5MDY2ZDJiNWZlMDk3MmJiMTE4OThjMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.B9lFOkp_F7JDXfKtgVmmMJmNAdX7nX4CPqq4MLpiiA4)
The text was updated successfully, but these errors were encountered: