def test_simple_remote_game(self): layout = """ ########## # # #0 1# ########## """ client1 = SimpleClient(SimpleTeam("team1", RandomPlayer()), local=False) client2 = SimpleClient(SimpleTeam("team2", RandomPlayer()), local=False) server = SimpleServer(layout_string=layout, rounds=5, players=2, local=False) self.assertEqual(server.host, "") self.assertEqual(server.port, 50007) self.assertTrue(server.server.is_alive) client1.autoplay_background() client2.autoplay_background() server.run_simple(AsciiViewer) self.assertFalse(server.server.is_alive)
our client might try to connect before the server is ready. This is ‘fixed’ repeated tries and should not be a problem in general. On certain operating systems (at least on Windows), starting processes naïvely may spark a fork bomb. Therefore, all scripts using multiprocessing must use a __name__=="__main__" part to shield from multiple execution of the script when a new process is started. """ from pelita.simplesetup import SimpleClient, SimpleServer from pelita.player import RandomPlayer, BFSPlayer, SimpleTeam, BasicDefensePlayer, NQRandomPlayer if __name__=="__main__": client = SimpleClient("the good ones", SimpleTeam(NQRandomPlayer(), BFSPlayer())) client.autoplay_background() client2 = SimpleClient("the bad ones", SimpleTeam(BFSPlayer(), BasicDefensePlayer())) client2.autoplay_background() layout = """ ################################## #... # .# # # 3# # ## # # ### # # #####1# #. # # # . # ## # #.# # . # . # ######### # ## # ## #### # ##. . . .# #.. . . #. . #. # # ## ##### # # ## #### #.## # # . . . ..# #.. .. # # # # ##### #####