def quitGame(): if chessboard.mode is NETWORK: net = chessnet() net.send_move('quit') if chessboard.mode is AI: chessboard.fin.write("quit\n") chessboard.fin.flush() p.terminate() print '>> quit game' sys.exit()
def enqueue_output(out, queue): for line in iter(out.readline, ''): queue.put(line) out.close() pygame.init() DISPLAY_REFRESH = pygame.USEREVENT fps = 60 screen = pygame.display.set_mode(size, 0, 32) chessboard = chessboard() #ai_options = chessai.get_ai_engine_options('harmless') ai_options = chessai.get_ai_engine_options('eleeye') if len(sys.argv) == 2 and sys.argv[1][:2] == '-n': chessboard.net = chessnet() if sys.argv[1][2:] == 'r': pygame.display.set_caption("red") chessboard.side = RED elif sys.argv[1][2:] == 'b': pygame.display.set_caption("black") chessboard.side = BLACK else: print '>> quit game' sys.exit() chessboard.net.NET_HOST = sys.argv[2] elif len(sys.argv) == 1: p = Popen(ai_options['engine_executable'], stdin=PIPE, stdout=PIPE, close_fds=ON_POSIX)
from Queue import Queue, Empty ON_POSIX = 'posix' in sys.builtin_module_names def enqueue_output(out, queue): for line in iter(out.readline, ''): queue.put(line) out.close() pygame.init() screen = pygame.display.set_mode(size, 0, 32) chessboard = chessboard() if len(sys.argv) == 2 and sys.argv[1][:2] == '-n': chessboard.net = chessnet() if sys.argv[1][2:] == 'r': pygame.display.set_caption("red") chessboard.side = RED elif sys.argv[1][2:] == 'b': pygame.display.set_caption("black") chessboard.side = BLACK else: print '>> quit game' sys.exit() chessboard.net.NET_HOST = sys.argv[2] elif len(sys.argv) == 1: p = Popen("./harmless", stdin=PIPE, stdout=PIPE, close_fds=ON_POSIX)