X-Git-Url: https://git.ucc.asn.au/?p=progcomp2013.git;a=blobdiff_plain;f=qchess%2Fmain.py;h=3f5d52e0ff3702c1a758e4450a46d2f3d5fc6531;hp=a0a40db106bee1e31d9c91d02c191cb6867aff21;hb=bfa63f1a2dc9c66399f8159857d4cc54f038eaa2;hpb=e0c24aed084b96f3c5800d869bc759f89667bd6a;ds=sidebyside diff --git a/qchess/main.py b/qchess/main.py index a0a40db..3f5d52e 100644 --- a/qchess/main.py +++ b/qchess/main.py @@ -30,31 +30,36 @@ def main(argv): global graphics # Magical argument parsing goes here - if len(argv) == 1: - players = [HumanPlayer("saruman", "white"), AgentRandom("sabbath", "black")] - elif len(argv) == 2: - players = [AgentPlayer(argv[1], "white"), HumanPlayer("shadow", "black"), ] - elif len(argv) == 3: - players = [AgentPlayer(argv[1], "white"), AgentPlayer(argv[2], "black")] +# if len(argv) == 1: +# players = [HumanPlayer("saruman", "white"), AgentRandom("sabbath", "black")] +# elif len(argv) == 2: +# players = [AgentPlayer(argv[1], "white"), HumanPlayer("shadow", "black"), ] +# elif len(argv) == 3: +# players = [AgentPlayer(argv[1], "white"), AgentPlayer(argv[2], "black")] + - # Construct the board! board = Board(style = "quantum") + # Construct the board! + if len(argv) == 1: + players = [NetworkSender(HumanPlayer("saruman", "white"), board), NetworkReceiver("black", board, 'localhost')] + + else: + players = [NetworkReceiver("white", board, 'localhost'), NetworkSender(HumanPlayer("sabbath", "black"), board)] + + + + + graphics = GraphicsThread(board, grid_sz = [64,64]) # Construct a GraphicsThread! I KNOW WHAT I'M DOING! BEAR WITH ME! + + + + game = GameThread(board, players) # Construct a GameThread! Make it global! Damn the consequences! - #try: - if True: - graphics = GraphicsThread(board, grid_sz = [64,64]) # Construct a GraphicsThread! I KNOW WHAT I'M DOING! BEAR WITH ME! - game.start() # This runs in a new thread - #except NameError: - # print "Run game in main thread" - # game.run() # Run game in the main thread (no need for joining) - # return game.error - #except Exception, e: - # raise e - #else: - # print "Normal" - graphics.run() - game.join() - return game.error + graphics.error + game.start() # This runs in a new thread + + graphics.run() + game.join() + return game.error + graphics.error # This is how python does a main() function...