Skip to content

Instantly share code, notes, and snippets.

@TheCherry
Last active October 10, 2017 22:26
Show Gist options
  • Save TheCherry/de038307d19f39e9c14a387a03f9978d to your computer and use it in GitHub Desktop.
Save TheCherry/de038307d19f39e9c14a387a03f9978d to your computer and use it in GitHub Desktop.
fp_id = FriendlyPlayerExporter(tps[-1]).export()
reward = 0
class MyETP(EntityTreeExporter):
last_player = "Unknown"
def handle_block(self, block):
super(MyETP, self).handle_block(block)
# for p in block.packets:
# self.export_packet(p)
# pp(block.type.name)
g = self.game
# for p in g.players:
# pp(p.player_id)
# exit()d
board = get_board(g, fp_id)
reward = 0
card = [e for e in g.entities if(e.id == block.entity)]
if card:
card = card[0]
player = "Player" if card.controller and card.controller.player_id == fp_id else "Enemy"
if(block.type == BlockType.PLAY or block.type == BlockType.ATTACK):# or block.type == BlockType.ATTACK):
# board = get_board(g)
if(card):
card_cd = get_cd(card.card_id)
# pp(card.controller.player_id)
for minion in board:
reward += minion.tags[GameTag.ATK]
reward += minion.tags[GameTag.HEALTH]
reward += 1
reward += get_amount_handcards(g, fp_id)*2
pp(reward)
# reward += get_amount_handcards(g, fp_id)*2
# pp(reward)
# if(block.type == BlockType.PLAY):
# pp("{:<20}: {:<8} - {}".format(player.name, block.type.name, card_cd["name"]))
# else:
target = [e for e in g.entities if(e.id == block.target)]
target_cd = None
target_name = None
if(target):
target_cd = get_cd(target[0].card_id) if target else None
target_name = target_cd["name"]
# print(player.name, block.type.name, card_cd["name"], target_cd["name"])
self.last_player = player
pp("{:<7}: {:<8} - {:<25} > {}".format(player, block.type.name, card_cd["name"], target_name))
cards = get_amount_handcards(g, fp_id)
minions = get_board(g, fp_id)
if(player == "Player"):
reward = cards + len(minions)
# pp(reward)
# actions.append([card, target])
# reward += 1
if(block.type == BlockType.TRIGGER):
blocks.append(block)
# pp(block.type)
for packet in block.packets:
if "tag" in packet.__dict__ and type(packet.tag) is not int and packet.tag == GameTag.TURN:
## TURN
# pp(packet.__dict__)
if(player == "Player"):
print("{:<7} - TURN".format(self.last_player))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment