Exemplo n.º 1
0
def run(col, row, k, ai_path_1, ai_path_2, fh, mode='t', full_path=None):
    if full_path is not None:
        ai_path_1 = full_path + ai_path_1
        ai_path_2 = full_path + ai_path_2
    main = GameLogic(col, row, k, 'l', debug=True)
    return main.Run(fh=fh,
                    mode=mode,
                    ai_path_1=ai_path_1,
                    ai_path_2=ai_path_2,
                    time=1200)
Exemplo n.º 2
0
    # Because the initialization of network mode is different from the normal modes,
    # the initialization of network mode is separated from other modes.
    if len(sys.argv) == 3:
        mode = sys.argv[1]
        if mode == 'n' or mode == 'network':
            ai_path = sys.argv[2]
            response,host_flag, rule = network_init()

            rule = list(map(lambda x:int(x),rule))

            col, row, k, order = rule

            main = GameLogic(col, row, k, 'n', debug=True)
            try:
                main.Run(mode=host_flag, ai_path=ai_path, info=response, time=1200)
            except:
                import traceback
                traceback.print_exc()
                import threading
                for timer in threading.enumerate():
                    if type(timer) == threading.Timer:
                        timer.cancel()
            exit(0)
        else:
            print("Invalid Parameters")
            sys.exit(-1)

    if len(sys.argv) < 5:
        print("Invalid Parameters")
        sys.exit(-1)
Exemplo n.º 3
0
from GameLogic import GameLogic
import sys

if __name__ == "__main__":
    if len(sys.argv) < 6:
        print("Invalid Parameters")
        sys.exit(-1)

    col = int(sys.argv[1])
    row = int(sys.argv[2])
    k = int(sys.argv[3])
    g = int(sys.argv[4])
    mode = sys.argv[5]
    debug = False
    if len(sys.argv) == 7 and sys.argv[6] == "-d":
        debug = True

    main = GameLogic(col,row,k,g,mode,debug)
    main.Run()