Quote:Original post by ToohrVyk
Quote:(build 1 unit->wait validation->build 1 unit->wait validation, ...500 times).
Why are you waiting for validation before building the next unit?
I understand this may look strange, like wanting building 500 units one by one. But this is a rule limitation.
The game i'm programming is an adaptation of an old game (multiplayer on the same computer), and i try to be the most faithful possible (and multiplayer across internet). I've reverse engineered the game, and i want to keep the same algorithm than the original.
In this game, the AI builds 1 unit by one in a kind of loop (simplified):
- while money > $2 - build unit- end-while
But this money may be shared among several players playing simultaneously.
I don't want to change the AI (it will change too much the behavior).
So this same loop may be executed by more than 1 player, and here comes the problem if i don't wait the validation: the two players think they have enough money, but the other one has already used this money. So i add validation and sync, but this lag (lots of validations):
- while - send server 'build unit' order - wait response - if OK, build unit locally (server has already built it) - if KO, break- end-while
This works perfectly for 10 loops, but not for 500 loops... which may be 3000 near the end of the game.
Quote:Are there so many collisions? Ouch...
Yes, like you see above, all the AIs play simultaneously (up to 4 sharing money) which gives 4 loops of 500 build units using the same variable 'money'.
Pascal