added percentage of systems explored

This commit is contained in:
TanguyPcFixe 2024-05-25 11:26:42 +02:00
parent 1717d25ddb
commit 9ef40206bf

View File

@ -7,7 +7,7 @@ from math import floor
#IMPORTANT BITS #IMPORTANT BITS
###This is the name of the sector you want to search into (Do not use caps!) ###This is the name of the sector you want to search into (Do not use caps!)
sectorName = "Phleedgaa" sectorName = "Byoomiae"
### "weights" to query, beware of big results when searching for lighter systems in more dense area ### "weights" to query, beware of big results when searching for lighter systems in more dense area
@ -16,7 +16,13 @@ weightsToQuery = ["a","b","c","d","e"]
### postFix List, modify as needed ### postFix List, modify as needed
#postFixList =["AA-A","BA-A","CL-Y","DL-Y","EG-Y","FG-Y","YE-A","ZE-A"] #postFixList =["AA-A","BA-A","CL-Y","DL-Y","EG-Y","FG-Y","YE-A","ZE-A"]
postFixList =["UJ-Q"] postFixList =["WP-X"]
@ -63,6 +69,9 @@ sysWeightDict = {}
#dict of dict of systems maximum value by postfix, keyed by weight ( dict["AA-A"]["g"] gives back the maximum recorded value for X where X is the integer in a system name : AA-A GX) #dict of dict of systems maximum value by postfix, keyed by weight ( dict["AA-A"]["g"] gives back the maximum recorded value for X where X is the integer in a system name : AA-A GX)
sysMaxDict = {} sysMaxDict = {}
#This is used to register how much systems are in EDSM to compute an "explored" percentage further
sysDiscovered = {}
postFixWithMultipleHyphens = {} # deals with system names like "Sector AA-A e5-8" postFixWithMultipleHyphens = {} # deals with system names like "Sector AA-A e5-8"
#dict of dict of all the systems in a sector keyed by postfix, keyed by weight, used later for substracting EDSM values from ALL systems #dict of dict of all the systems in a sector keyed by postfix, keyed by weight, used later for substracting EDSM values from ALL systems
@ -73,11 +82,13 @@ base = ""
reference = "" reference = ""
#for each weight class, we initialize our dicts with our postfix list #for each weight class, we initialize our dicts with our postfix list
for weight in weightsToQuery: for weight in weightsToQuery:
sysWeightDict[weight] = {} sysWeightDict[weight] = {}
sysMaxDict[weight] = {} sysMaxDict[weight] = {}
sysCandidates[weight] = {} sysCandidates[weight] = {}
sysDiscovered[weight] = {}
postFixWithMultipleHyphens[weight] = {} postFixWithMultipleHyphens[weight] = {}
#then we populate our dicts with the provided postfix #then we populate our dicts with the provided postfix
@ -85,6 +96,7 @@ for weight in weightsToQuery:
for postfix in postFixList: for postfix in postFixList:
sysWeightDict[weight][postfix], postFixWithMultipleHyphens[weight][postfix] = fetchEdsmSystems(sectorName, postfix, weight) # this is reversed from IG "AA-A G" sysWeightDict[weight][postfix], postFixWithMultipleHyphens[weight][postfix] = fetchEdsmSystems(sectorName, postfix, weight) # this is reversed from IG "AA-A G"
sysMaxDict[weight][postfix] = maxSystemValue(sysWeightDict[weight][postfix]) sysMaxDict[weight][postfix] = maxSystemValue(sysWeightDict[weight][postfix])
sysDiscovered[weight][postfix] = 0
#now we generate the inverse of the known system list #now we generate the inverse of the known system list
@ -96,7 +108,7 @@ for weight in weightsToQuery:
if postFixWithMultipleHyphens[weight][postfix]: #if we have multiple hyphens we take the first system to see what's in front of the hyphen if postFixWithMultipleHyphens[weight][postfix]: #if we have multiple hyphens we take the first system to see what's in front of the hyphen
reference = sysWeightDict[weight][postfix][0] reference = sysWeightDict[weight][postfix][0]
base = reference[:reference.rfind("-")+1] base = reference[:reference.rfind("-")+1]
print(f"Warning, sector {sectorName} {postfix} has multiple hyphens, predictions may be wrong!") print(f"Warning, sector {sectorName} {postfix} with size {weight} has multiple hyphens, predictions may be wrong!")
else: else:
base =f"{sectorName} {postfix} {weight}" base =f"{sectorName} {postfix} {weight}"
@ -104,6 +116,10 @@ for weight in weightsToQuery:
candidate = f"{base}{i}" candidate = f"{base}{i}"
if candidate not in sysWeightDict[weight][postfix]: if candidate not in sysWeightDict[weight][postfix]:
sysCandidates[weight][postfix].append(candidate) sysCandidates[weight][postfix].append(candidate)
else:
sysDiscovered[weight][postfix] += 1
#this computes the percentage of systems that are already discovered on EDSM
sysDiscovered[weight][postfix] = round(sysDiscovered[weight][postfix] / sysMaxDict[weight][postfix] * 100,2)
@ -111,6 +127,9 @@ for weight in weightsToQuery:
print("These are the systems known to EDSM") print("These are the systems known to EDSM")
print(sysMaxDict) print(sysMaxDict)
print("These are the exploration stats in percent of systems known to EDSM versus all the possible systems")
print(sysDiscovered)
#Finally writes the results to a JSON file. #Finally writes the results to a JSON file.
with open(f"{floor(dt.now().timestamp())}-{sectorName}-RESULTS-v2.json",'w') as f: with open(f"{floor(dt.now().timestamp())}-{sectorName}-RESULTS-v2.json",'w') as f: