Help Please: Any BGT Devs

Hello all.  A friend and I have been working on a game for a while now.  I had to take some time to deal with some life issues, but honestly, a large part of the reason for the lengthy development time (especially over the last year to year and a half is that we have run into a problem which we are at a loss to solve, and one which the few BGT programmers I know are unable to shed any light on.
My friend and I are pretty sure that the bug, if it is, indeed, a bug, resides in the networking code.  I'll try to explain the issue as best I can.
There is only one random aspect to this game, and therefore, the random seed is passed initially to the client machine, like so:
Server.send_reliable(0, "r:" + random_get_state(), Player);
And then, when events are checked:
if(string_contains(Event.message, "r:", 1) > -1)
{
string[] position = string_split(Event.message, ":", true);
random_set_state(pos ition[1]);
The only time that the random seed is used is when the ball bounces off of the net in the middle of the grid.  Tests show that the seed is passed correctly, so this is not the issue.  I have merely included this here for completeness.
Now to try to explain the issue.  For this example, we will use a 10 x 10 grid.  Player A hits the ball diagonally to player B.  The ball lands at coordinates 8,8 for player A, which would be reflected as 1,1 for player B (obviously, the movement is mirrored for the opponent.  If player A hits the ball to the right, then it would move to the left as it came into the opponent's side.  So 9,9 to player A is equivalent to 0,0 for player B, 8,8 is equivalent to 1,1 for player B).  Eight to nine times out of 10, the ball will, indeed, land on 1,1 for player B.  However, the remaining times, the ball lands exactly one diagonal off.  So player A shows the ball landing at 8,8.  In stead of landing at 1,1 for player B, however, the ball lands at 0,0, which is exactly one diagonal square off.  If the ball is struck straight ahead rather than diagonally, then the ball is exactly one square off in the direction it was struck.  I.e., if the ball is struck straight ahead from 9,0 from player A, and lands at 9,8, Which translates to 0,1 for player B, instead of 0,1, the ball lands at 0,0.
Two things bother me about this problem.  First, it's not reliably replicated.  It occurs totally randomly, with no discernible pattern.  Tests were conducted, where 25 balls were struck, with 22 landing correctly.  The three that did not land correctly were spaced out.  The main thing that bothers me is that the way this is set up, coordinates are not passed back and forth.  In other words, I do not pass packets with coordinates with each itteration of the ball.  Those would need to be sent reliably to insure delivery, and ini tially, This was tried, and caused major, major problems.  The way it is done now is that instead of passing the coordinates, a packet is sent that indicates the shot that was made, with the appropriate strength and direction parameters.  So the computer receives this, and then calls the appropriate method independently, with the parameters that were received.  Testing done has shown that this occurs correctly, and that all of the parameters used by both machines do match.  What this means is that both computers are executing the exact same ball movement code independent of any influence from the other machine, with the exact same parameters for shot strength, height, speed, etc.  If two computers are using the exact same code, with the exact same values, then both computers should arrive at the same exact result.  If I am player A, and the ball on my machine lands at square 9,9, then given the fact that the exact same movement code is executed, and the exact same parameters from my machine for the movement are being used by the other computer, the ball should land at 0,0 for player B, because the movement should exactly match.  Extensive testing has shown that the parameters are being passed and received correctly, and that the appropriate methods are being called correctly.  Everything matches exactly, except for the final landing outcome, and as stated before, many times it does match correctly, but even on the times that it doesn't, all other parameters and code execution do still match.  I have no idea what might be causing this issue, since the problem is so random, and since it has been determined that everything else is functioning correctly, there should never be a discrepancy in movement, or where the ball lands.  It can't be a timer issue, since both machines are using the same code, with the same timer parameters.  It isn't a network latency issue, because while this might mean t hat my machine executes your shot and calls the code a second or two after you actually strike it, as long as the parameters are received by my machine, the ball should still land correctly, based on the code and the parameters for strength of shot, etc. that were received.  Does anyone have any thoughts at all as to what this issue might be?  I would really, really like to finish this project, but it seems pointless to continue until this has been ironed out, because where the ball lands is critical to the game's scoring system, and the difference of just one coordinate can be huge.  If my machine lands the ball within the grid, and considers my shot good, it might score points for me, but if the other machine lands one square off, and the shot lands outside of the grid and is considered a bad one, then the scoring could change for the opponent, and will not at all match.  Therefore, until this problem is resolved, further coding seems unwise at best, and a waste of time at worst.  I really hope that someone can help to point in the general direction of a solution.  I appreciate any feedback.  Thanks.

JLove

_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Pragma via Audiogames-reflector

Reply via email to