First off, this is absolutely amazing. Thank you.SungSlaver231 wrote: ↑Mon Jun 25, 2018 6:46 amAdditionally, I have created an (incomplete) Python package for interacting with the Anacreon API. Perhaps someone can find it useful.
I've created this thread for players to discuss usage of the Anacreon API with respect to writing scripts/bots to automate gameplay. If this isn't allowed mods please remove it, but the official policy seems very liberal.
For anyone else new to scripting/coding wondering how to set their own thing up:
1. Download all the files from here into a directory (all credit to, and courtesy of SungSlaver231).
2. Then download and install Python 3 and the requests module. You can open the "IDLE" editor program, or any other code/text editor (e.g. Notepad++, Sublime) will do. Create a new file with extension .py, in the same directory as the anacreonlib files, name it myScript.py or similar.
3. Copy paste the below into the file, changing the global fields USERNAME, PASSWORD and SOV_ID as necessary. To get SOV_ID you need to run the script (press F5 in IDLE, or just run using the command line with "python ./myScript.py")
Code: Select all
from anacreon import Anacreon
USERNAME = "imperium"
PASSWORD = "hunter2"
GAME_ID = 4365595
api = Anacreon(USERNAME,PASSWORD)
api.gameID = GAME_ID
gameList = api.get_game_list()
gameInfo = api.get_game_info()
api.sovID = int(gameInfo['userInfo']['sovereignID'])
objects = api.get_objects()
Here is an example of a function that gets the empire names of all players in the game, even if you haven't discovered them yet:
Code: Select all
def getSovereigns():
sovereignList = []
for key in gameInfo['sovereigns']:
sovereignList.append(key['name'])
print(sovereignList)
return sovereignList
getSovereigns()
Code: Select all
['independent', 'Mesophon Traders Union', 'Olos Guaran', 'Faorn Empire', 'Kingdom of Johenna', 'Kalidorn', 'Omnithor', 'Thuhomur Wuchaiju', 'Durandal', 'New Aelion', 'Barricade Fellowship', 'M', 'Scavengers', 'Bozonation', 'evil space pirates', 'Emdief Integration', 'Mombetsu Union', 'ANTARes', 'Velari Directorate', 'kj', 'Also Observer', 'New Nirvana', ' 𝕭', 'IMPERIUM', 'Terran Collective']
Here is a quick intro to the Python language.
Hopefully that helps people get started, if there are any questions feel free to post them in this thread and I'll do my best to answer. I have lots of questions too, don't worry.