Skip to content

Turn two is skipped (?) #8

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

Closed
dEgolf opened this issue Mar 18, 2022 · 3 comments
Closed

Turn two is skipped (?) #8

dEgolf opened this issue Mar 18, 2022 · 3 comments
Assignees

Comments

@dEgolf
Copy link

dEgolf commented Mar 18, 2022

Describe the bug
It seems like the second turn of my robot is skipped.

To Reproduce
Steps to reproduce the behavior:

  1. Create a testing robot that prints out the current turn in its Run member. Working in F#, I used the following code:
    override this.Run() =  
            while(this.IsRunning) do
                use writer = File.AppendText("log.txt") 
                writer.WriteLine("It is turn: " + (string this.TurnNumber))                 
                this.Go()
  1. Create a battle with this testing robot and some other robot (I used Target).
  2. Let the battle run for a few seconds.
  3. Examine the log file "log.txt"

Expected behavior
I would expect each robot to be able to act on each turn. In particular, I would expect the log file created above to include the line "It is turn: 2".

Screenshots
The start of the resulting log file:
turn two is skipped

Desktop (please complete the following information):
Windows 10

Java info:
openjdk version "11.0.14.1" 2022-02-08
OpenJDK Runtime Environment Temurin-11.0.14.1+1 (build 11.0.14.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.14.1+1 (build 11.0.14.1+1, mixed mode)

Additional context
I'm using v0.10.0 of robocode tank-royale.

@flemming-n-larsen
Copy link
Contributor

flemming-n-larsen commented Mar 19, 2022

Thanks for reporting this issue. 👍I will have a look into this later.

When creating the sample bots, I saw this behavior once in a while. To me, it looks like some network latency in the beginning when the bot(s) are starting up. Perhaps the WebSocket client needs to "warm-up" to avoid this issue, and the server might give the bots like 10x more time the first 5-10 turns to get up to speed.

Anyways. Since Robocode Tank Royale (RTR) is network-based (web-socket), there is no 100% guarantee that a bot intent will be sent from a bot and received by the server within the time limit for all turns. (I assume that all packages will eventually be sent and received on WebSocket since it is TCP-based).
I propose that a bot should always expect that a turn might be skipped once in a while (for one or the other reason), and make a more robust robot design that is able to cope with that fact.

@flemming-n-larsen
Copy link
Contributor

flemming-n-larsen commented Jun 2, 2022

Hi @dEgolf ,
I have been able to reproduce this issue with both the Java and C#/.Net bots. The main bug was a raise condition at the server side, which is now fixed with release 0.13.3.

Note that your bot might skip turns. So you can add a OnSkippedTurn event handler and e.g. write to the console like: Console.WriteLine("Skipped turn :" + skippedTurnEvent.TurnNumber) assuming that you run your bot from a console to debug it. 🙂

@flemming-n-larsen
Copy link
Contributor

To my knowledge, this issue can now be closed as the problem with skipping the 2nd turn is fixed.
Note that a bot might skip turn for the very first round. I guess this is due to "warm up" of the websocket connection. At least another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants