예제 #1
0
def getBestRouteFromResult(startSystem , useSlowMod=True, maxDeep=None):
    if not maxDeep :maxDeep = startSystem.calcRoutingDeep()
    elif maxDeep > startSystem.calcRoutingDeep():
        maxDeep = startSystem.calcRoutingDeep()
    allRoutesTop = []
    bestSellCount = None
    bestOption = None
    print("max deep" , maxDeep)
    print("hops", startSystem.getMinHops(maxDeep))
    print("star dist", startSystem.getMinStarDist(maxDeep))
    print("dist", startSystem.getMinDistFromBest(maxDeep))

    print("routes calculated", startSystem.calcRouteSum())
    
    allRoutes = startSystem.getAllRoutes(maxDeep)
    print("routes with maxdeep", len(allRoutes))
    
    while len(allRoutesTop) == 0 :
        if bestSellCount:  # its on loop 2 true "give the best != 0 sell cout route back"
            bestOption = True
        for endsystem in allRoutes:
            route = endsystem.getSystemsFromRoute()
            
            for system in route:  # reset sell status
                system._sellDone = None
                system._raresInSystem = None

            for system in route:
                if system._raresInSystem == None: system._raresInSystem = myrares.getRaresInSystem(system.systemID)
                sellItems(system, route, True)
            sellItems(route[0], route, True)  # sell on start== end system
        
            notSellCount = 0
            for oldsystem in route:
                if oldsystem._sellDone == None and oldsystem._raresInSystem:
                    notSellCount += 1
            if notSellCount == 0 or (bestOption == True and notSellCount == bestSellCount):
                # top route can sell all items
                allRoutesTop.append(route)
                bestSellCount = notSellCount
            elif bestSellCount == None or bestSellCount > notSellCount:
                bestSellCount = notSellCount
                
    
    print("not sell count", bestSellCount)
    print("top routes", len(allRoutesTop))

    bestDist = None
    shortestStarDist = None
    backToStartDist = None
    bestBackToStartDist = None
    bestRating = None
    for route in allRoutesTop:
        totalDist = 0
        totalSunDist = 0
        syslist = ""
        for system in route:
            if system._hopsFromBefore : totalDist += system._dist
            if system.starDist : totalSunDist += system.starDist
            syslist += "%s" % system.systemID
            syslist += ", "
    #    print(totalHops, totalSunDist, system.systemName ,syslist)
        backToStartDist = mydb.getDistanceFromTo(system.systemID, route[0].systemID) 
        totalDist += backToStartDist  # add back to start distance
        #######################
        # # rating calculation
        #######################
        rating = backToStartDist * 2 + totalDist / len(route) + totalSunDist * 1.5 / len(route)
#        print(backToStartDist, totalDist, totalSunDist , rating)

        if not shortestStarDist or shortestStarDist > totalSunDist:
            shortestStarDist = totalSunDist
        if not bestBackToStartDist or bestBackToStartDist > backToStartDist:
            bestBackToStartDist = backToStartDist
        if not bestDist or bestDist > totalDist:
            bestDist = totalDist

        if not bestRating or bestRating > rating:
            usedRoute = "used route: starDist %dls len %dly backtostart %dly" % (totalSunDist, totalDist, backToStartDist)
            bestRating = rating
            bestRoute = route

    print("best rating ", bestRating)
    if bestRoute:
        dist = bestRoute[len(bestRoute) - 1].getStardistanceFromRoute()
        print("best star dist", shortestStarDist , "used route", dist, dist / len(bestRoute))
    else:
        print("best star dist", shortestStarDist , "noting used")
    print("best dist", bestDist)
    print("best bestBackToStartDist", bestBackToStartDist)
    print(usedRoute)
  
    stop = timeit.default_timer()
    print(round(stop - start, 3))
    # useSlowMod = False
    #######################
    ## rerouting in slow mode
    ## calc all avalibel routes to the best route (optimize the path)
    #######################
    if useSlowMod == True:
        systemList = []
        for system in bestRoute:
            if myStartSystem != system.systemID:
                systemList.append([ system.systemID, system.starDist ])

        print("slow calc with %d rare systems" % len(systemList))

        startSystem = elite.route(mydb, None, maxDeep, maxJumpDistance, maxHops)
        startSystem._availableSystemList = systemList
        startSystem.systemID = mydb.getSystemIDbyName(myStartSystem)  # Startsystem
        startSystem.initSystem = startSystem
        startSystem.calcAllRoutesFromSystem(True)  # slow mode calc
        # maxDeep = startSystem.calcRoutingDeep()
        # route = startSystem.getBestRoute(maxDeep)
        (bestRoute, bestSellCount, bestRating) = getBestRouteFromResult(startSystem, False, maxDeep)  # #recrusive run

    return (bestRoute, bestSellCount, bestRating)
예제 #2
0
def getBestRouteFromResult(startSystem, useSlowMod=True, maxDeep=None):
    if not maxDeep: maxDeep = startSystem.calcRoutingDeep()
    elif maxDeep > startSystem.calcRoutingDeep():
        maxDeep = startSystem.calcRoutingDeep()
    allRoutesTop = []
    bestSellCount = None
    bestOption = None
    print("max deep", maxDeep)
    print("hops", startSystem.getMinHops(maxDeep))
    print("star dist", startSystem.getMinStarDist(maxDeep))
    print("dist", startSystem.getMinDistFromBest(maxDeep))

    print("routes calculated", startSystem.calcRouteSum())

    allRoutes = startSystem.getAllRoutes(maxDeep)
    print("routes with maxdeep", len(allRoutes))

    while len(allRoutesTop) == 0:
        if bestSellCount:  # its on loop 2 true "give the best != 0 sell cout route back"
            bestOption = True
        for endsystem in allRoutes:
            route = endsystem.getSystemsFromRoute()

            for system in route:  # reset sell status
                system._sellDone = None
                system._raresInSystem = None

            for system in route:
                if system._raresInSystem == None:
                    system._raresInSystem = myrares.getRaresInSystem(
                        system.systemID)
                sellItems(system, route, True)
            sellItems(route[0], route, True)  # sell on start== end system

            notSellCount = 0
            for oldsystem in route:
                if oldsystem._sellDone == None and oldsystem._raresInSystem:
                    notSellCount += 1
            if notSellCount == 0 or (bestOption == True
                                     and notSellCount == bestSellCount):
                # top route can sell all items
                allRoutesTop.append(route)
                bestSellCount = notSellCount
            elif bestSellCount == None or bestSellCount > notSellCount:
                bestSellCount = notSellCount

    print("not sell count", bestSellCount)
    print("top routes", len(allRoutesTop))

    bestDist = None
    shortestStarDist = None
    backToStartDist = None
    bestBackToStartDist = None
    bestRating = None
    for route in allRoutesTop:
        totalDist = 0
        totalSunDist = 0
        syslist = ""
        for system in route:
            if system._hopsFromBefore: totalDist += system._dist
            if system.starDist: totalSunDist += system.starDist
            syslist += "%s" % system.systemID
            syslist += ", "
    #    print(totalHops, totalSunDist, system.systemName ,syslist)
        backToStartDist = mydb.getDistanceFromTo(system.systemID,
                                                 route[0].systemID)
        totalDist += backToStartDist  # add back to start distance
        #######################
        # # rating calculation
        #######################
        rating = backToStartDist * 2 + totalDist / len(
            route) + totalSunDist * 1.5 / len(route)
        #        print(backToStartDist, totalDist, totalSunDist , rating)

        if not shortestStarDist or shortestStarDist > totalSunDist:
            shortestStarDist = totalSunDist
        if not bestBackToStartDist or bestBackToStartDist > backToStartDist:
            bestBackToStartDist = backToStartDist
        if not bestDist or bestDist > totalDist:
            bestDist = totalDist

        if not bestRating or bestRating > rating:
            usedRoute = "used route: starDist %dls len %dly backtostart %dly" % (
                totalSunDist, totalDist, backToStartDist)
            bestRating = rating
            bestRoute = route

    print("best rating ", bestRating)
    if bestRoute:
        dist = bestRoute[len(bestRoute) - 1].getStardistanceFromRoute()
        print("best star dist", shortestStarDist, "used route", dist,
              dist / len(bestRoute))
    else:
        print("best star dist", shortestStarDist, "noting used")
    print("best dist", bestDist)
    print("best bestBackToStartDist", bestBackToStartDist)
    print(usedRoute)

    stop = timeit.default_timer()
    print(round(stop - start, 3))
    # useSlowMod = False
    #######################
    ## rerouting in slow mode
    ## calc all avalibel routes to the best route (optimize the path)
    #######################
    if useSlowMod == True:
        systemList = []
        for system in bestRoute:
            if myStartSystem != system.systemID:
                systemList.append([system.systemID, system.starDist])

        print("slow calc with %d rare systems" % len(systemList))

        startSystem = elite.route(mydb, None, maxDeep, maxJumpDistance,
                                  maxHops)
        startSystem._availableSystemList = systemList
        startSystem.systemID = mydb.getSystemIDbyName(
            myStartSystem)  # Startsystem
        startSystem.initSystem = startSystem
        startSystem.calcAllRoutesFromSystem(True)  # slow mode calc
        # maxDeep = startSystem.calcRoutingDeep()
        # route = startSystem.getBestRoute(maxDeep)
        (bestRoute, bestSellCount,
         bestRating) = getBestRouteFromResult(startSystem, False,
                                              maxDeep)  # #recrusive run

    return (bestRoute, bestSellCount, bestRating)
예제 #3
0
                    if myTitle:
                        print("\t__Sell__")
                        myTitle = False
                    for item in oldsystem._raresInSystem:
                        print("\t\tItem: %s" % (item["Name"]))









myrares = elite.rares(mydb)
myroute = elite.route(mydb)

systemList = myrares.getRaresListFitered(maxSunDistance)
print("calc with %d rare systems" % len(systemList))
myRaresRoute = []

startSystem = elite.route(mydb, None, maxDeep, maxJumpDistance, maxHops)
startSystem._availableSystemList = systemList
startSystem.systemID = mydb.getSystemIDbyName(myStartSystem)  # Startsystem
startSystem.initSystem = startSystem
startSystem.calcAllRoutesFromSystem(useSlowModOnStart)


def getBestRouteFromResult(startSystem , useSlowMod=True, maxDeep=None):
    if not maxDeep :maxDeep = startSystem.calcRoutingDeep()
    elif maxDeep > startSystem.calcRoutingDeep():
예제 #4
0
        if oldsystem._sellDone:
            continue
        dist = mydb.getDistanceFromTo(system.systemID, oldsystem.systemID)
        if dist >= sellDist:
            if oldsystem._raresInSystem:
                oldsystem._sellDone = True
                if muted == False:
                    if myTitle:
                        print("\t__Sell__")
                        myTitle = False
                    for item in oldsystem._raresInSystem:
                        print("\t\tItem: %s" % (item["Name"]))


myrares = elite.rares(mydb)
myroute = elite.route(mydb)

systemList = myrares.getRaresListFitered(maxSunDistance)
print("calc with %d rare systems" % len(systemList))
myRaresRoute = []

startSystem = elite.route(mydb, None, maxDeep, maxJumpDistance, maxHops)
startSystem._availableSystemList = systemList
startSystem.systemID = mydb.getSystemIDbyName(myStartSystem)  # Startsystem
startSystem.initSystem = startSystem
startSystem.calcAllRoutesFromSystem(useSlowModOnStart)


def getBestRouteFromResult(startSystem, useSlowMod=True, maxDeep=None):
    if not maxDeep: maxDeep = startSystem.calcRoutingDeep()
    elif maxDeep > startSystem.calcRoutingDeep():