Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping Unqueue to the corresponding DE_QUEUE action #114

Open
noreallyimfine opened this issue Dec 11, 2024 · 5 comments
Open

Mapping Unqueue to the corresponding DE_QUEUE action #114

noreallyimfine opened this issue Dec 11, 2024 · 5 comments

Comments

@noreallyimfine
Copy link

Hi, I'm working on parsing the match to draw out some summary statistics. I have run into an issue where I can't tell how to associate the queueing action to an unqueueing one, to know the villager wasn't created.

I see this object showing a villager queued up:

{'timestamp': '0:07:54.729000',
  'type': 'DE_QUEUE',
  'payload': {'object_ids': [1933],
   'amount': 1,
   'unit_id': 83,
   'sequence': 474729,
   'unit': 'Villager'},
  'player': 1}

then there's this one showing something unqueued:

{'timestamp': '0:07:58.425000',
  'type': 'SPECIAL',
  'payload': {'order_id': 4,
   'slot_id': 0,
   'target_id': -1,
   'x': 0.0,
   'y': 0.0,
   'object_ids': [494848],
   'sequence': 478425,
   'order': 'Unqueue'},
  'player': 1}

I am as sure as i can be that this unqueue is the unqueueing of the villager queued in the first object. But I can't figure how what value in the unqueue object can be used to identify where/what was unqueued. I suspect it should be the object_id but I don't see anywhere that 494848 is identified as the TC.

Any help greatly appreciated

@denniske
Copy link
Contributor

If you want to be 100% sure you can record your own game against AI and then look at the recording

@noreallyimfine
Copy link
Author

noreallyimfine commented Dec 16, 2024

It is the unqueuing of that villager, but what ID connects the 2? or is supposed to connect the 2?

I want to use this in a script so am looking to connect events in a reliable automatable way.

@happyleavesaoc
Copy link
Owner

I suspect the unqueue object_id is not being correctly parsed, at least based on the example you gave.

@noreallyimfine
Copy link
Author

noreallyimfine commented Dec 17, 2024

oh that is entirely possible.

I am using the parse_match() func to process the .aoe2record file. Then I'm parsing the actions to track villagers created, looking for DE_QUEUE for queued vils and SPECIAL with the order: 'Unqueue' for unqueued.

Am I missing something?

this is my code for reference

`def summarize_match(match_obj):
match_summary = {
'players': {}
}

for player in match_obj['players']:
    match_summary['players'][player['number']] = {
        'name': player['name'],
        'civ': player['civilization'],
        'winner': player['winner'],
        'eapm': player['eapm'],
        'dark_age_vils': 0,
    }

age_research_actions = [e for e in match_obj['actions'] if e['type'] == 'RESEARCH' and e['payload']['technology'] in AGES]
for act in age_research_actions:
        player = act['player']
        civ = match_summary['players'][player]['civ']
        age = act['payload']['technology']
        age_landing_time = calculate_age_landing_time(age, act['timestamp'], civ)
        age_name = (age.split(' ')[0]).lower()
        match_summary['players'][player][f"{age_name}_research_time"] = parse_to_timedelta(act['timestamp'])
        match_summary['players'][player][f"{age_name}_landing_time"] = age_landing_time

for player in match_summary['players']:
    player_feudal_research_time = f"{match_summary['players'][player]['feudal_research_time']}"
    player_civ = match_summary['players'][player]['civ']

    active_tc_time = 0
    for act in match_obj['actions']:
        if act['player'] == player and act['timestamp'] < player_feudal_research_time:
            if act['type'] == 'DE_QUEUE' and act['payload']['unit'] == 'Villager':
                match_summary['players'][player]['dark_age_vils'] += 1
                active_tc_time += get_civ_research_time(player_civ, act['payload']['unit'])

            elif act['type'] == 'RESEARCH' and act['payload']['technology'] == 'Loom':
                active_tc_time += get_civ_research_time(player_civ, act['payload']['technology'])
            
            elif act['type'] == 'SPECIAL' and act['payload'].get('order') == 'Unqueue':
                print(act)
                ...

    match_summary['players'][player]['dark_age_idle_tc_time'] = format_timedelta(abs(parse_to_timedelta(player_feudal_research_time) - timedelta(seconds=active_tc_time)))

pprint(match_summary)
return format_timedeltas(match_summary)`

@happyleavesaoc
Copy link
Owner

I'm saying there might be a bug in mgz, not that you are doing something wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants