3 # Do you know what the -u does? It unbuffers stdin and stdout
4 # I can't remember why, but last year things broke without that
7 UCC::Progcomp 2013 Quantum Chess game
8 @author Sam Moore [SZM] "matches"
9 @copyright The University Computer Club, Incorporated
10 (ie: You can copy it for not for profit purposes)
13 # system python modules or whatever they are called
19 [game, graphics] = [None, None]
22 # The main function! It does the main stuff!
25 # Apparently python will silently treat things as local unless you do this
26 # But (here's the fun part), only if you actually modify the variable.
27 # For example, all those 'if graphics_enabled' conditions work in functions that never say it is global
28 # Anyone who says "You should never use a global variable" can die in a fire
32 # Magical argument parsing goes here
34 players = [HumanPlayer("saruman", "white"), AgentRandom("sabbath", "black")]
36 players = [AgentPlayer(argv[1], "white"), HumanPlayer("shadow", "black"), ]
38 players = [AgentPlayer(argv[1], "white"), AgentPlayer(argv[2], "black")]
40 # Construct the board!
41 board = Board(style = "quantum")
42 game = GameThread(board, players) # Construct a GameThread! Make it global! Damn the consequences!
45 graphics = GraphicsThread(board, grid_sz = [64,64]) # Construct a GraphicsThread! I KNOW WHAT I'M DOING! BEAR WITH ME!
46 game.start() # This runs in a new thread
48 # print "Run game in main thread"
49 # game.run() # Run game in the main thread (no need for joining)
57 return game.error + graphics.error
60 # This is how python does a main() function...
61 if __name__ == "__main__":
62 sys.exit(main(sys.argv))