first proper release

This commit is contained in:
TanguyPcFixe 2024-05-20 22:16:57 +02:00
parent 3de0fa734f
commit 97e5dabe14
2 changed files with 25 additions and 122 deletions

View File

@ -1,3 +1,4 @@
# edsmAround # edsmAround
Shitty code to see what's around in Elite Dangerous. Uses EDSM data. Shitty code to see what's around in Elite Dangerous. Uses EDSM data.
To use, open the file and modify the Sector Name. Then run with python3

View File

@ -2,15 +2,16 @@ import requests as r
import re import re
import json import json
#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!)
name = "Cleeque" name = "Cleeque"
### don't touch any of this. Or do, I'm a comment, not a cop.
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"]
###Call to EDSM API, don't run this script too much in a short timeframe.
def apiCall(systemName): def apiCall(systemName):
systems = r.get("https://www.edsm.net/api-v1/systems", params={'systemName' : systemName}) systems = r.get("https://www.edsm.net/api-v1/systems", params={'systemName' : systemName})
return systems return systems
@ -21,81 +22,42 @@ patternh = re.compile(".*[ABCDEFGYZ][ACELGGZ]-[AYDE] [h].*")
patterng = re.compile(".*[ABCDEFGYZ][ACELGGZ]-[AYDE] [g].*") patterng = re.compile(".*[ABCDEFGYZ][ACELGGZ]-[AYDE] [g].*")
listeH = [] listH = []
listeG = [] listG = []
#fetch sector + postfix data from edsm #fetch sector + postfix data from edsm
for p in postFixList: for p in postFixList:
for s in json.loads(apiCall(name +" "+p).content): for s in json.loads(apiCall(name +" "+p).content):
if patternh.match(s['name']): if patternh.match(s['name']):
print(f"adding {s['name']} to list") #print(f"adding {s['name']} to list")
listeH.append(s['name']) listH.append(s['name'])
elif patterng.match(s['name']): elif patterng.match(s['name']):
print(f"adding {s['name']} to list") #print(f"adding {s['name']} to list")
listeG.append(s['name']) listG.append(s['name'])
# also prepare dictionnary for after
# also prepare dictionnary for later
lh[p] = [] lh[p] = []
lmaxh[p] = 0 lmaxh[p] = 0
lg[p] = [] lg[p] = []
lmaxg[p] = 0 lmaxg[p] = 0
lcandidates[p] = []
# lh = {"AA-A" : [],
# "BA-A" : [],
# "CL-Y" : [],
# "DL-Y" : [],
# "EG-Y" : [],
# "FG-Y" : [],
# "YE-A" : [],
# "ZE-A" : []}
# lmaxh = {"AA-A" : 0,
# "BA-A" : 0,
# "CL-Y" : 0,
# "DL-Y" : 0,
# "EG-Y" : 0,
# "FG-Y" : 0,
# "YE-A" : 0,
# "ZE-A" : 0}
# lg = {"AA-A" : [],
# "BA-A" : [],
# "CL-Y" : [],
# "DL-Y" : [],
# "EG-Y" : [],
# "FG-Y" : [],
# "YE-A" : [],
# "ZE-A" : []}
# lmaxg = {"AA-A" : 0,
# "BA-A" : 0,
# "CL-Y" : 0,
# "DL-Y" : 0,
# "EG-Y" : 0,
# "FG-Y" : 0,
# "YE-A" : 0,
# "ZE-A" : 0}
#h systems
for s in listeH:
# print(f"now dealing with {s}") #Sorting H systems into postfix dict entries
for s in listH:
for pre in postFixList: for pre in postFixList:
if pre in s: if pre in s:
length = len(f"{name} {pre} h") length = len(f"{name} {pre} h") ##TODO replace this bullshit
cur = int(s[length:]) cur = int(s[length:])
if cur > lmaxh[pre]: if cur > lmaxh[pre]:
lmaxh[pre] = cur lmaxh[pre] = cur
# print(s)
lh[pre].append(s) lh[pre].append(s)
#Same with G systems
for s in listG:
for s in listeG:
for pre in postFixList: for pre in postFixList:
if pre in s: if pre in s:
length = len(f"{name} {pre} g") length = len(f"{name} {pre} g")
@ -105,27 +67,13 @@ for s in listeG:
lg[pre].append(s) lg[pre].append(s)
print("These are the H sized systems known to EDSM")
# print(lh)
print("These are the H sized systems")
print(lmaxh) print(lmaxh)
#
# print(lg)
print("These are the G sized systems")
print("These are the G sized systems known to EDSM")
print(lmaxg) print(lmaxg)
#generate other systems for H #generate all the systems for H and adds it to the candidate dict only if its not on EDSM
lcandidates = {"AA-A" : [],
"BA-A" : [],
"CL-Y" : [],
"DL-Y" : [],
"EG-Y" : [],
"FG-Y" : [],
"YE-A" : [],
"ZE-A" : []}
for i in postFixList: for i in postFixList:
maxi = lmaxh[i] maxi = lmaxh[i]
@ -134,6 +82,8 @@ for i in postFixList:
if sys not in lh[i]: if sys not in lh[i]:
lcandidates[i].append(sys) lcandidates[i].append(sys)
#same for G systems
for i in postFixList: for i in postFixList:
maxi = lmaxg[i] maxi = lmaxg[i]
for j in range(maxi): for j in range(maxi):
@ -141,59 +91,11 @@ for i in postFixList:
if sys not in lg[i]: if sys not in lg[i]:
lcandidates[i].append(sys) lcandidates[i].append(sys)
#Finally writes the results to a JSON file.
with open(f"{name}-RESULTS.json",'w') as f: with open(f"{name}-RESULTS.json",'w') as f:
f.write(json.dumps(lcandidates, indent=4)) f.write(json.dumps(lcandidates, indent=4))
# length = len(f"{name} {pre} h")
# print(pre)
# if pre in s:
# cur = int(s[length:])
# if cur > lmaxh[pre]:
# lmaxh[pre] = cur
# listeNonEDSM = []
#
# #fill with all systems
#
# for i in ['A','B','C','D','E','F','G','Y','Z']:
# print(i)
# for j in ['A','C','E','L','G','G','Z']:
# for k in ['A','Y','D','E']:
# for l in range(0,600):
# listeNonEDSM.append(f"{name} {i}{j}-{k} h{l}")
# listeNonEDSM.append(f"{name} {i}{j}-{k} g{l}")
#
#
#
# listeNonEDSM = [x for x in listeNonEDSM if x not in listeCompat]
#
#
# [print(s) for s in listeNonEDSM]
# maxi = 0
# listeNbr = []
# for system in listeCompat:
# inte = int(system[system.rfind('h')+1:])
# listeNbr.append(inte)
# if inte > maxi:
# maxi = inte
#
# potential = []
#
# for i in range(0, maxi):
# if i not in listeNbr:
# potential.append(i)
#
# for i in range(0, len(potential)-10, 10):
# print(potential[i:i+10])
#
# #