Beispiel #1
0
def main():
    if len(sys.argv) < 2:
        print "Please enter a host name."
        exit(1)

    connection = library.createConnection();

    ai = AI(connection)

    success = library.serverConnect(connection, sys.argv[1], "19000")
    if not success:
        sys.stderr.write("Unable to connect to server\n")
        exit(1)

    if not library.serverLogin(connection, ai.username(), ai.password()):
        exit(1)

    if len(sys.argv) < 3:
        library.createGame(connection)
    else:
        library.joinGame(connection, int(sys.argv[2]))
    while library.networkLoop(connection):
        if ai.startTurn():
            library.endTurn(connection)
        else:
            library.getStatus(connection)

    #Grab the end game state
    library.networkLoop(connection)
    #request the log file
    library.networkLoop(connection)

    ai.end()
    exit(0)
Beispiel #2
0
def main():
    if len(sys.argv) < 2:
        print "Please enter a host name."
        exit(1)

    ai = AI()

    socket = library.open_server_connection(sys.argv[1], "19000")
    if socket == -1:
        sys.stderr.write("Unable to connect to server\n")
        exit(1)

    if not library.login(socket, ai.username(), ai.password()):
        exit(1)

    if len(sys.argv) < 3:
        library.createGame()
    else:
        library.joinGame(int(sys.argv[2]))
    while library.networkLoop(socket, 0):
        if ai.startTurn():
            library.endTurn()
        else:
            library.getStatus()

    while library.networkLoop(socket, 0):
        pass
    exit(0)
Beispiel #3
0
def main():
  if len(sys.argv) < 2:
    print "Please enter a host name."
    exit(1)
    
  connection = library.createConnection();
  
  ai = AI(connection)
    
  success = library.serverConnect(connection, sys.argv[1], "19000")
  if not success:
    sys.stderr.write("Unable to connect to server\n")
    exit(1)
  
  if not library.serverLogin(connection, ai.username(), ai.password()):
    exit(1)
  
  if len(sys.argv) < 3:
    library.createGame(connection)
  else:
    library.joinGame(connection, int(sys.argv[2]))
  while library.networkLoop(connection):
    if ai.startTurn():
      library.endTurn(connection)
    else:
      library.getStatus(connection)
  
  #Grab the end game state
  library.networkLoop(connection)
  #request the log file
  library.networkLoop(connection)

  ai.end()
  exit(0)
Beispiel #4
0
def main():
    if len(sys.argv) < 2:
        print "Please enter a host name."
        exit(1)

    ai = AI()

    socket = library.open_server_connection(sys.argv[1], "19000")
    if socket == -1:
        sys.stderr.write("Unable to connect to server\n")
        exit(1)

    if not library.serverLogin(socket, ai.username(), ai.password()):
        exit(1)

    if len(sys.argv) < 3:
        socket = library.createGame()
    else:
        socket = library.joinGame(int(sys.argv[2]))
    while library.networkLoop(socket, 0):
        if ai.startTurn():
            library.endTurn()
        else:
            library.getStatus()

    #request the log file
    while library.networkLoop(socket, 0):
        pass
    exit(0)