Question about making a bot.
Closed this issue · 2 comments
ethsmith commented
I have looked at your examples for making a bot and I understand the code but what I don't understand is where is the "scene" key word coming from. You have it in your code but nothing is imported that has a scene variable or class.
def do_play(scene):
print(scene)
if len(scene['PlayOptions']) == 0:
return []
return create_action(random.choice(scene['PlayOptions']))
How am I allowed to use any programming language and get what is happening and do something with it if I have no idea where scene is?
AiSatan commented
Hi, the scene create here:
def do_POST(self):
content_length = int(self.headers['Content-Length'])
raw_data = self.rfile.read(content_length)
json_data = json.loads(raw_data)
if self.path == "/trace":
ret = _trace.trace(json_data)
elif self.path == "/mulligan":
ret = _bot.get_mulligan_action(json_data)
elif self.path == "/play":
ret = _bot.get_play_action(json_data)
it is just json that came from post
- in hearthstone the rock module send post request to your server-bot
- your server got the post request and extract "post body"-json
- your server-bot make decision and return answer as json
- hearthstone-rock module make the decision
you can look to scene in this file for knowledge what it really have
https://github.com/yangyuan/hearthrock/blob/master/src/Hearthrock.Contracts/RockScene.cs
ethsmith commented
Thanks for the reply back, I will look into this more.