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")]
35 # elif len(argv) == 2:
36 # players = [AgentPlayer(argv[1], "white"), HumanPlayer("shadow", "black"), ]
37 # elif len(argv) == 3:
38 # players = [AgentPlayer(argv[1], "white"), AgentPlayer(argv[2], "black")]
41 board = Board(style = "quantum")
42 # Construct the board!
44 players = [NetworkSender(HumanPlayer("saruman", "white"), board), NetworkReceiver("black", board, 'localhost')]
47 players = [NetworkReceiver("white", board, 'localhost'), NetworkSender(HumanPlayer("sabbath", "black"), board)]
52 graphics = GraphicsThread(board, grid_sz = [64,64]) # Construct a GraphicsThread! I KNOW WHAT I'M DOING! BEAR WITH ME!
57 game = GameThread(board, players) # Construct a GameThread! Make it global! Damn the consequences!
58 game.start() # This runs in a new thread
62 return game.error + graphics.error
65 # This is how python does a main() function...
66 if __name__ == "__main__":
67 sys.exit(main(sys.argv))