between player turns to avoid glitch.
  • 6 posts
  • Page 1 of 1
cbt711 wrote:
So I notice time to time the end of a players turn and the beginning of the next player's turn overlap. It usually just looks odd in the log, but occasionally it can ruin a game. Like this one:

10 Feb, 19:53 gerk224 ran out of time.
10 Feb, 19:50 gerk224 received 3 troops for territories.
10 Feb, 19:50 gerk224 has been defeated by cbt711.
10 Feb, 19:50 gerk224 started the turn.
10 Feb, 19:50 cbt711 ran out of time.
10 Feb, 19:50 cbt711 received a card.
10 Feb, 19:50 Eastern Australia (cbt711) attacks Papua New Guinea (gerk224) conquering it, killing 1 troops, losing 1.

I suggest maybe a 500ms (millisecond) delay for critical events like running out of time, player turns ending, conquering a player. Just so there can't be an overlap of player's turns like this. It obviously ruined the game as chaining together runs at players is how you win most of the time and this ended said chain. The result was Gerk224 had a turn with no territories to place troops on, and had to time out. Either he should have been defeated and time extended, or time should have ran out and he should have 1 troop and 1 territory left, but obviously not both. I think a simple for loop or while loop or do loop (Programmer preference) for 250 to 500 ms to let the program catch up between turns could help.

Thanks for your time.
Vexer wrote:
There actually already is a 200ms delay before a turn is missed. It must have been the case that the server was so busy at the time that it took longer than that for the defeat player code to finish. I plan on rewriting all the turn code soon. I'm glad you noticed this and reported it.

Do you recall any other games with similar glitches? Also, please always include the game number in bug reports.
cbt711 wrote:
I have seen the overlap about a half dozen times in my 70 ish games. Good to know there is a delay... Sorry I don't have the numbers of the other games I've seen it. It didn't affect game play in any of the other games. I did include the above game number to a bug message to Fendi.

Thanks for the quick response Vexer.
Vexer wrote:
It turns out that simply increasing the delay only solved half of the problem (the half where the next player was able to start their turn before your attack had finished processing). It would not fix the problem of not getting additional time after killing the player.

What I had to do was change the game code to check and make sure the current time is less than (not less than or equal to) the expiration time before allowing any commands to go through. Then in the 'expire turns code' I changed it so that it would only expire if the current time was greater than the expiration and not greater than or equal to. This means that there will be at least a full second in between the time where you can't make anymore attacks and the time the turn is switched to the next player. That way if your last attack kills a player your turn will still exist in the database so that it can be updated with the additional time.

I'm pretty confident that this will fix it 99.99% of the time but if the server is really really backed up then it's possible the processing of an attack could take more than a second. I'd rather not add a longer delay for an unlikely scenario though. Please let me know if you see this glitch again.

And again I thank you. I probably would not have figured out how to correctly solve this problem (I would have solved it half way) if you hadn't given me this exact example.
cbt711 wrote:
Hey thank you for the great work. Now can I have my points back from that game? :-D haha. 

What do you use to program this site, Java or C++? Or maybe some flash or html5 that's way beyond me. I finally finished my EE (only took 12 years of school and military service), and want to learn an applicable language and actually get good at it instead of just BS assignments / labs about data entry. The only languages I'm proficient with are PLC and Labview graphical programming.

I'm glad this example helped.
Cireon wrote:
cbt711 - Feb 26, 03:55 PM
What do you use to program this site, Java or C++?
Serverside code is in PHP. Clientside naturally HTML and JavaScript.
It is a bit off topic though.

I assume this thread can be locked now? (vexer: lets keep it open in case I didn't actually fix the bug and there are more games to report.)
“This is how humans are: We question all our beliefs, except for the ones that we really believe in, and those we never think to question.”
- Speaker for the Dead, O.S. Card