Increase and decrease in troops during an attack
  • 13 posts
  • Page 1 of 1
Dominator000 wrote:
Dear Admins,

Kindly note that during game 286309, and while I was attacking I faced a problem in which I saw (as an example) my troops for one instant as 27 then 25 and suddenly 10 then 15 and so on... this ruined the game honestly as some players got weakened. If the numbers of troops were clear I would have stopped earlier and if it was a lag problem then why did the number of troops increased later! During the same game I attacked with 13 troops a country with 3 troops and conquered it losing 2 troops but the crazy thing is that the remaining 10 troops had become his!! I had to reload the page to get things right :P

Thanks in advance,
Vexer wrote:
The number of troops on a territory is stored by the server in the database and then sent to your browser. Sometimes because of lag the two don't match. The number of troops in the database is always correct but your browser may not be. Slow down your attacks if you want accuracy.

The reason why the troops went down to 10 and then back up to 15 is because some of your attacks failed to go through because the database was too busy to process them. The server processed the attack and told your browser about it which reduced the troop count you saw but the update did not go through to the database so on the next attack your browser was updated to again match the database which still said 15 troops because your previous attacks couldn't go through. This is a very tricky problem that I have worked on several times. I plan to revisit it soon. In the mean time don't attack so fast.

About the 10 troops becoming his.. just another instance of your browser not having the most up to date info. Sometimes you just have to do a refresh like you did.

The troop amounts are correct on the server, there is no glitch causing their value to be wrong. You just have to allow time for your browser to update.
Dominator000 wrote:
Thanks for the explanation Vexer. I really appreciate it as I'm keen on learning new staff specially regarding such a topic.

Simple question, are you updating the database after each attack (i.e. after each attack request resulting from pressing the attack button)? If so, why don't you store the whole attack process on the server's RAM then after finishing the attack phase you may try to update the database, this way you'll reduce the amount of requested transactions to the database thus reducing the possibilit of the database not able to process all the requests as the number of the requests will decrease tremedously (it might make more sense if all other games are updating on the same database at the same time) if there exist a limited availability in the RAM then you might group the number of attacks and this can be executed in several ways. One example could be in executing 3 consecutive attacks using the server's RAM and then updating the database. Other solution is taking advantage of the javascript being able to be executed on the client's side to perform such transactions and after finishing just sending a request to update the sever.

What do you think about the suggestions?
Vexer wrote:
Well, can't use javascript to do the attacks because then it could be hacked.

The problem with not updating the database after every attack is that it's possible for a player to have two tabs of the same game open and make attacks from each. There has to be one place where the actual troop count is always up to date and I don't see any other way to do it than the database.

We have been working for sometime on reducing the load on the database server by optimizing the queries. We can get further optimizations by reducing requests for data that hasn't been modified. Currently anytime someone makes a move on their turn a flag gets set which tells all the other players browsers to update the game. It updates the territories, players, cards, chat, log, everything. It would be better, but more complicated if each of those had it's own flag so that only what is necessary gets updated.
Dominator000 wrote:
.
I see how complicated it is :P Your flag suggestion makes sense :) wish you all the luck ;)

.
cbt711 wrote:
I had a similar glitch, mid attack string. 
Spoiler (click to show)
Here's a screen shot of the log and the board.
Attacked from George Town with 6 to Moron, killed 1, lost 1.
Sent 4 to Moron.
Look up and the "send" happened before the attack somehow and I lost the 4 troops.

Horrible timing since that 4 on Moron would have taken some off Stake Bay, then my cap would have pushed up to Stake Bay. Instead I had to just end turn, Stake Bay was reinforced with 5, and eventually became a troop that took out red the next turn with another 5 added.

http://www.dominating12.com/?cmd=game&sec=play&id=286240

I guess the moral of the story is don't send your troops to the next territory too fast.

EDIT: Ok looking at it now, the send did not happen first. There were 2 troops on George town to start the turn. 4 reinforcements @16:47 was the typical draft placement.

So Attacked with 6, killed 1, lost 1, then 4 troops went away and showed up on neither territory. Still probably caused by sending troops too fast. I definitely remember hitting send quickly there.
Dominator000 wrote:

Checked it cbt... so even after you reloaded the same error persisted? Weired!

cbt711 wrote:
Yeah it wasn't the glitch where the troops change colors. That can be fixed by refreshing. Nothing helped here. Refresh, logging out, adding time. 
Dominator000 wrote:
Hope Vexer fixes it soon. Believe he will :)

BTW once I had my cards suddenly change color to form a set (though they weren't) still I couldn't cash in :P :P :P Vexer later fixed the problem :D

Vexer wrote:
I don't think it was the case that an attack was processed after you sent in troops because the error would have been logged in the database. It's more likely that the update for the 'from' territory went through but the update for the 'to' territory didn't because the server maxed out at that point.

I'll put it on my to do list to add some code that will check to make sure that both updates go through before moving on.
Dominator000 wrote:
@Vexer: do you mind asking about your educational/professional backgroung? Kind of impressed with the diagnostic and solution proposal process ;)
Vexer wrote:
I took one basic class on programming in high school well over a decade ago. I've been learning bit by bit over the last couple of years so I could program for this site.

I did take a full year of calculus in college so I know about problem solving.

Unfortunately my occupation hardly utilizes these skills, which is probably why I do it as a hobby, so they get some use.
Dominator000 wrote:

So you do it as a hobby and you are that good ;) And thanks for the time you spent trying to improve the site :D