Network protocol race conditions.

Discussion in 'Development General' started by rupsbant, Mar 16, 2013.

  1. rupsbant

    rupsbant New Member

    Joined:
    Mar 7, 2013
    Messages:
    7
    Likes Received:
    0
    Hi,

    I'm trying to develop a Pokemon Online bot. Right now it doesn't use illegal moves (it's really really stupid)... And I noticed that the battles randomly stopped.

    After introducing a delay of 10 ms before sending the chosen move, it works perfectly.

    So my question is: When is it OK to send the choice?
    I currently send the answer after I received StartChoices (43).
    StartClock is sent before this message. And three messages are sent after StartChoices: DynamicInfo(x2) and DynamicStats.

    The simplest option is to wait some time until we are sure the server is ready. But there's no guarantee that this works under a heavy load, and for a computer program this is a rather large delay.
    Option two is fixing this in the source code of the server. I don't know C++ very well yet(maybe in three months when my course is finished). And threading issues are no fun to debug.

    I wanted to make you aware of this peculiarity (it's not really a bug). And since you know C++ and the project better than me maybe there's a quick fix.

    P.S. I really really love the project. Thanks for making and supporting it.
     
  2. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    oh well.

    Maybe just continue to wait the 10 ms, or resend if you didn't receive the "stopclock" message. I don't really know what else to tell you since client-battle-bots work fine (in javascript).
     
  3. rupsbant

    rupsbant New Member

    Joined:
    Mar 7, 2013
    Messages:
    7
    Likes Received:
    0
    Thanks for the reply. I didn't really expect you to do something, but it may give problems in the future so it could be good to know.

    I'll let you know how the bot progresses. Source should come online eventually.
     
  4. rupsbant

    rupsbant New Member

    Joined:
    Mar 7, 2013
    Messages:
    7
    Likes Received:
    0
    Update:
    Learned reading C++ templates.
    Found the offending lines.
    Removed the multithreaded guard code. Creates possible bugs, doubles the speed(for me).
    Now searching for a good solution...