- Code: Select all
(map_id, map_name, map_path) = random.choice(self.game_service.ladder_maps)
game = LadderGame(self.game_service.createUuid(), self.game_service, self.game_stats_service)
self.game_service.games[game.id] = game
player1.game = game
player2.game = game
game.map_file_path = map_path
Almost all module functions depend on the basic function random(), which generates a random float uniformly in the semi-open range [0.0, 1.0). Python uses the Mersenne Twister as the core generator. It produces 53-bit precision floats and has a period of 2**19937-1. The underlying implementation in C is both fast and threadsafe. The Mersenne Twister is one of the most extensively tested random number generators in existence. However, being completely deterministic, it is not suitable for all purposes, and is completely unsuitable for cryptographic purposes.
You can see that it is in fact random. It is just as reasonable that you will get the same 2 maps over and over as it is for any other sequence of maps. There was talk about changing the system in the last dev conference, so that it will not select the map that each player played last. But of course then you could still get loki->badlands->loki->badlands->loki->badlands.....
It is just that one line of code in
https://github.com/FAForever/server/blo ... service.py that chooses the maps. So anyone here could watch a couple python tutorials and change the algorithm. A simple solution would be to check the map that you played last and then pick the next one in the list, and if that happens to be the map your opponent played last, then pick the next one. Then you will never play the same map twice in a row and the games will be almost perfectly distributed among all the maps in the pool. The hard part is figuring out what map each player played last, but I imagine someone on Slack can tell you how to do it. Probably by just getting the last ladder reply for each player and checking what map it was on.